You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generated HMR metadata update function doesn't include proper imports when using defer blocks #59310
Uncaught ReferenceError: LazyComponent is not defined
at AppComponent_Defer_8_DepsFn (app.component.ts:1:157)
at triggerResourceLoading (chunk-L7E6HT6X.js?v=287274a3:19516:48)
at triggerDeferBlock (chunk-L7E6HT6X.js?v=287274a3:19586:7)
at chunk-L7E6HT6X.js?v=287274a3:19458:38
at callback (chunk-L7E6HT6X.js?v=287274a3:17478:9)
at _ZoneDelegate.invoke (zone.js:369:28)
at Object.onInvoke (chunk-L7E6HT6X.js?v=287274a3:8569:25)
at _ZoneDelegate.invoke (zone.js:368:34)
at ZoneImpl.run (zone.js:111:43)
at _NgZone.run (chunk-L7E6HT6X.js?v=287274a3:8450:24)
Please provide the environment you discovered this bug in (run ng version)
exportdefaultfunctionAppComponent_UpdateMetadata(AppComponent,ɵɵnamespaces){constɵhmr0=ɵɵnamespaces[0];constAppComponent_Defer_8_DepsFn=()=>[LazyComponent];// <-- errorfunctionAppComponent_Defer_7_Template(rf,ctx){if(rf&1){ɵhmr0.ɵɵelement(0,"app-lazy");}}AppComponent.ɵfac=functionAppComponent_Factory(__ngFactoryType__){returnnew(__ngFactoryType__||AppComponent)();};AppComponent.ɵcmp=/*@__PURE__*/ɵhmr0.ɵɵdefineComponent({type: AppComponent,selectors: [["app-root"]],features: [ɵhmr0.ɵɵExternalStylesFeature(["8911acd770bdc9e6b98613f574402426119ebd7d17ab3a9642918dbc80f2ddda.css"])],decls: 10,vars: 0,template: functionAppComponent_Template(rf,ctx){if(rf&1){ɵhmr0.ɵɵelementStart(0,"ol")(1,"li");ɵhmr0.ɵɵtext(2," Open Browser Devtools ");ɵhmr0.ɵɵelementEnd();ɵhmr0.ɵɵelementStart(3,"li");ɵhmr0.ɵɵtext(4," Make a change to app.component.html and save. ");ɵhmr0.ɵɵelementEnd();ɵhmr0.ɵɵelementStart(5,"li");ɵhmr0.ɵɵtext(6," Note error in browser devtools, and \"lazy works\" disappears. ");ɵhmr0.ɵɵelementEnd()();ɵhmr0.ɵɵtemplate(7,AppComponent_Defer_7_Template,1,0);ɵhmr0.ɵɵdefer(8,7,AppComponent_Defer_8_DepsFn);ɵhmr0.ɵɵdeferOnIdle();}}});(()=>{(typeofngDevMode==="undefined"||ngDevMode)&&ɵhmr0.ɵsetClassDebugInfo(AppComponent,{className: "AppComponent",filePath: "src/app/app.component.ts",lineNumber: 10});})();}
EDIT: looks like Dep is being captured because of setClassMetadata in our tests. If I disable it through supportTestBed: false, it stops being captured.
Interesting, we have a test that's identical to your repro and seems to work as expected. I wonder if something isn't getting lost when integrating with the CLI.
Definitely a bug. I suspect it's because it's written as provideIcons({heroUsers}). Does it work if you change it to provideIcons({heroUsers: heroUsers})?
Activity
crisbeto commentedon Dec 27, 2024
EDIT: looks like
Depis being captured because ofsetClassMetadatain our tests. If I disable it throughsupportTestBed: false, it stops being captured.Interesting, we have a test that's identical to your repro and seems to work as expected. I wonder if something isn't getting lost when integrating with the CLI.
fix(compiler-cli): preserve defer block dependencies during HMR when …
brandonroberts commentedon Dec 27, 2024
Thanks @crisbeto. Is there a workaround until this patch is released?
crisbeto commentedon Dec 27, 2024
Assuming the CLI doesn't override it somewhere, you should be able to set
angularCompilerOptions.supportTestBed: truein your tsconfig.brandonroberts commentedon Dec 27, 2024
Ok, it must be overriden internally. I tried that but it's still set to false.
brandonroberts commentedon Dec 27, 2024
This also fails with metadata that is provided as an import
Generated HMR:
crisbeto commentedon Dec 27, 2024
Definitely a bug. I suspect it's because it's written as
provideIcons({heroUsers}). Does it work if you change it toprovideIcons({heroUsers: heroUsers})?brandonroberts commentedon Dec 27, 2024
Yep, that works
fix(compiler-cli): account for more expression types when determining…
crisbeto commentedon Dec 28, 2024
Sent a fix at #59323.
fix(compiler-cli): account for more expression types when determining…
fix(compiler-cli): account for more expression types when determining…
fix(compiler-cli): preserve defer block dependencies during HMR when …
fix(compiler-cli): preserve defer block dependencies during HMR when …
angular-automatic-lock-bot commentedon Feb 6, 2025
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.
fix(compiler-cli): preserve defer block dependencies during HMR when …