angular/packages/compiler/src/render3
Kristiyan Kostadinov 86d8f6bda8 refactor(compiler): trigger hmr load on initialization (#58465)
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
2024-11-01 19:14:16 +00:00
..
partial refactor(compiler): dynamic default for the partial compiler. (#58169) 2024-10-15 16:05:14 +00:00
view refactor(core): remove the standalone feature (#58288) 2024-10-24 16:19:02 -07:00
r3_ast.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_class_debug_info_compiler.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_class_metadata_compiler.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_control_flow.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_deferred_blocks.ts fix(compiler): add more specific matcher for hydrate never block (#58360) 2024-10-28 12:35:11 -07:00
r3_deferred_triggers.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_factory.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_hmr_compiler.ts refactor(compiler): trigger hmr load on initialization (#58465) 2024-11-01 19:14:16 +00:00
r3_identifiers.ts refactor(core): remove the standalone feature (#58288) 2024-10-24 16:19:02 -07:00
r3_injector_compiler.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_jit.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_module_compiler.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
r3_pipe_compiler.ts refactor(core): Don't generate standalone: true for definitions (#58238) 2024-10-24 12:44:13 -07:00
r3_template_transform.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
util.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00