Issue
I am converting an angular app to angular lib. I generated angular lib project and slowly moving the modules. I now get the following error while building the library.
ng build lib
Error
Cannot read property 'module' of undefined
TypeError: Cannot read property 'module' of undefined
at MetadataBundler.convertSymbol (C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:312:61)
at createReference (C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:438:27)
at MetadataBundler.convertReference (C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:486:28)
at MetadataBundler.convertExpression (C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:415:37)
at C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:364:79
at Array.map (<anonymous>)
at MetadataBundler.convertMember (C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:364:47)
at C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:349:70
at Array.map (<anonymous>)
at MetadataBundler.convertMembers (C:\Code\abc\client\node_modules\@angular\compiler-cli\src\metadata\bundler.js:349:38)
Typically this error is caused when trying to register dependencies incorrectly in the module. How can I find, which part of my configuration makes this exception?
It works fine in angular app.
Solution
If angular decides to fail on aot compilation, you could try to go into node_modules\@angular\compiler-cli\src\metadata\bundler.js
and do some console logging in that file.
I would start from placing console.log in convertSymbol function.
That should provide you with some information about the file path which angular cli used before falling on module compilation.
For example in my case, it was the re-export of the constant from the barrel which broke the compilation
So finding all the usages of TWO_FA_INITIAL_STATE, and directly importing TWO_FA_INITIAL_STATE, fixed that particular problem.
Answered By - Mike
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.