Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typechecking variants #6253

Merged
merged 6 commits into from
Aug 25, 2022
Merged
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/early-bulldogs-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Create TypeScript/JSDoc/vanilla versions of shared template .ts files
5 changes: 5 additions & 0 deletions .changeset/healthy-penguins-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

Create vite.config.ts when creating TypeScript project
2 changes: 1 addition & 1 deletion packages/adapter-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"svelte": "^3.48.0",
"typescript": "^4.7.4",
"uvu": "^0.5.3",
"vite": "^3.0.8"
"vite": "^3.0.9"
}
}
2 changes: 1 addition & 1 deletion packages/adapter-static/test/apps/prerendered/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"devDependencies": {
"@sveltejs/kit": "workspace:*",
"svelte": "^3.48.0",
"vite": "^3.0.8"
"vite": "^3.0.9"
},
"type": "module"
}
2 changes: 1 addition & 1 deletion packages/adapter-static/test/apps/spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
37 changes: 28 additions & 9 deletions packages/create-svelte/scripts/build-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
9 changes: 9 additions & 0 deletions packages/create-svelte/shared/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion packages/create-svelte/templates/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
9 changes: 8 additions & 1 deletion packages/create-svelte/templates/default/vite.config.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions packages/kit/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ const enforced_config = {
root: true
};

/**
* @return {import('vite').Plugin[]}
*/
/** @return {import('vite').Plugin[]} */
export function sveltekit() {
return [...svelte(), kit()];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/amp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/apps/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/apps/dev-only/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/apps/options-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/apps/options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/apps/writes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/fallback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/paths-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/trailing-slash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Loading