Reproduction link or steps
https://stackblitz.com/edit/github-kuvn25tk
- Given 3 entries (a, b, c), they are all independent and do not reference each other.
- Define a
shared folder, with two files: index.ts & build-content.ts.
- Let a and b import
shared/index.ts, and c import shared/build-content.ts.
- Let
shared/index.ts lazy import shared/build-content.ts.
- Install
vitefu as dev dep, and ensure to bundle it, then reference it in entry a. (this can be any dep, this step is necessary)
- Run
tsdown, notice that __exportAll is generated in dist/entry-a/index.js because vitefu's inlined bundle generating parts of rolldown/runtime.
- Notice that the shared file
dist/build-content<hash>.js imports dist/entry-a/index.js, since it's a shared file, all entries now import entry a, problem caused.
What is expected?
When entry (a, b, c) are independent, their dependency relationship should not be changed and remain independent.
In reality, entry-a, entry-b entry-c could be adapters for different runtime/framework, e.g. /next, /tanstack-start, /react-router. This will cause runtime error as a React Router consumer using /react-router adapter will end up importing /next, which may import next and cause runtime error.
What is actually happening?
All entries are importing entry a, while they were originally independent.
Any additional comments?
I was confirming the current behaviour of rolldown based on https://github.com/rolldown/rolldown/blob/70c4828d616df5afabafbafc56ba2c9950fb460b/meta/design/code-splitting.md, but it took more time than I expected, couldn't narrow it down further sadly. Perhaps you might know more about the internals, thank you for the tsdown library :)
Reproduction link or steps
https://stackblitz.com/edit/github-kuvn25tk
sharedfolder, with two files:index.ts&build-content.ts.shared/index.ts, and c importshared/build-content.ts.shared/index.tslazy importshared/build-content.ts.vitefuas dev dep, and ensure to bundle it, then reference it in entry a. (this can be any dep, this step is necessary)tsdown, notice that__exportAllis generated indist/entry-a/index.jsbecausevitefu's inlined bundle generating parts of rolldown/runtime.dist/build-content<hash>.jsimportsdist/entry-a/index.js, since it's a shared file, all entries now import entry a, problem caused.What is expected?
When entry (a, b, c) are independent, their dependency relationship should not be changed and remain independent.
In reality,
entry-a,entry-bentry-ccould be adapters for different runtime/framework, e.g./next,/tanstack-start,/react-router. This will cause runtime error as a React Router consumer using/react-routeradapter will end up importing/next, which may importnextand cause runtime error.What is actually happening?
All entries are importing entry a, while they were originally independent.
Any additional comments?
I was confirming the current behaviour of rolldown based on https://github.com/rolldown/rolldown/blob/70c4828d616df5afabafbafc56ba2c9950fb460b/meta/design/code-splitting.md, but it took more time than I expected, couldn't narrow it down further sadly. Perhaps you might know more about the internals, thank you for the tsdown library :)