Skip to content

[Bug]: codeSplitting + strictExecutionOrder causes undefined behavior #10259

Description

@susnux

Reproduction link or steps

I tried to condense the issue into this REPL as our real project is much larger and has more configuration, but you can reproduce it here:

https://repl.rolldown.rs/#eNq1VcFu00AQ/ZWROThFtQMVJ0tIVKVIHAqIllMTEdc7ThbWu2Z3nTSKIvERfCFfwthrO+s0RlzIIbFn3s7MezM72QV5kOwCrYRgaiPjTMmcL2NraqsMklOe8yAjBy9KpS3sgGHOJV41bthDrlUBYXcsnMmZxMcGSsC0Es1vf2Cym0kALsvKJtA8A4QlaqNkKsIEQqOzKOoM8TcTnreglBVc9ojmzXfbFZJl2QPa9x6yb76nU9D4o+IaGTxsYcFlJiqGb7FEyVBmHM1nzCpt+BrFNoE8FQYX8IBCberzpUaDeo3X0urtLV/K1FZkoqSpIEiEjxal4Uq6pKqyPlHGNSEZN7YrO1e6SAkQYs8E69DvuMAPadFEvpf0MI+LA9lsVcnvJyCN3Qcaq3lmrx+JkqWiPmqGVIHVFbYA0uOGa620ARIMMsUwMqXg1pJ2sNSqKg1Uxqn1hhprM6EqNl1zi5GbkKSPFIGS2NRPMl5uUo0wC9KynAUuEqVILRSol2jAFKQYUKOjhjCY6sGl+3u4NfVJ6T4i6QeSiv5aKFYJCsuQCp5Q529XdOBKVZLUvThrdSPkbceu7wq0PBO47wxw8NWfWl1SuRuxVjv3sWgow9QNZVlG0XTg9ssfKP/UfVMLc7eicVopwRJ4+eIFPKfvi1eDI/80st4JN/jjrJyiJ0k51zGlY3H/K99D9fP2yVn2M7mnrgb782CwD7o1NjQONlgYe93q94gXy9s+g3C+fTyiv7u8oId9NIjpmcdDervMp+zXP+Q98Li4dFmNEhgLtZyE9wabO2Acag5F3cv6yjfv9S5oJn2g8BG5pxlH9dnBp1RQRnxPVfR/GXE/X6XzRpzcjiRdf6vKSCDNNBjOaA/kOWYWfv/8RVstlczQRWiu/yLTmFq8LMvJF9rNd670s7ihNAmf9VS78jo5w7PFTI7I0mE9ZTbcrsJzn0lc36AnEo00+th3qiutew4EFts6aW3Brg0jcnVpxtwuU/ufXCe0g3a8pva0q8Azh/UNC/Z1VjosSGBjg/0fjRG1kQ==

To test you can try to run the resulting entry points:

Image

What is expected?

All entry points can be executed correctly.

What is actually happening?

codeSplitting turns an acyclic module graph into a chunk graph where a shared/common chunk statically imports a binding out of an entry chunk that has top-level side-effects depending on that shared chunk. Rolldown should either not create such a cycle, or order/wrap it so bindings are initialized before use.

TL;DR:
When running such bundled entry points errors like this are thrown init_XY is not a function (in the debugger you see its undefined due to import / evaluation race conditions).

System Info

System:
    OS: Linux 7.1
  Binaries:
    Node: 24.18.0
    npm: 11.16.0
  Browsers:
    Chromium: 149
    Firefox: 152
  npmPackages:
    rolldown: ^1.1.5 => 1.1.5

Any additional comments?

Might be related to those issues, but they explicitly only mention CJS output, but this here is about ESM.

Metadata

Metadata

Assignees

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions