Same module imported via import and import -> require points to different code
#13854
oleg-slapdash
started this conversation in
General
Replies: 1 comment 6 replies
-
|
expected, resolution using |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
What is the current behavior?
When the same library from the same location is imported via commonjs
requireand es6importresults in two different instances for classes and duplicate code in the bundle.If the current behavior is a bug, please provide the steps to reproduce.
If an app imports a class directly and then uses a commonjs-based 3rd party library that uses the same library it results having duplicate code in the bundle and
instancesofdoes not work properly. The real issue happens withsuperstructpackage, however, see the demo below with boiled down-version.Visualization:
Repro: https://github.com/oleg-slapdash/webpack-issue-commonjs-es6-deduplication
What is the expected behavior?
Webpack should be able to de-duplicate commonjs and es6 imports of the same library. The bundle should contain only one implementation of the library and instances should be able to be checked via
instanceof.Other relevant information:
webpack version: ^5.46.0
Node.js version: v15.1.0
Operating System: Mac OS 10.15.7
Additional tools: N/A
Beta Was this translation helpful? Give feedback.
All reactions