Angular Compiler compileModuleAndAllComponentsAsync declaration of null
See original GitHub issue🐞 bug report
Affected Package
@angular/core the function compileModuleAndAllComponentsAsync in angular/core compiler is not loading module anymore:
Is this a regression?
Yes, we were totally using this with angular 8 compiler Hello there, I’m sorry to bother you here guys. But we are trying to upgrade our angular application to your new patch angular 9 ivy with AOT compilation. We have a main feature that is to load stand alone angular module precompiled to .umd.js file. And we load them in our main angular application at runtime. For this we were using this at the moment . Our url is our own application and the file is located in our assets folder which is publicly served from our app
` return SystemJS.import(url)
.then((module: any) => {
return module[moduleInfo.moduleName]
})
.then(
module => {
console.log(module)
return this.compiler
.compileModuleAndAllComponentsAsync(module)
.then(_compiled => {
return module
})
.catch(error => {
console.error('ERROR in SystemJS compile with module', {
error,
module
})
// tslint:disable-next-line: rxjs-throw-error
throw { error, module }
})
}
// console.error.bind(console))
)`
Description
I put in this file an example umd.js file that we were loading at runtime
🔥 Exception or Error
core.js:3872 ERROR TypeError: Cannot read property 'declarations' of null
at Compiler_compileModuleAndAllComponentsSync__POST_R3__ (core.js:27418)
at Compiler_compileModuleAndAllComponentsAsync__POST_R3__ [as compileModuleAndAllComponentsAsync] (core.js:27429)
at module.service.ts:182
at ZoneDelegate.invoke (zone.js:396)
at Object.onInvoke (core.js:27800)
at ZoneDelegate.invoke (zone.js:395)
at Zone.run (zone.js:153)
at zone.js:894
at ZoneDelegate.invokeTask (zone.js:431)
at Object.onInvokeTask (core.js:27788)
🌍 Your Environment
Angular Version:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.0.6
Node: 12.16.1
OS: win32 x64
Angular: 9.0.6
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
Ivy Workspace: Yes
Package Version
--------------------------------------------------------------------
@angular-devkit/architect 0.900.6
@angular-devkit/build-angular 0.900.6
@angular-devkit/build-ng-packagr 0.900.6
@angular-devkit/build-optimizer 0.900.6
@angular-devkit/build-webpack 0.900.6
@angular-devkit/core 8.1.3
@angular-devkit/schematics 8.1.3
@angular/cdk 9.1.1
@angular/http 8.0.0-beta.10
@angular/material 9.1.1
@angular/material-moment-adapter 9.1.1
@angular/pwa 0.801.3
@ngtools/webpack 9.0.6
@nguniversal/common 9.0.1
@nguniversal/express-engine 9.0.1
@nguniversal/module-map-ngfactory-loader 8.2.6
@schematics/angular 8.1.3
@schematics/update 0.900.6
ng-packagr 9.0.0
rxjs 6.5.4
typescript 3.6.5
webpack 4.41.2
Anything else relevant?
modula.umd.js renamed for pasting to modulea.umd.js.txt
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (3 by maintainers)
Thanks for pointed this out !! We thought that was what we missed, but when we removed it. The plugin seems to be loaded so it’s ok. But when trying to route to the library module
Thanks anyway your help is much appreciated and I’m grats for that
@Borsi92 I had the same issue but I eventually found out that my lazy loading script was wrong this was what I had
path:'modulePath', loadChildren:()=>import('../some-module/some-module.module').then(m=>{m.some-module})
this is what it should have beenpath:'modulePath', loadChildren:()=>import('../some-module/some-module.module').then(m=>m.some-module)
turns out i didn’t return the module in the arrow function. I don’t know if this helps, but this is the issue I had and how I solved it