Incorrect resolution of default import for library.type = "system" #19922
Closed
AlekseyMalakhov
started this conversation in
General
Replies: 1 comment 1 reply
-
Hello, sorry for small delay, investigating, sounds like a bug |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Currently I’m migrating my project from Webpack 4 to Webpack 5. Project uses SystemJS modules.
In Webpack 4 when you bundle a library (e. g. React) as SystemJS module, default import of resulting module will return a whole object (React in my case).
In Webpack 5 when you bundle a library (e. g. React) as SystemJS module, default import of resulting module will return undefined, instead of the whole object.
I created a small, reproducible example. Here is a link
Repo contains 2 folders - webpack4 and webpack5 with (almost) identical code. The goal is to show the difference in behavior between Webpack 4 and 5.
How to start:
npm install
in both folders (webpack4 and webpack5)npm run serve
in both foldersconsole.logs
fromsrc/app.js
file.You will see the following difference:
http://localhost:9004 - displays data for both default and named import (React and useEffect).
http://localhost:9005 - displays data only for named import (useEffect). React is undefined.
If we check the resulted
main.js
files created by both webpacks we will see the that Webpack 5 has the following expression:But the problem is that
e
does not have adefault
property. That’s why React is undefined.Webpack 4 does not have this string and works correctly - for default import it returns the whole React module.
Any suggestions how to fix it in Webpack 5?
Beta Was this translation helpful? Give feedback.
All reactions