Replies: 1 comment
-
@shellscape May I ask why this was turned into a discussion? Is duplicate imports expected behaviour from the plugin? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
npm install
npm build
to generate incorrect minified files.npm run build:examples
to see the examples unable to import the library because it contains duplicate imports in some files.dist/esm/src/
to find the output files.Expected Behavior
Expect no duplicate imports in each module.
Actual Behavior
Duplicate imports in certain files, for example in this file theres's two imports called
x
:File:
dist/esm/src/elements/controls/viewport.mjs
Which file it picks changes often when I try something different. Sometimes it's multiple files in the project.
When another project then tries to use this library, the build failes with:
Additional Information
I've spend hours looking into it, testing various scenarios and browsing this plugin's and Terser's source code, and I'm suspecting it has something to do with the default
mangle.nth_identifier
. In some specific scenarios it seems to generate a duplicate id which does not get discarded with a specific setup of imports. I've also been able to reproduce it by replacing the default identifier with my own very predictable identifier.Furthermore:
preserveModules
, because turning this off and generating a single file works fine. Though, I want to stick withpreserveModules
for my project, so this is not a solution for me.I've also spent a few hours trying to create a smaller example set up, but unfortunately I wasn't successful in that, as this id generator is just too unpredictable for me to really understand it. So I'm sorry for the big example project.
I hope there's someone out there who knows a bit more about how this works internally.
Thank you for your time!
Beta Was this translation helpful? Give feedback.
All reactions