-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
Describe the bug
This is related to #17762 .
Looking back it should've been obvious... since the static analyzer no longer sees the import() call, esbuild no longer resolves it in --bundle mode (docs), so the resulting source code looks like this:
var obfuscated_import = (module_name) => import(
/* @vite-ignore */
module_name
);There's obviously no error at build time, it just hits you at runtime when running the .cjs file because... well, esbuild is supposed to resolve the import(), but it's not, and a cjs only runtime has no idea what import() is.
I honestly don't know if this is fixable unless node:crypto is dropped, aka node 18 is dropped.
Another alternative would be to use a userland crypto package instead of something from the platform, but I don't know if that's doable or even worth it, this is getting ridiculous.
I'll come up with some patch-work on my end, I'll probably have to straight up remove that code from the bundle and cross my fingers.
I'm just opening this because I thought I should let you guys know about the issue.
Reproduction
Full reproduction can be found here https://github.com/razshare/svelte-reproduction-issue-17771
Logs
make build
npx vite build --logLevel=info --outDir=dist/server --emptyOutDir=true --ssr=app.server.ts
vite v7.3.1 building ssr environment for production...
✓ 114 modules transformed.
dist/server/app.server.js 32.32 kB
✓ built in 249ms
./node_modules/.bin/esbuild --bundle --outfile=dist/server/app.server.cjs --format=cjs --allow-overwrite dist/server/app.server.js
dist/server/app.server.cjs 46.1kb
⚡ Done in 4msSystem Info
System:
OS: Linux 6.12 Debian GNU/Linux 13 (trixie) 13 (trixie)
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Memory: 112.19 GB / 125.69 GB
Container: Yes
Shell: 5.2.37 - /bin/bash
Binaries:
Node: 24.12.0 - /home/raz/.nvm/versions/node/v24.12.0/bin/node
Yarn: 1.22.22 - /home/raz/.nvm/versions/node/v24.12.0/bin/yarn
npm: 11.6.2 - /home/raz/.nvm/versions/node/v24.12.0/bin/npm
pnpm: 10.30.1 - /home/raz/.local/share/pnpm/pnpm
bun: 1.3.9 - /home/raz/.bun/bin/bun
Browsers:
Brave Browser: 144.1.86.139Severity
annoyance