diff --git a/.changeset/early-bulldogs-smile.md b/.changeset/early-bulldogs-smile.md new file mode 100644 index 000000000000..488e1a694b4b --- /dev/null +++ b/.changeset/early-bulldogs-smile.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +Create TypeScript/JSDoc/vanilla versions of shared template .ts files diff --git a/.changeset/healthy-penguins-fail.md b/.changeset/healthy-penguins-fail.md new file mode 100644 index 000000000000..8b8b0792a1c8 --- /dev/null +++ b/.changeset/healthy-penguins-fail.md @@ -0,0 +1,5 @@ +--- +'create-svelte': patch +--- + +Create vite.config.ts when creating TypeScript project diff --git a/packages/adapter-static/package.json b/packages/adapter-static/package.json index 9c0a100dac1d..28fa9863bb0d 100644 --- a/packages/adapter-static/package.json +++ b/packages/adapter-static/package.json @@ -32,6 +32,6 @@ "svelte": "^3.48.0", "typescript": "^4.7.4", "uvu": "^0.5.3", - "vite": "^3.0.8" + "vite": "^3.0.9" } } diff --git a/packages/adapter-static/test/apps/prerendered/package.json b/packages/adapter-static/test/apps/prerendered/package.json index b38399527f6b..ef581f5c6347 100644 --- a/packages/adapter-static/test/apps/prerendered/package.json +++ b/packages/adapter-static/test/apps/prerendered/package.json @@ -10,7 +10,7 @@ "devDependencies": { "@sveltejs/kit": "workspace:*", "svelte": "^3.48.0", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/adapter-static/test/apps/spa/package.json b/packages/adapter-static/test/apps/spa/package.json index a3144238b04d..859b0929f2e5 100644 --- a/packages/adapter-static/test/apps/spa/package.json +++ b/packages/adapter-static/test/apps/spa/package.json @@ -12,7 +12,7 @@ "@sveltejs/kit": "workspace:*", "sirv-cli": "^2.0.2", "svelte": "^3.48.0", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/create-svelte/scripts/build-templates.js b/packages/create-svelte/scripts/build-templates.js index c9d21f9a0e19..d2450f7d2b85 100644 --- a/packages/create-svelte/scripts/build-templates.js +++ b/packages/create-svelte/scripts/build-templates.js @@ -206,22 +206,41 @@ async function generate_shared() { } if (name.endsWith('.ts') && !include.includes('typescript')) { + // file includes types in TypeScript and JSDoc — + // create .js file, with and without JSDoc + const js = convert_typescript(contents); const js_name = name.replace(/\.ts$/, '.js'); - shared.add(js_name); + // typescript files.push({ - name: js_name, - include: [...include], - exclude: [...exclude, 'typescript'], - contents: convert_typescript(contents) + name, + include: [...include, 'typescript'], + exclude, + contents: strip_jsdoc(contents) }); - include.push('typescript'); - } + // checkjs + files.push({ + name: js_name, + include: [...include, 'checkjs'], + exclude, + contents: js + }); - shared.add(name); + // no typechecking + files.push({ + name: js_name, + include, + exclude: [...exclude, 'typescript', 'checkjs'], + contents: strip_jsdoc(js) + }); - files.push({ name, include, exclude, contents }); + shared.add(name); + shared.add(js_name); + } else { + shared.add(name); + files.push({ name, include, exclude, contents }); + } }); files.sort((a, b) => a.include.length + a.exclude.length - (b.include.length + b.exclude.length)); diff --git a/packages/create-svelte/shared/vite.config.ts b/packages/create-svelte/shared/vite.config.ts new file mode 100644 index 000000000000..60ef89c74357 --- /dev/null +++ b/packages/create-svelte/shared/vite.config.ts @@ -0,0 +1,9 @@ +import { sveltekit } from '@sveltejs/kit/vite'; +import type { UserConfig } from 'vite'; + +/** @type {import('vite').UserConfig} */ +const config: UserConfig = { + plugins: [sveltekit()] +}; + +export default config; diff --git a/packages/create-svelte/templates/default/package.json b/packages/create-svelte/templates/default/package.json index ce127a154cdc..5766fd22608c 100644 --- a/packages/create-svelte/templates/default/package.json +++ b/packages/create-svelte/templates/default/package.json @@ -13,7 +13,7 @@ "svelte": "^3.48.0", "svelte-preprocess": "^4.10.6", "typescript": "^4.7.4", - "vite": "^3.0.4" + "vite": "^3.0.9" }, "type": "module", "dependencies": { diff --git a/packages/create-svelte/templates/default/vite.config.js b/packages/create-svelte/templates/default/vite.config.js index 8747050534d8..9f6d10066b6f 100644 --- a/packages/create-svelte/templates/default/vite.config.js +++ b/packages/create-svelte/templates/default/vite.config.js @@ -1,8 +1,15 @@ +import path from 'path'; import { sveltekit } from '@sveltejs/kit/vite'; /** @type {import('vite').UserConfig} */ const config = { - plugins: [sveltekit()] + plugins: [sveltekit()], + + server: { + fs: { + allow: [path.resolve('../../../kit')] + } + } }; export default config; diff --git a/packages/kit/package.json b/packages/kit/package.json index 152e8a89c372..0ea2ff5f5fbb 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -39,7 +39,7 @@ "tiny-glob": "^0.2.9", "typescript": "^4.7.4", "uvu": "^0.5.3", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "peerDependencies": { "svelte": "^3.44.0", diff --git a/packages/kit/src/vite/index.js b/packages/kit/src/vite/index.js index c6ecdb9ef889..fdf17f0740c5 100644 --- a/packages/kit/src/vite/index.js +++ b/packages/kit/src/vite/index.js @@ -58,9 +58,7 @@ const enforced_config = { root: true }; -/** - * @return {import('vite').Plugin[]} - */ +/** @return {import('vite').Plugin[]} */ export function sveltekit() { return [...svelte(), kit()]; } diff --git a/packages/kit/test/apps/amp/package.json b/packages/kit/test/apps/amp/package.json index 1576cdbfc974..0cc8e95fafde 100644 --- a/packages/kit/test/apps/amp/package.json +++ b/packages/kit/test/apps/amp/package.json @@ -19,7 +19,7 @@ "svelte": "^3.48.0", "svelte-check": "^2.7.1", "typescript": "^4.7.4", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/apps/basics/package.json b/packages/kit/test/apps/basics/package.json index a58156c56d74..e295073325f9 100644 --- a/packages/kit/test/apps/basics/package.json +++ b/packages/kit/test/apps/basics/package.json @@ -18,7 +18,7 @@ "svelte": "^3.48.0", "svelte-check": "^2.7.1", "typescript": "^4.7.4", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/apps/dev-only/package.json b/packages/kit/test/apps/dev-only/package.json index e222d532c7d0..cbba7da8dfe8 100644 --- a/packages/kit/test/apps/dev-only/package.json +++ b/packages/kit/test/apps/dev-only/package.json @@ -16,7 +16,7 @@ "svelte": "^3.48.0", "svelte-check": "^2.7.1", "typescript": "^4.7.4", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/apps/options-2/package.json b/packages/kit/test/apps/options-2/package.json index 747b2bef6b81..dd612d2c4839 100644 --- a/packages/kit/test/apps/options-2/package.json +++ b/packages/kit/test/apps/options-2/package.json @@ -18,7 +18,7 @@ "svelte": "^3.48.0", "svelte-check": "^2.7.1", "typescript": "^4.7.4", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/apps/options/package.json b/packages/kit/test/apps/options/package.json index 51e96620d8fa..48734ac77518 100644 --- a/packages/kit/test/apps/options/package.json +++ b/packages/kit/test/apps/options/package.json @@ -17,7 +17,7 @@ "svelte": "^3.48.0", "svelte-check": "^2.7.1", "typescript": "^4.7.4", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/apps/writes/package.json b/packages/kit/test/apps/writes/package.json index 3aeed6b2be9c..3c6cab88a447 100644 --- a/packages/kit/test/apps/writes/package.json +++ b/packages/kit/test/apps/writes/package.json @@ -18,7 +18,7 @@ "svelte": "^3.48.0", "svelte-check": "^2.7.1", "typescript": "^4.7.4", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/prerendering/basics/package.json b/packages/kit/test/prerendering/basics/package.json index 92c4a6bfa24b..2a60f53f9757 100644 --- a/packages/kit/test/prerendering/basics/package.json +++ b/packages/kit/test/prerendering/basics/package.json @@ -15,7 +15,7 @@ "svelte-check": "^2.7.1", "typescript": "^4.7.4", "uvu": "^0.5.3", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/prerendering/fallback/package.json b/packages/kit/test/prerendering/fallback/package.json index 8b6a092827bd..9835390fe550 100644 --- a/packages/kit/test/prerendering/fallback/package.json +++ b/packages/kit/test/prerendering/fallback/package.json @@ -15,7 +15,7 @@ "svelte-check": "^2.7.1", "typescript": "^4.7.4", "uvu": "^0.5.3", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/prerendering/options/package.json b/packages/kit/test/prerendering/options/package.json index 1fba5f3024d0..7c75411c6d2e 100644 --- a/packages/kit/test/prerendering/options/package.json +++ b/packages/kit/test/prerendering/options/package.json @@ -15,7 +15,7 @@ "svelte-check": "^2.7.1", "typescript": "^4.7.4", "uvu": "^0.5.3", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/prerendering/paths-base/package.json b/packages/kit/test/prerendering/paths-base/package.json index 1f743ca22906..10eb75923b67 100644 --- a/packages/kit/test/prerendering/paths-base/package.json +++ b/packages/kit/test/prerendering/paths-base/package.json @@ -15,7 +15,7 @@ "svelte-check": "^2.7.1", "typescript": "^4.7.4", "uvu": "^0.5.3", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/packages/kit/test/prerendering/trailing-slash/package.json b/packages/kit/test/prerendering/trailing-slash/package.json index a2c58958642a..d149c42bf1c9 100644 --- a/packages/kit/test/prerendering/trailing-slash/package.json +++ b/packages/kit/test/prerendering/trailing-slash/package.json @@ -15,7 +15,7 @@ "svelte-check": "^2.7.1", "typescript": "^4.7.4", "uvu": "^0.5.4", - "vite": "^3.0.8" + "vite": "^3.0.9" }, "type": "module" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a621b9837bfa..0967ad4444da 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -149,7 +149,7 @@ importers: svelte: ^3.48.0 typescript: ^4.7.4 uvu: ^0.5.3 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../kit '@types/node': 16.11.42 @@ -158,17 +158,17 @@ importers: svelte: 3.48.0 typescript: 4.7.4 uvu: 0.5.4 - vite: 3.0.8 + vite: 3.0.9 packages/adapter-static/test/apps/prerendered: specifiers: '@sveltejs/kit': workspace:* svelte: ^3.48.0 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../../../kit svelte: 3.48.0 - vite: 3.0.8 + vite: 3.0.9 packages/adapter-static/test/apps/spa: specifiers: @@ -176,13 +176,13 @@ importers: '@sveltejs/kit': workspace:* sirv-cli: ^2.0.2 svelte: ^3.48.0 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/adapter-node': link:../../../../adapter-node '@sveltejs/kit': link:../../../../kit sirv-cli: 2.0.2 svelte: 3.48.0 - vite: 3.0.8 + vite: 3.0.9 packages/adapter-vercel: specifiers: @@ -247,7 +247,7 @@ importers: svelte: ^3.48.0 svelte-preprocess: ^4.10.6 typescript: ^4.7.4 - vite: ^3.0.4 + vite: ^3.0.9 dependencies: '@fontsource/fira-mono': 4.5.8 '@lukeed/uuid': 2.0.0 @@ -258,7 +258,7 @@ importers: svelte: 3.48.0 svelte-preprocess: 4.10.7_lvfi2wesz6u4l5rfbnetbucfmm typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 packages/create-svelte/templates/skeleton: specifiers: @@ -294,9 +294,9 @@ importers: typescript: ^4.7.4 undici: ^5.8.1 uvu: ^0.5.3 - vite: ^3.0.8 + vite: ^3.0.9 dependencies: - '@sveltejs/vite-plugin-svelte': 1.0.1_svelte@3.48.0+vite@3.0.8 + '@sveltejs/vite-plugin-svelte': 1.0.1_svelte@3.48.0+vite@3.0.9 cookie: 0.5.0 devalue: 2.0.1 kleur: 4.1.5 @@ -323,7 +323,7 @@ importers: svelte-preprocess: 4.10.7_lvfi2wesz6u4l5rfbnetbucfmm typescript: 4.7.4 uvu: 0.5.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/apps/amp: specifiers: @@ -334,7 +334,7 @@ importers: svelte: ^3.48.0 svelte-check: ^2.7.1 typescript: ^4.7.4 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/amp': link:../../../../amp '@sveltejs/kit': link:../../.. @@ -343,7 +343,7 @@ importers: svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/apps/basics: specifiers: @@ -353,7 +353,7 @@ importers: svelte: ^3.48.0 svelte-check: ^2.7.1 typescript: ^4.7.4 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. cross-env: 7.0.3 @@ -361,7 +361,7 @@ importers: svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/apps/dev-only: specifiers: @@ -371,7 +371,7 @@ importers: svelte: ^3.48.0 svelte-check: ^2.7.1 typescript: ^4.7.4 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. cross-env: 7.0.3 @@ -379,7 +379,7 @@ importers: svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/apps/options: specifiers: @@ -388,14 +388,14 @@ importers: svelte: ^3.48.0 svelte-check: ^2.7.1 typescript: ^4.7.4 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. cross-env: 7.0.3 svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/apps/options-2: specifiers: @@ -405,7 +405,7 @@ importers: svelte: ^3.48.0 svelte-check: ^2.7.1 typescript: ^4.7.4 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/adapter-node': link:../../../../adapter-node '@sveltejs/kit': link:../../.. @@ -413,7 +413,7 @@ importers: svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/apps/writes: specifiers: @@ -423,7 +423,7 @@ importers: svelte: ^3.48.0 svelte-check: ^2.7.1 typescript: ^4.7.4 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. cross-env: 7.0.3 @@ -431,7 +431,7 @@ importers: svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/prerendering/basics: specifiers: @@ -440,14 +440,14 @@ importers: svelte-check: ^2.7.1 typescript: ^4.7.4 uvu: ^0.5.3 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 uvu: 0.5.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/prerendering/fallback: specifiers: @@ -456,14 +456,14 @@ importers: svelte-check: ^2.7.1 typescript: ^4.7.4 uvu: ^0.5.3 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 uvu: 0.5.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/prerendering/options: specifiers: @@ -472,14 +472,14 @@ importers: svelte-check: ^2.7.1 typescript: ^4.7.4 uvu: ^0.5.3 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 uvu: 0.5.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/prerendering/paths-base: specifiers: @@ -488,14 +488,14 @@ importers: svelte-check: ^2.7.1 typescript: ^4.7.4 uvu: ^0.5.3 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 uvu: 0.5.4 - vite: 3.0.8 + vite: 3.0.9 packages/kit/test/prerendering/trailing-slash: specifiers: @@ -504,14 +504,14 @@ importers: svelte-check: ^2.7.1 typescript: ^4.7.4 uvu: ^0.5.4 - vite: ^3.0.8 + vite: ^3.0.9 devDependencies: '@sveltejs/kit': link:../../.. svelte: 3.48.0 svelte-check: 2.8.0_svelte@3.48.0 typescript: 4.7.4 uvu: 0.5.4 - vite: 3.0.8 + vite: 3.0.9 packages/migrate: specifiers: @@ -572,7 +572,7 @@ importers: shiki-twoslash: ^3.0.2 svelte: ^3.48.0 typescript: ^4.7.4 - vite: ^3.0.8 + vite: ^3.0.9 vite-imagetools: ^4.0.3 devDependencies: '@sveltejs/adapter-auto': link:../../packages/adapter-auto @@ -588,7 +588,7 @@ importers: shiki-twoslash: 3.1.0 svelte: 3.48.0 typescript: 4.7.4 - vite: 3.0.8 + vite: 3.0.9 vite-imagetools: 4.0.4 packages: @@ -1019,7 +1019,7 @@ packages: golden-fleece: 1.0.9 dev: true - /@sveltejs/vite-plugin-svelte/1.0.1_svelte@3.48.0+vite@3.0.8: + /@sveltejs/vite-plugin-svelte/1.0.1_svelte@3.48.0+vite@3.0.9: resolution: {integrity: sha512-PorCgUounn0VXcpeJu+hOweZODKmGuLHsLomwqSj+p26IwjjGffmYQfVHtiTWq+NqaUuuHWWG7vPge6UFw4Aeg==} engines: {node: ^14.18.0 || >= 16} peerDependencies: @@ -1037,7 +1037,7 @@ packages: magic-string: 0.26.2 svelte: 3.48.0 svelte-hmr: 0.14.12_svelte@3.48.0 - vite: 3.0.8 + vite: 3.0.9 transitivePeerDependencies: - supports-color dev: false @@ -4495,8 +4495,8 @@ packages: magic-string: 0.26.2 dev: true - /vite/3.0.8: - resolution: {integrity: sha512-AOZ4eN7mrkJiOLuw8IA7piS4IdOQyQCA81GxGsAQvAZzMRi9ZwGB3TOaYsj4uLAWK46T5L4AfQ6InNGlxX30IQ==} + /vite/3.0.9: + resolution: {integrity: sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true peerDependencies: diff --git a/sites/kit.svelte.dev/package.json b/sites/kit.svelte.dev/package.json index eeeb76b29d88..1a2cd1c4ab20 100644 --- a/sites/kit.svelte.dev/package.json +++ b/sites/kit.svelte.dev/package.json @@ -21,7 +21,7 @@ "shiki-twoslash": "^3.0.2", "svelte": "^3.48.0", "typescript": "^4.7.4", - "vite": "^3.0.8", + "vite": "^3.0.9", "vite-imagetools": "^4.0.3" }, "type": "module"