kit: config.kit.alias sets wrong compilerOptions.paths
Describe the bug
In our svelte.config.js
we have defined this options for config.kit.alias
:
alias: {
$locales: "node_modules/svelte-intl-precompile/index.d.ts",
"$locales/*": "src/locales/*"
}
Now SvelteKit creates these nodes in the tsconfig.json
file:
"$locales": [
"node_modules/svelte-intl-precompile/index.d.ts"
],
"$locales/*": [
"node_modules/svelte-intl-precompile/index.d.ts/*"
]
The problem is the entry for $locales/*
. I think this entry is auto-generated, but SvelteKit should use the value that I provided in svelte.config.js
instead of the auto-generated path.
Reproduction
Just insert the config.kit.alias entries from above in your svelte.config.js
and run svelte-kit sync
.
Logs
No response
System Info
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
Memory: 10.86 GB / 31.79 GB
Binaries:
Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 101.0.4951.67
Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.53)
Internet Explorer: 11.0.19041.1566
npmPackages:
@sveltejs/adapter-node: 1.0.0-next.73 => 1.0.0-next.73
@sveltejs/kit: 1.0.0-next.345 => 1.0.0-next.345
svelte: 3.48.0 => 3.48.0
Severity
annoyance
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 25 (4 by maintainers)
I came to the same conclusion.
I wish I could tell you how I solved it but I can’t. I just ( wrongly ) assumed since it was throwing in build referencing
prerender.paths
( which didn’t make sense because we use a static adapter, but I don’t know the internals well enough to be sure ) so I assumed it was a config problem, I went around in circles for a while on that.It took me a long time to guess which file it was, there were maybe 5 that were new enough to cause it, but because it didn’t point out any specific file as the problem I had to go one by one.
The error disappeared when I removed an import from the layout file. Then I had to copy the contents to a new file, with a new name, and then the error stopped. Wierd.
In my case, the only thing I could figure out was that maybe a vs-code plugin added a non-visible char that was messing things up, but a diff showed nothing between the new and old file.
I solved the error just removing the dynamic import with
await
inside theonMount()
method. This has nothing to do apparently with TS or the configuration. @vekunzGetting the same error with the last version when I try to build:
I just upgraded svelte/kit and it now requires vite.config.js, which apparently also broke the all of our aliases
alias: { $stores: './src/stores', $components: './src/components', $views: './src/views', $api: './src/endpointAPI' }
These all worked fine until now. The error I get during build is
[vite-plugin-svelte-kit] Cannot read properties of undefined (reading 'paths') error during build: TypeError: Cannot read properties of undefined (reading 'paths') at create_builder (file:///E:/Dev/my-app/node_modules/@sveltejs/kit/dist/chunks/index2.js:52:48)
Seems related
I’m getting “Unexpected option config.kit.alias” (Svelte 3.48.0) - is this still supported?