angular/packages/compiler/src
Kristiyan Kostadinov 7d0ba0cac8 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
..
expression_parser fix(compiler): handle typeof expressions in serializer (#58217) 2024-10-16 09:47:10 +00:00
i18n refactor(compiler): remove preservePlaceholders (#58176) 2024-10-16 06:42:37 +00:00
ml_parser refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
output refactor(compiler): remove unused field from output AST (#58444) 2024-11-01 14:32:57 +00:00
render3 refactor(compiler): trigger hmr load on initialization (#58465) 2024-11-01 19:14:16 +00:00
schema refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
template/pipeline feat(compiler): add support for the typeof keyword in template expressions. (#58183) 2024-10-16 07:31:00 +00:00
template_parser refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
assertions.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
chars.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
compiler.ts refactor(compiler): generate HMR update function (#58205) 2024-10-16 07:22:45 +00:00
compiler_facade_interface.ts refactor(compiler): dynamic default for the partial compiler. (#58169) 2024-10-15 16:05:14 +00:00
config.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
constant_pool.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
core.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
injectable_compiler_2.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
jit_compiler_facade.ts refactor(compiler): dynamic default for the partial compiler. (#58169) 2024-10-15 16:05:14 +00:00
parse_util.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
resource_loader.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
selector.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
shadow_css.ts fix(compiler): scope :host-context inside pseudo selectors, do not decrease specificity (#57796) 2024-10-10 08:13:22 +00:00
style_url_resolver.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
util.ts refactor(compiler): dynamic default for the partial compiler. (#58169) 2024-10-15 16:05:14 +00:00
version.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00