Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Esbuild --bundle fails to resolve import call in obfuscated_import | GoodFirstPicks

Esbuild --bundle fails to resolve import call in obfuscated_import

sveltejs/svelte 14 comments 1mo ago
View on GitHub
highopenScope: somewhat clearSkill match: maybeSvelteTypeScript

Why this is a good first issue

Dynamic import resolution in esbuild bundling requires deep understanding of both esbuild and runtime environments.

AI Summary

The issue involves esbuild failing to resolve dynamic imports during bundling, particularly affecting Node.js runtime compatibility. It requires understanding esbuild's bundling behavior and potential workarounds for dynamic imports. The solution may involve significant changes to how imports are handled or dropping Node 18 support.

Issue 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 4ms

System 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/n

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 30 points when you complete it!

Risk Flags

  • esbuild behavior
  • runtime compatibility
  • node version constraints
Loading labels...

Details

Points30 pts
Difficultyhigh
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno