Skip to content
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

Version 13.2.2 breaks production build when using dynamic imports #22662

Closed
1 of 15 tasks
annervisser opened this issue Feb 7, 2022 · 1 comment · Fixed by #22683
Closed
1 of 15 tasks

Version 13.2.2 breaks production build when using dynamic imports #22662

annervisser opened this issue Feb 7, 2022 · 1 comment · Fixed by #22683

Comments

@annervisser
Copy link
Contributor

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 13.2.1

Description

When running a production build with version 13.2.2, it fails with an error after chunk generation completes.
This relates to using a dynamic import of a json file.
The error is: An unhandled exception occurred: Cannot read properties of undefined (reading 'name') (see below for extended error)
ng serve does not have this problem.

🔬 Minimal Reproduction

  • A dynamic import of a json file: import(`../../../../../assets/animations/${this.animation}.json`).then(animation => {
  • causes the error (Cannot read properties of undefined (reading 'name')
  • Because in function extractIdentifiedModule the directory and packageJson are undefined

The problem is caused by license-webpack-plugin@4.0.1, specifically the changes in commit xz64/license-webpack-plugin@55dd3f8
Also reported as bug to license-webpack-plugin: xz64/license-webpack-plugin#119

🔥 Exception or Error

Error


✔ Browser application bundle generation complete.
An unhandled exception occurred: Cannot read properties of undefined (reading 'name')
See "/tmp/ng-IvNqNx/angular-errors.log" for further details.

angular-errors.log:


[error] HookWebpackError: Cannot read properties of undefined (reading 'name')
    at makeWebpackError (/scienta/resources/script/node_modules/webpack/lib/HookWebpackError.js:48:9)
    at /scienta/resources/script/node_modules/webpack/lib/Compilation.js:3057:12
    at eval (eval at create (/scienta/resources/script/node_modules/tapable/lib/HookCodeFactory.js:33:10), :31:1)
    at fn (/scienta/resources/script/node_modules/webpack/lib/Compilation.js:478:17)
    at _next4 (eval at create (/scienta/resources/script/node_modules/tapable/lib/HookCodeFactory.js:33:10), :28:1)
    at eval (eval at create (/scienta/resources/script/node_modules/tapable/lib/HookCodeFactory.js:33:10), :46:1)
    at fn (/scienta/resources/script/node_modules/webpack/lib/Compilation.js:490:9)
    at _next3 (eval at create (/scienta/resources/script/node_modules/tapable/lib/HookCodeFactory.js:33:10), :41:1)
    at eval (eval at create (/scienta/resources/script/node_modules/tapable/lib/HookCodeFactory.js:33:10), :60:1)
    at runMicrotasks ()
-- inner error --
TypeError: Cannot read properties of undefined (reading 'name')
    at PluginChunkReadHandler.extractIdentifiedModule (/scienta/resources/script/node_modules/license-webpack-plugin/dist/PluginChunkReadHandler.js:39:35)
    at /scienta/resources/script/node_modules/license-webpack-plugin/dist/PluginChunkReadHandler.js:21:46
    at WebpackInnerModuleIterator.internalCallback (/scienta/resources/script/node_modules/license-webpack-plugin/dist/WebpackInnerModuleIterator.js:39:13)
    at WebpackInnerModuleIterator.iterateModules (/scienta/resources/script/node_modules/license-webpack-plugin/dist/WebpackInnerModuleIterator.js:21:9)
    at /scienta/resources/script/node_modules/license-webpack-plugin/dist/PluginChunkReadHandler.js:20:39
    at WebpackChunkModuleIterator.iterateModules (/scienta/resources/script/node_modules/license-webpack-plugin/dist/WebpackChunkModuleIterator.js:28:21)
    at PluginChunkReadHandler.processChunk (/scienta/resources/script/node_modules/license-webpack-plugin/dist/PluginChunkReadHandler.js:19:29)
    at _loop_1 (/scienta/resources/script/node_modules/license-webpack-plugin/dist/WebpackCompilerHandler.js:135:37)
    at WebpackCompilerHandler.iterateChunks (/scienta/resources/script/node_modules/license-webpack-plugin/dist/WebpackCompilerHandler.js:160:17)
    at /scienta/resources/script/node_modules/license-webpack-plugin/dist/WebpackCompilerHandler.js:50:31

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 13.2.2
Node: 16.13.2
Package Manager: yarn 1.22.15
OS: linux x64

Angular: 13.2.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, localize, material
... material-moment-adapter, platform-browser
... platform-browser-dynamic, platform-server, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1302.2
@angular-devkit/build-angular   13.2.2
@angular-devkit/core            13.2.2
@angular-devkit/schematics      13.2.2
@angular/cli                    13.2.2
@schematics/angular             13.2.2
rxjs                            6.6.7
typescript                      4.5.5

@ngbot ngbot bot modified the milestone: Backlog Feb 7, 2022
annervisser added a commit to annervisser/angular-cli that referenced this issue Feb 10, 2022
…4.0.2

Fixes builds with extractLicenses enabled when using dynamic exports

Fixes angular#22662
alan-agius4 pushed a commit that referenced this issue Feb 10, 2022
…4.0.2

Fixes builds with extractLicenses enabled when using dynamic exports

Fixes #22662
alan-agius4 pushed a commit that referenced this issue Feb 10, 2022
…4.0.2

Fixes builds with extractLicenses enabled when using dynamic exports

Fixes #22662

(cherry picked from commit fafbbea)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants