Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/friendly-vue-devtools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vue': patch
---

Fix dev server crashes when Vue devtools are enabled with Vite 8.
17 changes: 13 additions & 4 deletions packages/integrations/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,22 @@ async function getViteConfiguration(

if (command === 'dev' && options?.devtools) {
const vueDevTools = (await import('vite-plugin-vue-devtools')).default;
const devToolsOptions = typeof options.devtools === 'object' ? options.devtools : {};
plugins.push(
configEnvironmentPlugin(),
const devToolsOptions =
typeof options.devtools === 'object' && options.devtools ? options.devtools : {};
const devToolsPlugins = (
vueDevTools({
...devToolsOptions,
appendTo: VIRTUAL_MODULE_ID,
}),
}) as Plugin[] | Plugin[][]
).flat();
plugins.push(
configEnvironmentPlugin(),
...devToolsPlugins.map((plugin) => ({
...plugin,
applyToEnvironment: (
environment: Parameters<NonNullable<Plugin['applyToEnvironment']>>[0],
) => environment.name === 'client',
})),
);
}

Expand Down
21 changes: 19 additions & 2 deletions packages/integrations/vue/test/basics.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { after, before, describe, it } from 'node:test';
import { parseHTML } from 'linkedom';
import { type Fixture, loadFixture } from './test-utils.ts';
import { type DevServer, type Fixture, loadFixture } from './test-utils.ts';

describe('Basics', () => {
let fixture: Fixture;
Expand Down Expand Up @@ -47,4 +47,21 @@ describe('Basics', () => {
const allPreValues = [...document.querySelectorAll('pre')].map((e) => e.textContent);
assert.deepEqual(allPreValues, ['2345', '0', '1', '1', '1', '10', '100', '1000']);
});

describe('dev', () => {
let devServer: DevServer;

before(async () => {
devServer = await fixture.startDevServer();
});

after(async () => {
await devServer.stop();
});

it('starts with Vue devtools enabled', async () => {
const response = await fixture.fetch('/');
assert.equal(response.status, 200);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import vue from '@astrojs/vue';
import { defineConfig } from 'astro/config';

export default defineConfig({
integrations: [vue({ jsx: true })],
integrations: [vue({ devtools: true, jsx: true })],
})
Loading