mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Adjusts the HMR initialization to avoid the edge case where a developer makes change to a non-rendered component that exists in a lazy loaded chunk that has not been loaded yet. The changes include:
* Moving the `import` statement out into a separate function.
* Adding a null check for `d.default` before calling `replaceMEtadata`.
* Triggering the `import` callback eagerly on initialization.
Example of the new generated code:
```js
(() => {
function Cmp_HmrLoad(t) {
import(
/* @vite-ignore */ "/@ng/component?c=test.ts%40Cmp&t=" + encodeURIComponent(t)
).then((m) => m.default && i0.ɵɵreplaceMetadata(Cmp, m.default, [/* Dependencies go here */]));
}
(typeof ngDevMode === "undefined" || ngDevMode) && Cmp_HmrLoad(Date.now());
(typeof ngDevMode === "undefined" || ngDevMode) &&
import.meta.hot &&
import.meta.hot.on("angular:component-update", (d) => {
if (d.id === "test.ts%40Cmp") {
Cmp_HmrLoad(d.timestamp);
}
});
})();
```
PR Close #58465
|
||
|---|---|---|
| .. | ||
| expression_parser | ||
| i18n | ||
| ml_parser | ||
| output | ||
| render3 | ||
| schema | ||
| template/pipeline | ||
| template_parser | ||
| assertions.ts | ||
| chars.ts | ||
| compiler.ts | ||
| compiler_facade_interface.ts | ||
| config.ts | ||
| constant_pool.ts | ||
| core.ts | ||
| injectable_compiler_2.ts | ||
| jit_compiler_facade.ts | ||
| parse_util.ts | ||
| resource_loader.ts | ||
| selector.ts | ||
| shadow_css.ts | ||
| style_url_resolver.ts | ||
| util.ts | ||
| version.ts | ||