An attempt to inject some plugins ends up with the following runtime error:
Error: key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?
I found that all the plugins giving this error were not configured with configure() because it does not exist in the webpack-generated build.
Here is an example, let's take 2 plugins, aurelia-store 1.7.0 and aurelia-dialog 2.0.0
They are registered in the main.ts, nothing special:
As you can see, aurelia-dialog properly exported as harmony module, but aurelia-store has mangled names and unused configure(). Some plugins are fine, and some (store and i18n are the notable examples) are broken, and I cannot find the pattern yet.
If I set webpack optimization option mangleExports to false, it restores the function names and usedExports: false solves the issue, but in the cost of broken tree-shaking and huge bundle size.
I have a feeling that it has something to do with the PreserveExportsPlugin, but unfortunately I was not able to trace the origin of the problem.
I'm submitting a bug report
Please tell us about your environment:
Operating System: Linux 5.10.42-1-MANJARO
Node Version: v16.3.0
NPM Version: 7.19.1
JSPM OR Webpack AND Version webpack 5.41.1
Browser: all
Language: TypeScript
Current behavior:
As I mentioned in https://github.com/aurelia/webpack-plugin/issues/181#issuecomment-876436789, I have some issues after changing the module type to ESNext.
An attempt to inject some plugins ends up with the following runtime error: Error: key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?
I found that all the plugins giving this error were not configured with
configure()
because it does not exist in the webpack-generated build.Here is an example, let's take 2 plugins, aurelia-store 1.7.0 and aurelia-dialog 2.0.0 They are registered in the main.ts, nothing special:
Webpack (using config from #181 with turned off minification) bundled them as following:
and
As you can see, aurelia-dialog properly exported as harmony module, but aurelia-store has mangled names and unused
configure()
. Some plugins are fine, and some (store and i18n are the notable examples) are broken, and I cannot find the pattern yet.If I set webpack optimization option
mangleExports
tofalse
, it restores the function names andusedExports: false
solves the issue, but in the cost of broken tree-shaking and huge bundle size.I have a feeling that it has something to do with the
PreserveExportsPlugin
, but unfortunately I was not able to trace the origin of the problem.