-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default import is undefined in dev, but exists in --prod
#9058
Comments
I have similar issues with So at the moment I can't use imports like: |
I was just about to post a bug with steps to reproduce the loadash issue. I have encountered similar issues. @zoamel @cebor , I have fixed my lodash issue by changing: My other issue has to do with my Angular Components that extends a BaseComponent. For that, I had to wrap checks around the method calls. For example:
Note: Rolling back to 1.6.1 works fine in both scenarios. The issue presented starting with 1.6.2 |
--prod
#9059 reported a similar problem. Using the reproduction provided by @cebor I boiled it down to a simpler repro:
Both of these console logs will show I tracked it down to #8128, where we force TS to use commonjs on dev serve. The difference is significant... at the time it could go as high as 60% of rebuild time. This causes different semantics to be used for default imports. This optimization will go away with Webpack 4 (#8611) but for now it's a huge rebuild speed improvement. For now I think the only good alternative is to force the default import:
This will work on dev/prod. |
@filipesilva Thanks for above workaround. It fixed one issue for us on one default import but in another case a library where we use momentjs and build the library using ngc & rollup, using the "import *" approach gives the following error during the rollup step [!] Error: Cannot call a namespace ('moment') There are some workarounds to that, ( rollup/rollup#670 (comment) ) but a consuming angular app throws TypeError: moment_1.default is not a function Is the fix that will come with webpack 4 a big task that is not going to happen anytime soon? |
Followup to angular#8128 Related to webpack/webpack#6248 (comment) Fix angular#9058
Followup to angular#8128 Fix angular#9058
Followup to angular#8128 Fix angular#9058
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Repro steps
Observed behavior
Desired behavior
Following default import should not be undefined: https://github.com/cebor/angular-highcharts-demo/blob/master/src/app/app.module.ts#L4
Mention any other details that might be useful (optional)
The text was updated successfully, but these errors were encountered: