Skip to content

[Bug]: export wildcard in combination with top level await #8986

@damask

Description

@damask

Reproduction link or steps

Recently as developers we have got to work with top level await in our code and we use rolldown as a bundler.
And here is the problem that came out.
When some exports in modules are declared with wildcards (export * from)
that disables rolldown from tracking types and at some point await is getting lost which leads to broken code when bundle generated.

I have worked around it by creating a plugin which replaces wildcard exports to named ones and that seemed to work but I would like to work without additional complications.

Here is the repo with MRE.
https://github.com/damask/rolldown-export-wildcard-top-level-await

Thank you!

What is expected?

Wildcard exports are expected to work as named ones.

When I build the named case it works fine and I see in the bundle

//#region src/reexport-named.ts var init_reexport_named = __esm({ "src/reexport-named.ts": (async () => { await init_async_nested_module(); }) });

What is actually happening?

When we build export * case
await is lost
code is broken

//#region src/async-module.ts var init_async_module = __esm({ "src/async-module.ts": (async () => { init_async_nested_module(); // THE PROBLEM }) });

System Info

"rolldown": "1.0.0-beta.35"

find details in repo I created

Any additional comments?

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions