monorepo: [bug] sveltekit vercel adapter does not bundle paraglide, leading to unresolvable imports
Problem
The SvelteKit Vercel adapter does not bundle paraglide imports.
- The imports in the compiled output reference the node modules which don’t exist in the vercel edge runtime. Every other import is referencing build output (“…/chunk.js”)
- The directory structure of the build output does not include
node_moduleswhich likely leads to this problem. The paraglide import can’t be resolved.
Expected behavior
The bundler processes the paraglide imports instead of leaving them as is.
-import { availableLanguageTags, languageTag, setLanguageTag } from "@inlang/paraglide-js/website";
-import * as m from "@inlang/paraglide-js/website/messages";
+import { a, b, c, messageas } from "../chunk-2ss.js";
Reproduction
TODO
Other information
I suspect the package.exports might play a role here. SvelteKit doesn’t use the TypeScript compiler option moduleResolution: Node16 or Bundler yet by default. It might be that the Vercel adapter ignores export maps altogether. A reproduction could be a mock package with exports fields and see how the Vercel adapter behaves.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 16 (13 by maintainers)
🎉🎈 @rishi-raj-jain has been awarded $200! 🎈🎊
TLDR
The main change is
Explanation in detail
As the compiled-output folder is already transpiled, using noExternal with vite becomes necessary to be used so that is not left out while bundling.
More specifically, the issue was due to exclusion of the file
messages.jsin the node_modules of the vercel output while treeshaking, whileruntime.jswas included because as being the default export from the package.