diff --git a/.changeset/witty-pandas-whisper.md b/.changeset/witty-pandas-whisper.md new file mode 100644 index 000000000..f5450e5d1 --- /dev/null +++ b/.changeset/witty-pandas-whisper.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/vite-plugin-svelte': patch +--- + +improve detection of sveltekit in inspector plugin to be compatible to latest changes diff --git a/packages/e2e-tests/inspector-kit/package.json b/packages/e2e-tests/inspector-kit/package.json index 89b2e6b16..3ef4afdd3 100644 --- a/packages/e2e-tests/inspector-kit/package.json +++ b/packages/e2e-tests/inspector-kit/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "devDependencies": { - "@sveltejs/kit": "^1.0.0-next.572", + "@sveltejs/kit": "^1.0.0-next.582", "svelte": "^3.54.0", "vite": "^4.0.0" }, diff --git a/packages/e2e-tests/inspector-kit/src/app.html b/packages/e2e-tests/inspector-kit/src/app.html index 568b69b88..062500177 100644 --- a/packages/e2e-tests/inspector-kit/src/app.html +++ b/packages/e2e-tests/inspector-kit/src/app.html @@ -3,6 +3,7 @@
+ %sveltekit.head% diff --git a/packages/e2e-tests/inspector-kit/static/favicon.png b/packages/e2e-tests/inspector-kit/static/favicon.png new file mode 100644 index 000000000..825b9e65a Binary files /dev/null and b/packages/e2e-tests/inspector-kit/static/favicon.png differ diff --git a/packages/e2e-tests/kit-node/__tests__/kit.spec.ts b/packages/e2e-tests/kit-node/__tests__/kit.spec.ts index ff63e0571..554ae7398 100644 --- a/packages/e2e-tests/kit-node/__tests__/kit.spec.ts +++ b/packages/e2e-tests/kit-node/__tests__/kit.spec.ts @@ -243,17 +243,6 @@ describe('kit-node', () => { expect(await getText('button')).toBe('Clicks: 0'); }); }); - describe('config file update', () => { - it('should auto refresh', async () => { - const button = await getEl('button'); - await button.click(); - expect(await getText('button')).toBe('Clicks: 1'); - editFile('svelte.config.js', (config) => config + '\n'); - await waitForNavigation({ waitUntil: 'networkidle' }); - // clicks should reset, means the browser refreshed - expect(await getText('button')).toBe('Clicks: 0'); - }); - }); }); } }); diff --git a/packages/e2e-tests/kit-node/package.json b/packages/e2e-tests/kit-node/package.json index 3366f74b5..8069e49a2 100644 --- a/packages/e2e-tests/kit-node/package.json +++ b/packages/e2e-tests/kit-node/package.json @@ -11,8 +11,8 @@ "check:watch": "svelte-check --tsconfig ./jsconfig.json --watch" }, "devDependencies": { - "@sveltejs/adapter-node": "^1.0.0-next.102", - "@sveltejs/kit": "^1.0.0-next.572", + "@sveltejs/adapter-node": "^1.0.0-next.104", + "@sveltejs/kit": "^1.0.0-next.582", "e2e-test-dep-svelte-api-only": "file:../_test_dependencies/svelte-api-only", "e2e-test-dep-vite-plugins": "file:../_test_dependencies/vite-plugins", "svelte": "^3.54.0", diff --git a/packages/playground/big-component-library-kit/package.json b/packages/playground/big-component-library-kit/package.json index 6c84f5859..d8daf9644 100644 --- a/packages/playground/big-component-library-kit/package.json +++ b/packages/playground/big-component-library-kit/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "@sveltejs/adapter-auto": "1.0.0-next.90", - "@sveltejs/kit": "^1.0.0-next.572", + "@sveltejs/kit": "^1.0.0-next.582", "carbon-components-svelte": "^0.70.12", "carbon-icons-svelte": "^11.4.0", "carbon-preprocess-svelte": "^0.9.1", diff --git a/packages/playground/kit-demo-app/package.json b/packages/playground/kit-demo-app/package.json index 86d956a8a..b2f55bcf7 100644 --- a/packages/playground/kit-demo-app/package.json +++ b/packages/playground/kit-demo-app/package.json @@ -13,7 +13,7 @@ "@fontsource/fira-mono": "^4.5.10", "@neoconfetti/svelte": "^1.0.0", "@sveltejs/adapter-auto": "^1.0.0-next.90", - "@sveltejs/kit": "^1.0.0-next.572", + "@sveltejs/kit": "^1.0.0-next.582", "@types/cookie": "^0.5.1", "svelte": "^3.54.0", "svelte-check": "^2.10.1", diff --git a/packages/vite-plugin-svelte/src/ui/inspector/plugin.ts b/packages/vite-plugin-svelte/src/ui/inspector/plugin.ts index ddda7c9d2..5adaffb3f 100644 --- a/packages/vite-plugin-svelte/src/ui/inspector/plugin.ts +++ b/packages/vite-plugin-svelte/src/ui/inspector/plugin.ts @@ -35,22 +35,23 @@ export function svelteInspector(): Plugin { configResolved(config) { const vps = config.plugins.find((p) => p.name === 'vite-plugin-svelte'); - if (vps?.api?.options?.experimental?.inspector) { - inspectorOptions = { - ...defaultInspectorOptions, - ...vps.api.options.experimental.inspector - }; - } - if (!vps || !inspectorOptions) { + const options = vps?.api?.options?.experimental?.inspector; + if (!vps || !options) { log.debug('inspector disabled, could not find config'); disabled = true; - } else { - if (vps.api.options.kit && !inspectorOptions.appendTo) { - const out_dir = path.basename(vps.api.options.kit.outDir || '.svelte-kit'); - inspectorOptions.appendTo = `${out_dir}/generated/root.svelte`; - } - appendTo = inspectorOptions.appendTo; + return; + } + inspectorOptions = { + ...defaultInspectorOptions, + ...options + }; + const isSvelteKit = config.plugins.some((p) => p.name.startsWith('vite-plugin-sveltekit')); + if (isSvelteKit && !inspectorOptions.appendTo) { + // this could append twice if a user had a file that ends with /generated/root.svelte + // but that should be rare and inspector doesn't execute twice + inspectorOptions.appendTo = `/generated/root.svelte`; } + appendTo = inspectorOptions.appendTo; }, async resolveId(importee: string, importer, options) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b0e86d2a..19a58ea62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -261,11 +261,11 @@ importers: packages/e2e-tests/inspector-kit: specifiers: - '@sveltejs/kit': ^1.0.0-next.572 + '@sveltejs/kit': ^1.0.0-next.582 svelte: ^3.54.0 vite: ^4.0.0 devDependencies: - '@sveltejs/kit': 1.0.0-next.572_svelte@3.54.0+vite@4.0.0 + '@sveltejs/kit': 1.0.0-next.582_svelte@3.54.0+vite@4.0.0 svelte: 3.54.0 vite: 4.0.0 @@ -281,8 +281,8 @@ importers: packages/e2e-tests/kit-node: specifiers: - '@sveltejs/adapter-node': ^1.0.0-next.102 - '@sveltejs/kit': ^1.0.0-next.572 + '@sveltejs/adapter-node': ^1.0.0-next.104 + '@sveltejs/kit': ^1.0.0-next.582 e2e-test-dep-svelte-api-only: file:../_test_dependencies/svelte-api-only e2e-test-dep-vite-plugins: file:../_test_dependencies/vite-plugins svelte: ^3.54.0 @@ -292,8 +292,8 @@ importers: typescript: ^4.9.3 vite: ^4.0.0 devDependencies: - '@sveltejs/adapter-node': 1.0.0-next.102 - '@sveltejs/kit': 1.0.0-next.572_svelte@3.54.0+vite@4.0.0 + '@sveltejs/adapter-node': 1.0.0-next.104 + '@sveltejs/kit': 1.0.0-next.582_svelte@3.54.0+vite@4.0.0 e2e-test-dep-svelte-api-only: file:packages/e2e-tests/_test_dependencies/svelte-api-only e2e-test-dep-vite-plugins: file:packages/e2e-tests/_test_dependencies/vite-plugins svelte: 3.54.0 @@ -483,7 +483,7 @@ importers: packages/playground/big-component-library-kit: specifiers: '@sveltejs/adapter-auto': 1.0.0-next.90 - '@sveltejs/kit': ^1.0.0-next.572 + '@sveltejs/kit': ^1.0.0-next.582 carbon-components-svelte: ^0.70.12 carbon-icons-svelte: ^11.4.0 carbon-preprocess-svelte: ^0.9.1 @@ -495,7 +495,7 @@ importers: vite: ^4.0.0 devDependencies: '@sveltejs/adapter-auto': 1.0.0-next.90 - '@sveltejs/kit': 1.0.0-next.572_svelte@3.54.0+vite@4.0.0 + '@sveltejs/kit': 1.0.0-next.582_svelte@3.54.0+vite@4.0.0 carbon-components-svelte: 0.70.12 carbon-icons-svelte: 11.4.0 carbon-preprocess-svelte: 0.9.1_svelte@3.54.0 @@ -540,7 +540,7 @@ importers: '@fontsource/fira-mono': ^4.5.10 '@neoconfetti/svelte': ^1.0.0 '@sveltejs/adapter-auto': ^1.0.0-next.90 - '@sveltejs/kit': ^1.0.0-next.572 + '@sveltejs/kit': ^1.0.0-next.582 '@types/cookie': ^0.5.1 svelte: ^3.54.0 svelte-check: ^2.10.1 @@ -550,7 +550,7 @@ importers: '@fontsource/fira-mono': 4.5.10 '@neoconfetti/svelte': 1.0.0 '@sveltejs/adapter-auto': 1.0.0-next.90 - '@sveltejs/kit': 1.0.0-next.572_svelte@3.54.0+vite@4.0.0 + '@sveltejs/kit': 1.0.0-next.582_svelte@3.54.0+vite@4.0.0 '@types/cookie': 0.5.1 svelte: 3.54.0 svelte-check: 2.10.1_svelte@3.54.0 @@ -1177,8 +1177,8 @@ packages: /@polka/url/1.0.0-next.21: resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} - /@rollup/plugin-commonjs/23.0.2_rollup@2.79.1: - resolution: {integrity: sha512-e9ThuiRf93YlVxc4qNIurvv+Hp9dnD+4PjOqQs5vAYfcZ3+AXSrcdzXnVjWxcGQOa6KGJFcRZyUI3ktWLavFjg==} + /@rollup/plugin-commonjs/23.0.4_rollup@3.7.3: + resolution: {integrity: sha512-bOPJeTZg56D2MCm+TT4psP8e8Jmf1Jsi7pFUMl8BN5kOADNzofNHe47+84WVCt7D095xPghC235/YKuNDEhczg==} engines: {node: '>=14.0.0'} peerDependencies: rollup: ^2.68.0||^3.0.0 @@ -1186,17 +1186,17 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.2_rollup@2.79.1 + '@rollup/pluginutils': 5.0.2_rollup@3.7.3 commondir: 1.0.1 estree-walker: 2.0.2 glob: 8.0.3 is-reference: 1.2.1 magic-string: 0.26.7 - rollup: 2.79.1 + rollup: 3.7.3 dev: true - /@rollup/plugin-json/5.0.1_rollup@2.79.1: - resolution: {integrity: sha512-QCwhZZLvM8nRcTHyR1vOgyTMiAnjiNj1ebD/BMRvbO1oc/z14lZH6PfxXeegee2B6mky/u9fia4fxRM4TqrUaw==} + /@rollup/plugin-json/5.0.2_rollup@3.7.3: + resolution: {integrity: sha512-D1CoOT2wPvadWLhVcmpkDnesTzjhNIQRWLsc3fA49IFOP2Y84cFOOJ+nKGYedvXHKUsPeq07HR4hXpBBr+CHlA==} engines: {node: '>=14.0.0'} peerDependencies: rollup: ^1.20.0||^2.0.0||^3.0.0 @@ -1204,11 +1204,11 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.2_rollup@2.79.1 - rollup: 2.79.1 + '@rollup/pluginutils': 5.0.2_rollup@3.7.3 + rollup: 3.7.3 dev: true - /@rollup/plugin-node-resolve/15.0.1_rollup@2.79.1: + /@rollup/plugin-node-resolve/15.0.1_rollup@3.7.3: resolution: {integrity: sha512-ReY88T7JhJjeRVbfCyNj+NXAG3IIsVMsX9b5/9jC98dRP8/yxlZdz7mHZbHk5zHr24wZZICS5AcXsFZAXYUQEg==} engines: {node: '>=14.0.0'} peerDependencies: @@ -1217,16 +1217,16 @@ packages: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.2_rollup@2.79.1 + '@rollup/pluginutils': 5.0.2_rollup@3.7.3 '@types/resolve': 1.20.2 deepmerge: 4.2.2 is-builtin-module: 3.2.0 is-module: 1.0.0 resolve: 1.22.1 - rollup: 2.79.1 + rollup: 3.7.3 dev: true - /@rollup/pluginutils/5.0.2_rollup@2.79.1: + /@rollup/pluginutils/5.0.2_rollup@3.7.3: resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} engines: {node: '>=14.0.0'} peerDependencies: @@ -1238,7 +1238,7 @@ packages: '@types/estree': 1.0.0 estree-walker: 2.0.2 picomatch: 2.3.1 - rollup: 2.79.1 + rollup: 3.7.3 dev: true /@sveltejs/adapter-auto/1.0.0-next.90: @@ -1247,28 +1247,29 @@ packages: import-meta-resolve: 2.2.0 dev: true - /@sveltejs/adapter-node/1.0.0-next.102: - resolution: {integrity: sha512-8HKFGXXxYQx4diAJ4eSceuQXoqOpSZCPQp9JkATKLK2ItEqjXk0FqiktGdoMNp2Xlgd1n4jF2sF3NECz8dblzg==} + /@sveltejs/adapter-node/1.0.0-next.104: + resolution: {integrity: sha512-CZVSDTH1fnpBEztvNqoye9xC5w2E+q4S1X5LjZv1tqszM/A9VuwWY358k4/tQ6OFYz011R5mbZ4QyjTB+GB2AA==} dependencies: - '@rollup/plugin-commonjs': 23.0.2_rollup@2.79.1 - '@rollup/plugin-json': 5.0.1_rollup@2.79.1 - '@rollup/plugin-node-resolve': 15.0.1_rollup@2.79.1 - rollup: 2.79.1 + '@rollup/plugin-commonjs': 23.0.4_rollup@3.7.3 + '@rollup/plugin-json': 5.0.2_rollup@3.7.3 + '@rollup/plugin-node-resolve': 15.0.1_rollup@3.7.3 + rollup: 3.7.3 dev: true - /@sveltejs/kit/1.0.0-next.572_svelte@3.54.0+vite@4.0.0: - resolution: {integrity: sha512-PiKEr55L/uJyMKvDPdyoa5MlAYQwdgs8HLMbr28YcCBmhw/v6V7gutKOKdqeXc3YwKEFVS3z7TvW6c7eDokJdQ==} + /@sveltejs/kit/1.0.0-next.582_svelte@3.54.0+vite@4.0.0: + resolution: {integrity: sha512-Mt/1QcIHiHxrBLH4iV+pgVXDWOvQKX9iDEUwswRfkt6x72HR1FDeVRKFXS5PBFPGRFLejifGJRN383co7xzumA==} engines: {node: '>=16.14'} hasBin: true requiresBuild: true peerDependencies: - svelte: ^3.44.0 - vite: ^3.2.0 || ^4.0.0 + svelte: ^3.54.0 + vite: ^4.0.0 dependencies: '@sveltejs/vite-plugin-svelte': link:packages/vite-plugin-svelte '@types/cookie': 0.5.1 cookie: 0.5.0 devalue: 4.2.0 + esm-env: 1.0.0 kleur: 4.1.5 magic-string: 0.27.0 mime: 3.0.0 @@ -1277,7 +1278,7 @@ packages: sirv: 2.0.2 svelte: 3.54.0 tiny-glob: 0.2.9 - undici: 5.13.0 + undici: 5.14.0 vite: 4.0.0 dev: true @@ -2865,6 +2866,10 @@ packages: - supports-color dev: true + /esm-env/1.0.0: + resolution: {integrity: sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==} + dev: true + /espree/9.4.0: resolution: {integrity: sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -3265,7 +3270,7 @@ packages: fs.realpath: 1.0.0 inflight: 1.0.6 inherits: 2.0.4 - minimatch: 5.1.0 + minimatch: 5.1.1 once: 1.4.0 dev: true @@ -4050,8 +4055,8 @@ packages: brace-expansion: 1.1.11 dev: true - /minimatch/5.1.0: - resolution: {integrity: sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==} + /minimatch/5.1.1: + resolution: {integrity: sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g==} engines: {node: '>=10'} dependencies: brace-expansion: 2.0.1 @@ -4779,6 +4784,14 @@ packages: optionalDependencies: fsevents: 2.3.2 + /rollup/3.7.3: + resolution: {integrity: sha512-7e68MQbAWCX6mI4/0lG1WHd+NdNAlVamg0Zkd+8LZ/oXojligdGnCNyHlzXqXCZObyjs5FRc3AH0b17iJESGIQ==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: true + /run-parallel/1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: @@ -5754,8 +5767,8 @@ packages: which-boxed-primitive: 1.0.2 dev: true - /undici/5.13.0: - resolution: {integrity: sha512-UDZKtwb2k7KRsK4SdXWG7ErXiL7yTGgLWvk2AXO1JMjgjh404nFo6tWSCM2xMpJwMPx3J8i/vfqEh1zOqvj82Q==} + /undici/5.14.0: + resolution: {integrity: sha512-yJlHYw6yXPPsuOH0x2Ib1Km61vu4hLiRRQoafs+WUgX1vO64vgnxiCEN9dpIrhZyHFsai3F0AEj4P9zy19enEQ==} engines: {node: '>=12.18'} dependencies: busboy: 1.6.0