You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(compile): #5918 — import_function_prefixes collides on exported name across unrelated imports (#5919)
import_function_prefixes (imported name -> source module prefix,
consumed by ExternFuncRef codegen to form perry_fn_<prefix>__<name>)
was populated by inserting BOTH the exported/origin name and the local
alias for every renamed Named import. Per the #35/#321 precedent in
the same function, a renamed import's ExternFuncRef in the HIR always
carries the LOCAL name (unique per import site) -- the exported_name
insert only ever mattered in the no-rename case (local == exported).
Running it unconditionally meant: when two DIFFERENT import statements
in the same file rename to different locals from modules whose ORIGIN
export names happen to collide (common with short, minifier-style
names -- "a"/"b"/"c" -- which is exactly what esbuild's chunk-splitting
produces), the second insert silently overwrote the first's entry.
The overwritten entry could be a completely unrelated LOCAL alias from
an earlier import, repointing that alias's ExternFuncRef at the wrong
module entirely.
Confirmed via a real-world source compile of sst/opencode
(compilePackages: ["*"]): remeda's real dist/chunk-*.js build output
has this exact shape, and nearly every remeda function transitively
imports the four affected chunks, so this single bug blocked the
entire package.
Fix: only insert under exported_name in the local_name == exported_name
case; the aliased case inserts under local_name only, keeping every
key in the map unique per file (local identifiers can't collide with
each other within one file; export names from different origin
modules can and do).
Added a 4-file regression test reproducing the exact collision shape,
lifted from remeda's real build output. Verified test_gap_renamed_
class_export_namespace.ts, test_issue_836_zod_class_reexports.ts, and
test_issue_678_reexport_default.ts (the existing tests covering this
same code path) are unaffected.
Co-authored-by: Ralph <ralph@skelpo.com>
0 commit comments