Skip to content

Commit

Permalink
only complain about missing lib alias if directory exists - closes #4218
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Apr 27, 2022
1 parent f9c3030 commit 791c90c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-geese-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Only complain about missing \$lib paths in tsconfig if src/lib exists
12 changes: 7 additions & 5 deletions packages/kit/src/core/sync/write_tsconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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[]} */
Expand Down

0 comments on commit 791c90c

Please sign in to comment.