diff --git a/.changeset/thick-spies-hope.md b/.changeset/thick-spies-hope.md new file mode 100644 index 000000000000..17c879350ea0 --- /dev/null +++ b/.changeset/thick-spies-hope.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +fix: use `vite-plugin-svelte` v4 pre-release when Svelte 5 is chosen diff --git a/packages/create-svelte/shared/+svelte5/package.json b/packages/create-svelte/shared/+svelte5/package.json index 5d2d0a1e9157..1fee312f2cca 100644 --- a/packages/create-svelte/shared/+svelte5/package.json +++ b/packages/create-svelte/shared/+svelte5/package.json @@ -1,5 +1,6 @@ { "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^4.0.0-next.6", "svelte": "^5.0.0-next.1" } } diff --git a/packages/create-svelte/test/check.js b/packages/create-svelte/test/check.js index 65b5eeaa1a32..3c30ff6db08f 100644 --- a/packages/create-svelte/test/check.js +++ b/packages/create-svelte/test/check.js @@ -106,36 +106,39 @@ for (const template of templates) { if (template[0] === '.') continue; for (const types of /** @type {const} */ (['checkjs', 'typescript'])) { - const cwd = path.join(test_workspace_dir, `${template}-${types}`); - fs.rmSync(cwd, { recursive: true, force: true }); - - create(cwd, { - name: `create-svelte-test-${template}-${types}`, - template, - types, - prettier: true, - eslint: true, - playwright: false, - vitest: false, - svelte5: false - }); - - const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8')); - patch_package_json(pkg); - - fs.writeFileSync(path.join(cwd, 'package.json'), JSON.stringify(pkg, null, '\t') + '\n'); - - // run provided scripts that are non-blocking. All of them should exit with 0 - // package script requires lib dir - // TODO: lint should run before format - const scripts_to_test = ['format', 'lint', 'check', 'build', 'package'].filter( - (s) => s in pkg.scripts - ); - - for (const script of scripts_to_test) { - const tests = script_test_map.get(script) ?? []; - tests.push([`${template}-${types}`, () => exec_async(`pnpm ${script}`, { cwd })]); - script_test_map.set(script, tests); + for (const svelteVersion of /** @type {const} */ (['svelte4', 'svelte5'])) { + const test_id = `${template}-${types}-${svelteVersion}`; + const cwd = path.join(test_workspace_dir, test_id); + fs.rmSync(cwd, { recursive: true, force: true }); + + create(cwd, { + name: `create-svelte-test-${test_id}`, + template, + types, + prettier: true, + eslint: true, + playwright: false, + vitest: false, + svelte5: svelteVersion === 'svelte5' + }); + + const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8')); + patch_package_json(pkg); + + fs.writeFileSync(path.join(cwd, 'package.json'), JSON.stringify(pkg, null, '\t') + '\n'); + + // run provided scripts that are non-blocking. All of them should exit with 0 + // package script requires lib dir + // TODO: lint should run before format + const scripts_to_test = ['format', 'lint', 'check', 'build', 'package'].filter( + (s) => s in pkg.scripts + ); + + for (const script of scripts_to_test) { + const tests = script_test_map.get(script) ?? []; + tests.push([test_id, () => exec_async(`pnpm ${script}`, { cwd })]); + script_test_map.set(script, tests); + } } } }