From 791c90c6697164384ea64e4b00229fa54c979ac1 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 27 Apr 2022 07:17:11 -0400 Subject: [PATCH] only complain about missing lib alias if directory exists - closes #4218 (#4735) --- .changeset/large-geese-cheat.md | 5 +++++ packages/kit/src/core/sync/write_tsconfig.js | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/large-geese-cheat.md diff --git a/.changeset/large-geese-cheat.md b/.changeset/large-geese-cheat.md new file mode 100644 index 000000000000..5d51c0fdfdf0 --- /dev/null +++ b/.changeset/large-geese-cheat.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Only complain about missing \$lib paths in tsconfig if src/lib exists diff --git a/packages/kit/src/core/sync/write_tsconfig.js b/packages/kit/src/core/sync/write_tsconfig.js index aa3fa7bae918..38655eac2484 100644 --- a/packages/kit/src/core/sync/write_tsconfig.js +++ b/packages/kit/src/core/sync/write_tsconfig.js @@ -40,10 +40,12 @@ export function write_tsconfig(config) { compilerOptions: { // generated options baseUrl: config_relative('.'), - paths: { - $lib: [project_relative(config.kit.files.lib)], - '$lib/*': [project_relative(config.kit.files.lib + '/*')] - }, + paths: fs.existsSync(config.kit.files.lib) + ? { + $lib: [project_relative(config.kit.files.lib)], + '$lib/*': [project_relative(config.kit.files.lib + '/*')] + } + : {}, rootDirs: [config_relative('.'), './types'], // essential options @@ -82,7 +84,7 @@ function validate(config, out, user_file) { if (extends_framework_config) { const { paths: user_paths } = user_tsconfig.compilerOptions || {}; - if (user_paths) { + if (user_paths && fs.existsSync(config.kit.files.lib)) { /** @type {string[]} */ const lib = user_paths['$lib'] || []; /** @type {string[]} */