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

only complain about missing lib alias if directory exists #4735

Merged
merged 1 commit into from
Apr 27, 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/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