Skip to content
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/old-mails-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: generate a placeholder tsconfig.json to squelch sync-time warnings
30 changes: 30 additions & 0 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,42 @@ if (!command) {
}

if (command === 'sync') {
// create placeholder .svelte-kit/tsconfig.json if necessary, to squelch warnings.
// this isn't bulletproof — if someone has some esoteric config, it will continue
// to harmlessly warn — but we handle the 90% case and clean up after ourselves
const sveltekit_dir = '.svelte-kit';
const base_tsconfig = `${sveltekit_dir}/tsconfig.json`;
const base_tsconfig_json = '{}';

const sveltekit_dir_exists = fs.existsSync(sveltekit_dir);
const base_tsconfig_exists = fs.existsSync(base_tsconfig);

if (!base_tsconfig_exists) {
try {
fs.mkdirSync('.svelte-kit');
} catch {
// ignore
}

fs.writeFileSync(base_tsconfig, base_tsconfig_json);
}

try {
const config = await load_config();
const sync = await import('./core/sync/sync.js');
sync.all_types(config, values.mode);
} catch (error) {
handle_error(error);
} finally {
// if we errored, or accidentally created the wrong file
// (could happen!) then clean up after ourselves
if (fs.readFileSync(base_tsconfig, 'utf-8') === base_tsconfig_json) {
Comment thread
vercel[bot] marked this conversation as resolved.
fs.unlinkSync(base_tsconfig);
}

if (!sveltekit_dir_exists && fs.readdirSync(sveltekit_dir).length === 0) {
fs.rmSync(sveltekit_dir, { recursive: true });
}
}
} else {
console.error(colors.bold().red(`> Unknown command: ${command}`));
Expand Down
Loading