Skip to content

compile: dynamic import() namespace of a pure re-export chunk is empty (breaks esbuild --splitting shared chunks) #6304

Description

@proggeramlug

Summary

The namespace object for a dynamically-imported pure re-export chunk is empty. This is the canonical shape esbuild/bun emit for a shared chunk under --splitting, so it breaks code-split bundles.

Repro

esbuild src/index.ts --bundle --splitting --format=esm --outdir=out --platform=node
perry out/index.js -o app && ./app

esbuild emits out/agent-VP4LHHJR.js as a 2-statement re-export file:

import { run } from "./chunk-XXXX.js";
export { run };

Result:

node perry main
typeof ns object object
typeof ns.run function undefined
ns.run() "[shared-util] agent" (missing)
a chunk containing real code (not a re-export) works works

Perry ingests the whole graph correctly (Found 4 module(s): 4 native, 0 JavaScript) — the chunk-set ingestion from #5572 works. It is specifically the re-export-only chunk whose namespace comes out empty.

Worse: an unguarded ns.run() printed undefined rather than throwing ns.run is not a function, so this is a silent wrong answer.

Likely the same family as #5916 (barrel re-export of a namespace value never gets a wrapper).

Split out of #5207, whose headline ask (ingest a bundler's chunk-set) did ship.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions