diff --git a/.changeset/violet-planets-tell.md b/.changeset/violet-planets-tell.md new file mode 100644 index 000000000000..b3a5fa38f208 --- /dev/null +++ b/.changeset/violet-planets-tell.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: write generated tsconfig to `node_modules/$app/tsconfig.json` so that tools with simplified tsconfig resolution can find it diff --git a/packages/kit/src/cli.js b/packages/kit/src/cli.js index fd7e219d9cc6..4221f33a1fbf 100755 --- a/packages/kit/src/cli.js +++ b/packages/kit/src/cli.js @@ -75,10 +75,10 @@ if (!command) { } if (command === 'sync') { - // create placeholder node_modules/$app/tsconfig/tsconfig.json if necessary, to squelch warnings. + // create placeholder node_modules/$app/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 dir = 'node_modules/$app/tsconfig'; + const dir = 'node_modules/$app'; const base_tsconfig = `${dir}/tsconfig.json`; const base_tsconfig_json = '{}'; diff --git a/packages/kit/src/core/sync/write_tsconfig/index.js b/packages/kit/src/core/sync/write_tsconfig/index.js index d7d944926917..4e327331a2e0 100644 --- a/packages/kit/src/core/sync/write_tsconfig/index.js +++ b/packages/kit/src/core/sync/write_tsconfig/index.js @@ -85,7 +85,8 @@ export function write_tsconfig(kit, root) { * @param {ValidatedKitConfig['typescript']['config']} [transform] TODO get rid of this */ function write_parent_tsconfig(root, dir, id, config, example, transform) { - const out_file = path.join(root, `node_modules/${id}/tsconfig.json`); + // simplified tsconfig resolvers (e.g. Playwright's) only find `${id}.json`, not `${id}/tsconfig.json` + const out_file = path.join(root, `node_modules/${id}.json`); let normalized = normalize_config(out_file, config); normalized = transform?.(normalized) ?? normalized; diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 8931e7f4e105..3d9561362b5f 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -862,7 +862,7 @@ export interface KitConfig { * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one. * This is useful for extending a shared `tsconfig.json` in a monorepo root, for example. * - * Note that any paths configured here should be relative to the generated config file, which is written to `node_modules/$app/tsconfig/tsconfig.json`. + * Note that any paths configured here should be relative to the generated config file, which is written to `node_modules/$app/tsconfig.json`. * * @default (config) => config * @since 1.3.0 diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 96154f98488d..2c29e2a2c516 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -834,7 +834,7 @@ declare module '@sveltejs/kit' { * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one. * This is useful for extending a shared `tsconfig.json` in a monorepo root, for example. * - * Note that any paths configured here should be relative to the generated config file, which is written to `node_modules/$app/tsconfig/tsconfig.json`. + * Note that any paths configured here should be relative to the generated config file, which is written to `node_modules/$app/tsconfig.json`. * * @default (config) => config * @since 1.3.0