Duplicate Exports Generated by bun build
When Using --splitting
Option with Glob Pattern in Entry
#14493
Labels
bug
Something isn't working
bundler
Something to do with the bundler
confirmed bug
We can repo this issue
What version of Bun is running?
1.1.30
What platform is your computer?
Darwin 23.5.0 arm64 arm
What steps can reproduce the bug?
Description
I’ve been considering switching to Bun as an all-in-one tool for my project, and everything has worked smoothly so far. However, I encountered an issue with the output generated by the
build
commandMy project consists of numerous submodules, which need to be built as separate modules. To avoid manually specifying each entry file for every submodule, I used a glob pattern for the
entry
option of thebuild
command (e.g.,src/**/*.ts
)The issue arises when I include the
--splitting
option in thebuild
command. In this case, all exports in each module are duplicated in the output files across all submodulesSteps to Reproduce
d072e4e9d1d647bc6974619dac37e09f5c067216
bun i
bun build src/**/*.ts --outdir dist --splitting
dist
directory and observe the duplicated exports in every moduleWhat is the expected behavior?
When using the
--splitting
option with a glob pattern in theentry
option (e.g.,src/**/*.ts
), Bun should generate output files with correctly defined exports, ensuring that each export is only defined once in every module. The generated files should not contain any duplicate export declarations, and the build process should handle module splitting without any redundancy in the outputWhat do you see instead?
With the
--splitting
option enabled, the generated output files contain duplicated exports in every module. Each export is defined twice, leading to unnecessary redundancy in the bundled output. This issue occurs consistently across all submodules when using the glob pattern for the entry pointsExample
Input:
Output:
Additional information
--splitting
option is used in thebuild
command--splitting
option, everything works as expected, and no duplicate exports are generatedindex.ts
file that re-exports from other files, and those files also have their own exportsindex.ts
file, the--splitting
option works correctly, and no duplicate exports are presentindex.ts
This summarizes the key points I’ve observed so far
The text was updated successfully, but these errors were encountered: