@analogjs/vite-plugin-angular 3.0.0-alpha.9 → 3.0.0-alpha.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +121 -0
  2. package/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
  3. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
  4. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
  5. package/migrations/migration.json +7 -1
  6. package/migrations/migrations.json +9 -0
  7. package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
  8. package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
  9. package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
  10. package/package.json +49 -8
  11. package/src/index.d.ts +7 -2
  12. package/src/index.js +3 -1
  13. package/src/index.js.map +1 -1
  14. package/src/lib/analog-plugin-interop.d.ts +78 -0
  15. package/src/lib/analog-plugin-interop.js +97 -0
  16. package/src/lib/analog-plugin-interop.js.map +1 -0
  17. package/src/lib/angular-build-optimizer-plugin.d.ts +8 -4
  18. package/src/lib/angular-build-optimizer-plugin.js +66 -31
  19. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  20. package/src/lib/angular-jit-plugin.d.ts +3 -3
  21. package/src/lib/angular-jit-plugin.js +28 -6
  22. package/src/lib/angular-jit-plugin.js.map +1 -1
  23. package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
  24. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  25. package/src/lib/angular-vite-plugin.d.ts +79 -69
  26. package/src/lib/angular-vite-plugin.js +774 -352
  27. package/src/lib/angular-vite-plugin.js.map +1 -1
  28. package/src/lib/angular-vitest-plugin.d.ts +26 -21
  29. package/src/lib/angular-vitest-plugin.js +34 -25
  30. package/src/lib/angular-vitest-plugin.js.map +1 -1
  31. package/src/lib/compilation-api/compilation-api-plugin.d.ts +24 -0
  32. package/src/lib/compilation-api/compilation-api-plugin.js +547 -0
  33. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
  34. package/src/lib/compilation-api/index.d.ts +1 -0
  35. package/src/lib/compilation-api/index.js +1 -0
  36. package/src/lib/compiler/angular-version.d.ts +19 -0
  37. package/src/lib/compiler/angular-version.js +31 -0
  38. package/src/lib/compiler/angular-version.js.map +1 -0
  39. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  40. package/src/lib/compiler/class-field-lowering.js +131 -0
  41. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  42. package/src/lib/compiler/compile.d.ts +50 -0
  43. package/src/lib/compiler/compile.js +814 -0
  44. package/src/lib/compiler/compile.js.map +1 -0
  45. package/src/lib/compiler/constants.d.ts +24 -0
  46. package/src/lib/compiler/constants.js +59 -0
  47. package/src/lib/compiler/constants.js.map +1 -0
  48. package/src/lib/compiler/debug.d.ts +22 -0
  49. package/src/lib/compiler/debug.js +20 -0
  50. package/src/lib/compiler/debug.js.map +1 -0
  51. package/src/lib/compiler/defer.d.ts +57 -0
  52. package/src/lib/compiler/defer.js +154 -0
  53. package/src/lib/compiler/defer.js.map +1 -0
  54. package/src/lib/compiler/dts-reader.d.ts +45 -0
  55. package/src/lib/compiler/dts-reader.js +395 -0
  56. package/src/lib/compiler/dts-reader.js.map +1 -0
  57. package/src/lib/compiler/hmr.d.ts +16 -0
  58. package/src/lib/compiler/hmr.js +69 -0
  59. package/src/lib/compiler/hmr.js.map +1 -0
  60. package/src/lib/compiler/index.d.ts +8 -0
  61. package/src/lib/compiler/index.js +8 -0
  62. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  63. package/src/lib/compiler/jit-metadata.js +168 -0
  64. package/src/lib/compiler/jit-metadata.js.map +1 -0
  65. package/src/lib/compiler/jit-transform.d.ts +24 -0
  66. package/src/lib/compiler/jit-transform.js +204 -0
  67. package/src/lib/compiler/jit-transform.js.map +1 -0
  68. package/src/lib/compiler/js-emitter.d.ts +10 -0
  69. package/src/lib/compiler/js-emitter.js +446 -0
  70. package/src/lib/compiler/js-emitter.js.map +1 -0
  71. package/src/lib/compiler/metadata.d.ts +36 -0
  72. package/src/lib/compiler/metadata.js +710 -0
  73. package/src/lib/compiler/metadata.js.map +1 -0
  74. package/src/lib/compiler/registry.d.ts +56 -0
  75. package/src/lib/compiler/registry.js +176 -0
  76. package/src/lib/compiler/registry.js.map +1 -0
  77. package/src/lib/compiler/resource-inliner.d.ts +43 -0
  78. package/src/lib/compiler/resource-inliner.js +230 -0
  79. package/src/lib/compiler/resource-inliner.js.map +1 -0
  80. package/src/lib/compiler/style-ast.d.ts +9 -0
  81. package/src/lib/compiler/style-ast.js +54 -0
  82. package/src/lib/compiler/style-ast.js.map +1 -0
  83. package/src/lib/compiler/styles.d.ts +13 -0
  84. package/src/lib/compiler/test-helpers.d.ts +7 -0
  85. package/src/lib/compiler/type-elision.d.ts +28 -0
  86. package/src/lib/compiler/type-elision.js +211 -0
  87. package/src/lib/compiler/type-elision.js.map +1 -0
  88. package/src/lib/compiler/utils.d.ts +40 -0
  89. package/src/lib/compiler/utils.js +76 -0
  90. package/src/lib/compiler/utils.js.map +1 -0
  91. package/src/lib/compiler-plugin.d.ts +13 -12
  92. package/src/lib/compiler-plugin.js +18 -18
  93. package/src/lib/compiler-plugin.js.map +1 -1
  94. package/src/lib/component-resolvers.d.ts +20 -4
  95. package/src/lib/component-resolvers.js +34 -20
  96. package/src/lib/component-resolvers.js.map +1 -1
  97. package/src/lib/encapsulation-plugin.d.ts +23 -0
  98. package/src/lib/encapsulation-plugin.js +68 -0
  99. package/src/lib/encapsulation-plugin.js.map +1 -0
  100. package/src/lib/fast-compile-plugin.d.ts +23 -0
  101. package/src/lib/fast-compile-plugin.js +433 -0
  102. package/src/lib/fast-compile-plugin.js.map +1 -0
  103. package/src/lib/host.d.ts +10 -8
  104. package/src/lib/host.js +59 -17
  105. package/src/lib/host.js.map +1 -1
  106. package/src/lib/live-reload-plugin.d.ts +5 -5
  107. package/src/lib/live-reload-plugin.js +10 -0
  108. package/src/lib/live-reload-plugin.js.map +1 -1
  109. package/src/lib/models.d.ts +9 -9
  110. package/src/lib/nx-folder-plugin.d.ts +5 -5
  111. package/src/lib/nx-folder-plugin.js.map +1 -1
  112. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  113. package/src/lib/plugins/file-replacements.plugin.js +6 -1
  114. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  115. package/src/lib/router-plugin.d.ts +1 -1
  116. package/src/lib/router-plugin.js +14 -2
  117. package/src/lib/router-plugin.js.map +1 -1
  118. package/src/lib/style-preprocessor.d.ts +35 -0
  119. package/src/lib/style-preprocessor.js +35 -0
  120. package/src/lib/style-preprocessor.js.map +1 -0
  121. package/src/lib/stylesheet-registry.d.ts +74 -0
  122. package/src/lib/stylesheet-registry.js +174 -0
  123. package/src/lib/stylesheet-registry.js.map +1 -0
  124. package/src/lib/tools/package.json +1 -3
  125. package/src/lib/tools/src/builders/vite/vite-build.impl.js +7 -5
  126. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  127. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +16 -19
  128. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  129. package/src/lib/utils/compilation-shared.d.ts +62 -0
  130. package/src/lib/utils/compilation-shared.js +138 -0
  131. package/src/lib/utils/compilation-shared.js.map +1 -0
  132. package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
  133. package/src/lib/utils/css-extension-resolver.d.ts +32 -0
  134. package/src/lib/utils/css-extension-resolver.js +73 -0
  135. package/src/lib/utils/css-extension-resolver.js.map +1 -0
  136. package/src/lib/utils/css-preprocessor-workers.d.ts +6 -0
  137. package/src/lib/utils/css-preprocessor-workers.js +29 -0
  138. package/src/lib/utils/css-preprocessor-workers.js.map +1 -0
  139. package/src/lib/utils/debug-harness.d.ts +23 -0
  140. package/src/lib/utils/debug-harness.js +88 -0
  141. package/src/lib/utils/debug-harness.js.map +1 -0
  142. package/src/lib/utils/debug-log-file.d.ts +5 -0
  143. package/src/lib/utils/debug-log-file.js +56 -0
  144. package/src/lib/utils/debug-log-file.js.map +1 -0
  145. package/src/lib/utils/debug.d.ts +26 -0
  146. package/src/lib/utils/debug.js +35 -0
  147. package/src/lib/utils/debug.js.map +1 -0
  148. package/src/lib/utils/devkit.d.ts +14 -6
  149. package/src/lib/utils/devkit.js +40 -2
  150. package/src/lib/utils/devkit.js.map +1 -1
  151. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  152. package/src/lib/utils/jit-inline-styles.d.ts +3 -0
  153. package/src/lib/utils/jit-inline-styles.js +16 -0
  154. package/src/lib/utils/jit-inline-styles.js.map +1 -0
  155. package/src/lib/utils/plugin-config.d.ts +41 -0
  156. package/src/lib/utils/plugin-config.js +85 -0
  157. package/src/lib/utils/plugin-config.js.map +1 -0
  158. package/src/lib/utils/rolldown.d.ts +1 -1
  159. package/src/lib/utils/rolldown.js.map +1 -1
  160. package/src/lib/utils/safe-module-paths.d.ts +16 -0
  161. package/src/lib/utils/safe-module-paths.js +29 -0
  162. package/src/lib/utils/safe-module-paths.js.map +1 -0
  163. package/src/lib/utils/source-file-cache.d.ts +8 -15
  164. package/src/lib/utils/source-file-cache.js.map +1 -1
  165. package/src/lib/utils/transform-cache.d.ts +43 -0
  166. package/src/lib/utils/transform-cache.js +97 -0
  167. package/src/lib/utils/transform-cache.js.map +1 -0
  168. package/src/lib/utils/tsconfig-resolver.d.ts +34 -0
  169. package/src/lib/utils/tsconfig-resolver.js +205 -0
  170. package/src/lib/utils/tsconfig-resolver.js.map +1 -0
  171. package/src/lib/utils/virtual-ids.d.ts +4 -0
  172. package/src/lib/utils/virtual-ids.js +23 -0
  173. package/src/lib/utils/virtual-ids.js.map +1 -0
  174. package/src/lib/utils/virtual-resources.d.ts +19 -0
  175. package/src/lib/utils/virtual-resources.js +38 -0
  176. package/src/lib/utils/virtual-resources.js.map +1 -0
  177. package/src/lib/virtual-modules-plugin.d.ts +5 -0
  178. package/src/lib/virtual-modules-plugin.js +23 -0
  179. package/src/lib/virtual-modules-plugin.js.map +1 -0
  180. package/src/test-setup.d.ts +2 -0
  181. package/setup-vitest.d.ts +0 -4
  182. package/setup-vitest.js +0 -176
  183. package/setup-vitest.js.map +0 -1
  184. package/src/lib/tools/src/index.d.ts +0 -0
@@ -1,49 +1,84 @@
1
- import { jt } from "./utils/devkit.js";
2
- import { getJsTransformConfigKey } from "./utils/rolldown.js";
1
+ import { JavaScriptTransformer } from "./utils/devkit.js";
2
+ import { isProdMode } from "./utils/plugin-config.js";
3
3
  //#region packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts
4
4
  function buildOptimizerPlugin({ jit }) {
5
- const javascriptTransformer = new jt({
6
- sourcemap: false,
7
- thirdPartySourcemaps: false,
8
- advancedOptimizations: true,
9
- jit: true
10
- }, 1);
5
+ const transformers = /* @__PURE__ */ new Map();
11
6
  let isProd = false;
7
+ let isWatch = false;
8
+ let preserveVendorMaps = false;
9
+ function getTransformer(envName = "default") {
10
+ let transformer = transformers.get(envName);
11
+ if (!transformer) {
12
+ transformer = new JavaScriptTransformer({
13
+ sourcemap: preserveVendorMaps,
14
+ thirdPartySourcemaps: preserveVendorMaps,
15
+ advancedOptimizations: isProd,
16
+ jit: true
17
+ }, 1);
18
+ transformers.set(envName, transformer);
19
+ }
20
+ return transformer;
21
+ }
12
22
  return {
13
23
  name: "@analogjs/vite-plugin-angular-optimizer",
14
- apply: "build",
24
+ apply(_config, env) {
25
+ return env.command === "build" || process.env.NODE_ENV === "production";
26
+ },
15
27
  config(userConfig) {
16
- isProd = userConfig.mode === "production" || process.env.NODE_ENV === "production";
17
- const jsTransformConfigKey = getJsTransformConfigKey();
18
- return {
19
- define: isProd ? {
20
- ngJitMode: "false",
21
- ngI18nClosureMode: "false",
22
- ngDevMode: "false",
23
- ngServerMode: `${!!userConfig.build?.ssr}`
24
- } : {},
25
- [jsTransformConfigKey]: { define: isProd ? {
26
- ngDevMode: "false",
27
- ngJitMode: "false",
28
- ngI18nClosureMode: "false",
29
- ngServerMode: `${!!userConfig.build?.ssr}`
30
- } : void 0 }
31
- };
28
+ isProd = isProdMode(userConfig.mode);
29
+ return { define: isProd ? {
30
+ ngJitMode: "false",
31
+ ngI18nClosureMode: "false",
32
+ ngDevMode: "false",
33
+ ngServerMode: `${!!userConfig.build?.ssr}`
34
+ } : {} };
35
+ },
36
+ configEnvironment(_name, config) {
37
+ if (isProd && config.consumer === "server") return { define: { ngServerMode: "true" } };
38
+ },
39
+ configResolved(config) {
40
+ preserveVendorMaps = !!config.build.sourcemap;
41
+ isWatch = config.command === "serve" || !!config.build?.watch;
32
42
  },
33
43
  transform: {
34
- filter: { id: /\.[cm]?js$/ },
44
+ filter: { id: /\.[cm]?js(?:\?|$)/ },
35
45
  async handler(code, id) {
36
- if (!/fesm20/.test(id)) return {
37
- code: isProd ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, "") : code,
46
+ const cleanId = id.split("?")[0];
47
+ if (!/fesm20/.test(cleanId)) return {
48
+ code: isProd && !preserveVendorMaps ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, "") : code,
49
+ map: preserveVendorMaps ? null : { mappings: "" }
50
+ };
51
+ const sideEffects = jit && cleanId.includes("@angular/compiler") ? true : false;
52
+ const result = await getTransformer(this.environment?.name ?? "default").transformData(cleanId, code, false, sideEffects);
53
+ const transformed = Buffer.from(result).toString();
54
+ return preserveVendorMaps ? extractInlineSourceMap(transformed, cleanId) : {
55
+ code: transformed,
38
56
  map: { mappings: "" }
39
57
  };
40
- const sideEffects = jit && id.includes("@angular/compiler") ? true : false;
41
- const result = await javascriptTransformer.transformData(id, code, false, sideEffects);
42
- return { code: Buffer.from(result).toString() };
58
+ }
59
+ },
60
+ async closeBundle() {
61
+ if (isWatch) return;
62
+ const envName = this.environment?.name ?? "default";
63
+ const transformer = transformers.get(envName);
64
+ if (transformer) {
65
+ transformers.delete(envName);
66
+ await transformer.close();
43
67
  }
44
68
  }
45
69
  };
46
70
  }
71
+ function extractInlineSourceMap(code, id) {
72
+ const sourceMapMatch = code.match(/\n?\/\/# sourceMappingURL=data:application\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\s*$/);
73
+ if (!sourceMapMatch || sourceMapMatch.index === void 0) return {
74
+ code,
75
+ map: null
76
+ };
77
+ return {
78
+ code: code.slice(0, sourceMapMatch.index),
79
+ map: Buffer.from(sourceMapMatch[1], "base64").toString()
80
+ };
81
+ }
47
82
  //#endregion
48
83
  export { buildOptimizerPlugin };
49
84
 
@@ -1 +1 @@
1
- {"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function buildOptimizerPlugin({\n jit,\n}: {\n supportedBrowsers: string[];\n jit: boolean;\n}): Plugin {\n const javascriptTransformer = new JavaScriptTransformer(\n {\n sourcemap: false,\n thirdPartySourcemaps: false,\n advancedOptimizations: true,\n jit: true,\n },\n 1,\n );\n let isProd = false;\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n apply: 'build',\n config(userConfig) {\n isProd =\n userConfig.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n const jsTransformConfigKey = getJsTransformConfigKey();\n\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n [jsTransformConfigKey]: {\n define: isProd\n ? {\n ngDevMode: 'false',\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : undefined,\n },\n } as UserConfig;\n },\n transform: {\n filter: {\n id: /\\.[cm]?js$/,\n },\n async handler(code, id) {\n const angularPackage = /fesm20/.test(id);\n\n if (!angularPackage) {\n return {\n code: isProd\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: {\n mappings: '',\n },\n };\n }\n\n const sideEffects =\n jit && id.includes('@angular/compiler') ? true : false;\n const result: Uint8Array = await javascriptTransformer.transformData(\n id,\n code,\n false,\n sideEffects,\n );\n\n return {\n code: Buffer.from(result).toString(),\n };\n },\n },\n };\n}\n"],"mappings":";;;AAIA,SAAgB,qBAAqB,EACnC,OAIS;CACT,MAAM,wBAAwB,IAAI,GAChC;EACE,WAAW;EACX,sBAAsB;EACtB,uBAAuB;EACvB,KAAK;EACN,EACD,EACD;CACD,IAAI,SAAS;AAEb,QAAO;EACL,MAAM;EACN,OAAO;EACP,OAAO,YAAY;AACjB,YACE,WAAW,SAAS,gBAAA,QAAA,IAAA,aACQ;GAC9B,MAAM,uBAAuB,yBAAyB;AAEtD,UAAO;IACL,QAAQ,SACJ;KACE,WAAW;KACX,mBAAmB;KACnB,WAAW;KACX,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;KACtC,GACD,EAAE;KACL,uBAAuB,EACtB,QAAQ,SACJ;KACE,WAAW;KACX,WAAW;KACX,mBAAmB;KACnB,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;KACtC,GACD,KAAA,GACL;IACF;;EAEH,WAAW;GACT,QAAQ,EACN,IAAI,cACL;GACD,MAAM,QAAQ,MAAM,IAAI;AAGtB,QAAI,CAFmB,SAAS,KAAK,GAAG,CAGtC,QAAO;KACL,MAAM,SACF,KAAK,QAAQ,sCAAsC,GAAG,GACtD;KACJ,KAAK,EACH,UAAU,IACX;KACF;IAGH,MAAM,cACJ,OAAO,GAAG,SAAS,oBAAoB,GAAG,OAAO;IACnD,MAAM,SAAqB,MAAM,sBAAsB,cACrD,IACA,MACA,OACA,YACD;AAED,WAAO,EACL,MAAM,OAAO,KAAK,OAAO,CAAC,UAAU,EACrC;;GAEJ;EACF"}
1
+ {"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode } from './utils/plugin-config.js';\n\nexport function buildOptimizerPlugin({\n jit,\n}: {\n supportedBrowsers: string[];\n jit: boolean;\n}): Plugin {\n const transformers = new Map<\n string,\n InstanceType<typeof JavaScriptTransformer>\n >();\n let isProd = false;\n let isWatch = false;\n let preserveVendorMaps = false;\n\n function getTransformer(envName = 'default') {\n let transformer = transformers.get(envName);\n if (!transformer) {\n transformer = new JavaScriptTransformer(\n {\n sourcemap: preserveVendorMaps,\n thirdPartySourcemaps: preserveVendorMaps,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\n transformers.set(envName, transformer);\n }\n return transformer;\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n // Normally build-only. Astro's Cloudflare integration (`@astrojs/cloudflare`)\n // transforms SSR modules through a serve-style `workerd` runner *during*\n // `astro build`; an `apply: 'build'` plugin is excluded from that pipeline,\n // so the Angular linker never runs on the worker's partially-compiled\n // packages and they fall back to the JIT compiler. Also apply under a\n // production `NODE_ENV` (which `astro build` sets) so the linker runs in\n // that runner too. Regular Analog dev servers run with a development\n // `NODE_ENV`, so their behavior is unchanged.\n apply(_config, env) {\n return (\n env.command === 'build' || process.env['NODE_ENV'] === 'production'\n );\n },\n config(userConfig) {\n isProd = isProdMode(userConfig.mode);\n // Advanced optimizations paired with dev-mode defines would strip\n // dev-only code the debug API needs, so both key off `isProd`.\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n } as UserConfig;\n },\n // The top-level define keys `ngServerMode` off the legacy `build.ssr`\n // flag. Environment API builds run the server through an environment\n // with `consumer: 'server'` while `build.ssr` stays unset, so give that\n // environment its own value; otherwise the guard compiles to `false`\n // and browser-only hydration features run during SSR.\n configEnvironment(_name, config) {\n if (isProd && config.consumer === 'server') {\n return { define: { ngServerMode: 'true' } };\n }\n return undefined;\n },\n configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\n isWatch = config.command === 'serve' || !!config.build?.watch;\n },\n transform: {\n filter: {\n // Allow an optional `?query` after the extension. Some environments\n // (e.g. Cloudflare's `workerd`, used by Astro's Cloudflare integration)\n // reference optimized deps with a `?v=<hash>` suffix, e.g.\n // `.../fesm2022/_platform_location-chunk.mjs?v=a786a9ff`. A `$`-anchored\n // extension match skips those, so the Angular linker never runs and the\n // partially-compiled package falls back to the JIT compiler at runtime.\n id: /\\.[cm]?js(?:\\?|$)/,\n },\n async handler(code, id) {\n // Strip the `?query` so the fesm check and the transformer see a real\n // filename rather than `foo.mjs?v=<hash>`.\n const cleanId = id.split('?')[0];\n const angularPackage = /fesm20/.test(cleanId);\n\n if (!angularPackage) {\n // `{ mappings: '' }` declares zero segments, dropping the module's own\n // map from the chain; `null` keeps it. Removing `sourceMappingURL` is\n // what makes that map unreachable, so it only runs when discarding.\n return {\n code:\n isProd && !preserveVendorMaps\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: preserveVendorMaps ? null : { mappings: '' },\n };\n }\n\n const sideEffects =\n jit && cleanId.includes('@angular/compiler') ? true : false;\n const envName = this.environment?.name ?? 'default';\n const transformer = getTransformer(envName);\n const result: Uint8Array = await transformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n const transformed = Buffer.from(result).toString();\n return preserveVendorMaps\n ? extractInlineSourceMap(transformed, cleanId)\n : { code: transformed, map: { mappings: '' } };\n },\n },\n async closeBundle() {\n if (isWatch) {\n return;\n }\n const envName = this.environment?.name ?? 'default';\n const transformer = transformers.get(envName);\n if (transformer) {\n transformers.delete(envName);\n await transformer.close();\n }\n },\n };\n}\n\nexport function extractInlineSourceMap(\n code: string,\n id: string,\n): { code: string; map: string | null } {\n const sourceMapMatch = code.match(\n /\\n?\\/\\/# sourceMappingURL=data:application\\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\\s*$/,\n );\n if (!sourceMapMatch || sourceMapMatch.index === undefined) {\n return {\n code,\n map: null,\n };\n }\n return {\n code: code.slice(0, sourceMapMatch.index),\n map: Buffer.from(sourceMapMatch[1]!, 'base64').toString(),\n };\n}\n"],"mappings":";;;AAIA,SAAgB,qBAAqB,EACnC,OAIS;CACT,MAAM,+BAAe,IAAI,KAGtB;CACH,IAAI,SAAS;CACb,IAAI,UAAU;CACd,IAAI,qBAAqB;CAEzB,SAAS,eAAe,UAAU,WAAW;EAC3C,IAAI,cAAc,aAAa,IAAI,QAAQ;AAC3C,MAAI,CAAC,aAAa;AAChB,iBAAc,IAAI,sBAChB;IACE,WAAW;IACX,sBAAsB;IACtB,uBAAuB;IACvB,KAAK;IACN,EACD,EACD;AACD,gBAAa,IAAI,SAAS,YAAY;;AAExC,SAAO;;AAGT,QAAO;EACL,MAAM;EASN,MAAM,SAAS,KAAK;AAClB,UACE,IAAI,YAAY,WAAA,QAAA,IAAA,aAAuC;;EAG3D,OAAO,YAAY;AACjB,YAAS,WAAW,WAAW,KAAK;AAGpC,UAAO,EACL,QAAQ,SACJ;IACE,WAAW;IACX,mBAAmB;IACnB,WAAW;IACX,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;IACtC,GACD,EAAE,EACP;;EAOH,kBAAkB,OAAO,QAAQ;AAC/B,OAAI,UAAU,OAAO,aAAa,SAChC,QAAO,EAAE,QAAQ,EAAE,cAAc,QAAQ,EAAE;;EAI/C,eAAe,QAAQ;AACrB,wBAAqB,CAAC,CAAC,OAAO,MAAM;AACpC,aAAU,OAAO,YAAY,WAAW,CAAC,CAAC,OAAO,OAAO;;EAE1D,WAAW;GACT,QAAQ,EAON,IAAI,qBACL;GACD,MAAM,QAAQ,MAAM,IAAI;IAGtB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC;AAG9B,QAAI,CAFmB,SAAS,KAAK,QAAQ,CAM3C,QAAO;KACL,MACE,UAAU,CAAC,qBACP,KAAK,QAAQ,sCAAsC,GAAG,GACtD;KACN,KAAK,qBAAqB,OAAO,EAAE,UAAU,IAAI;KAClD;IAGH,MAAM,cACJ,OAAO,QAAQ,SAAS,oBAAoB,GAAG,OAAO;IAGxD,MAAM,SAAqB,MADP,eADJ,KAAK,aAAa,QAAQ,UACC,CACE,cAC3C,SACA,MACA,OACA,YACD;IAED,MAAM,cAAc,OAAO,KAAK,OAAO,CAAC,UAAU;AAClD,WAAO,qBACH,uBAAuB,aAAa,QAAQ,GAC5C;KAAE,MAAM;KAAa,KAAK,EAAE,UAAU,IAAI;KAAE;;GAEnD;EACD,MAAM,cAAc;AAClB,OAAI,QACF;GAEF,MAAM,UAAU,KAAK,aAAa,QAAQ;GAC1C,MAAM,cAAc,aAAa,IAAI,QAAQ;AAC7C,OAAI,aAAa;AACf,iBAAa,OAAO,QAAQ;AAC5B,UAAM,YAAY,OAAO;;;EAG9B;;AAGH,SAAgB,uBACd,MACA,IACsC;CACtC,MAAM,iBAAiB,KAAK,MAC1B,oGACD;AACD,KAAI,CAAC,kBAAkB,eAAe,UAAU,KAAA,EAC9C,QAAO;EACL;EACA,KAAK;EACN;AAEH,QAAO;EACL,MAAM,KAAK,MAAM,GAAG,eAAe,MAAM;EACzC,KAAK,OAAO,KAAK,eAAe,IAAK,SAAS,CAAC,UAAU;EAC1D"}
@@ -1,4 +1,4 @@
1
- import { Plugin } from 'vite';
2
- export declare function jitPlugin({ inlineStylesExtension, }: {
3
- inlineStylesExtension: string;
1
+ import { Plugin } from "vite";
2
+ export declare function jitPlugin({ inlineStylesExtension }: {
3
+ inlineStylesExtension: string;
4
4
  }): Plugin;
@@ -1,29 +1,51 @@
1
+ import { debugStyles } from "./utils/debug.js";
2
+ import { preprocessStylesheet } from "./stylesheet-registry.js";
3
+ import { discoverAnalogIntegrations } from "./analog-plugin-interop.js";
4
+ import { getJitInlineStyles } from "./utils/jit-inline-styles.js";
5
+ import { releaseCssPreprocessorWorkers } from "./utils/css-preprocessor-workers.js";
1
6
  import { preprocessCSS } from "vite";
2
- import { createHash } from "node:crypto";
3
7
  //#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
4
8
  function jitPlugin({ inlineStylesExtension }) {
5
9
  let config;
10
+ let stylePreprocessor;
6
11
  return {
7
12
  name: "@analogjs/vite-plugin-angular-jit",
8
13
  configResolved(_config) {
9
14
  config = _config;
10
15
  },
16
+ async buildStart() {
17
+ stylePreprocessor = (await discoverAnalogIntegrations(config)).stylePreprocessor;
18
+ },
11
19
  resolveId(id) {
12
20
  if (id.startsWith("virtual:angular")) return `\0${id}`;
13
21
  },
14
22
  async load(id) {
15
23
  if (id.includes("virtual:angular:jit:style:inline;")) {
16
- const styleId = id.split("style:inline;")[1];
17
- const styleIdHash = createHash("sha256").update(styleId).digest("hex").slice(0, 16);
18
- const decodedStyles = Buffer.from(decodeURIComponent(styleId), "base64").toString();
24
+ const styleIdHash = id.split("style:inline;")[1];
25
+ const encodedStyles = getJitInlineStyles(styleIdHash);
26
+ if (encodedStyles === void 0) return;
27
+ const decodedStyles = Buffer.from(decodeURIComponent(encodedStyles), "base64").toString();
28
+ const filename = `${styleIdHash}.${inlineStylesExtension}`;
29
+ const preprocessed = preprocessStylesheet(decodedStyles, filename, stylePreprocessor, {
30
+ filename,
31
+ inline: true
32
+ });
19
33
  let styles = "";
20
34
  try {
21
- styles = (await preprocessCSS(decodedStyles, `${styleIdHash}.${inlineStylesExtension}?direct`, config))?.code;
35
+ styles = (await preprocessCSS(preprocessed, `${filename}?direct`, config))?.code;
22
36
  } catch (e) {
23
- console.error(`${e}`);
37
+ const errorMessage = e instanceof Error ? e.message : String(e);
38
+ debugStyles("jit css compilation error", {
39
+ styleIdHash,
40
+ error: errorMessage
41
+ });
42
+ console.warn("[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s", styleIdHash, errorMessage);
24
43
  }
25
44
  return `export default \`${styles}\``;
26
45
  }
46
+ },
47
+ closeBundle() {
48
+ if (!this.meta?.watchMode) releaseCssPreprocessorWorkers();
27
49
  }
28
50
  };
29
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes('virtual:angular:jit:style:inline;')) {\n const styleId = id.split('style:inline;')[1];\n // styleId may exceed 255 bytes of base64-encoded content, limit to 16\n const styleIdHash = createHash('sha256')\n .update(styleId)\n .digest('hex')\n .slice(0, 16);\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(styleId),\n 'base64',\n ).toString();\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n decodedStyles,\n `${styleIdHash}.${inlineStylesExtension}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n console.error(`${e}`);\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAS,oCAAoC,EAAE;IACpD,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC;IAE1C,MAAM,cAAc,WAAW,SAAS,CACrC,OAAO,QAAQ,CACf,OAAO,MAAM,CACb,MAAM,GAAG,GAAG;IAEf,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,QAAQ,EAC3B,SACD,CAAC,UAAU;IAEZ,IAAI,SAA6B;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,eACA,GAAG,YAAY,GAAG,sBAAsB,UACxC,OACD,GACkB;aACZ,GAAG;AACV,aAAQ,MAAM,GAAG,IAAI;;AAGvB,WAAO,oBAAoB,OAAO;;;EAKvC"}
1
+ {"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n} from './utils/jit-inline-styles.js';\nimport { debugStyles } from './utils/debug.js';\nimport { discoverAnalogIntegrations } from './analog-plugin-interop.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n let stylePreprocessor: StylePreprocessor | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n async buildStart() {\n stylePreprocessor = (await discoverAnalogIntegrations(config))\n .stylePreprocessor;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes(JIT_INLINE_STYLE_PREFIX)) {\n const styleIdHash = id.split('style:inline;')[1];\n const encodedStyles = getJitInlineStyles(styleIdHash);\n\n if (encodedStyles === undefined) {\n return;\n }\n\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n const filename = `${styleIdHash}.${inlineStylesExtension}`;\n const preprocessed = preprocessStylesheet(\n decodedStyles,\n filename,\n stylePreprocessor,\n { filename, inline: true },\n );\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n preprocessed,\n `${filename}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n debugStyles('jit css compilation error', {\n styleIdHash,\n error: errorMessage,\n });\n console.warn(\n '[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s',\n styleIdHash,\n errorMessage,\n );\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n closeBundle() {\n if (!this.meta?.watchMode) {\n releaseCssPreprocessorWorkers();\n }\n },\n };\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;CACJ,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,eAAe,SAAS;AACtB,YAAS;;EAEX,MAAM,aAAa;AACjB,wBAAqB,MAAM,2BAA2B,OAAO,EAC1D;;EAEL,UAAU,IAAY;AACpB,OAAI,GAAG,WAAW,kBAAkB,CAClC,QAAO,KAAK;;EAKhB,MAAM,KAAK,IAAY;AACrB,OAAI,GAAG,SAAA,oCAAiC,EAAE;IACxC,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC;IAC9C,MAAM,gBAAgB,mBAAmB,YAAY;AAErD,QAAI,kBAAkB,KAAA,EACpB;IAGF,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,cAAc,EACjC,SACD,CAAC,UAAU;IACZ,MAAM,WAAW,GAAG,YAAY,GAAG;IACnC,MAAM,eAAe,qBACnB,eACA,UACA,mBACA;KAAE;KAAU,QAAQ;KAAM,CAC3B;IAED,IAAI,SAA6B;AAEjC,QAAI;AAMF,eALiB,MAAM,cACrB,cACA,GAAG,SAAS,UACZ,OACD,GACkB;aACZ,GAAG;KACV,MAAM,eAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;AAC/D,iBAAY,6BAA6B;MACvC;MACA,OAAO;MACR,CAAC;AACF,aAAQ,KACN,6HACA,aACA,aACD;;AAGH,WAAO,oBAAoB,OAAO;;;EAKtC,cAAc;AACZ,OAAI,CAAC,KAAK,MAAM,UACd,gCAA+B;;EAGpC"}
@@ -1,9 +1,9 @@
1
- import { Plugin } from 'vite';
1
+ import { Plugin } from "vite";
2
2
  /**
3
- * This plugin is a workaround for the ɵPendingTasks symbol being renamed
4
- * to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of
5
- * Angular with Analog that used the ɵPendingTasks symbol.
6
- *
7
- * Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4
8
- */
3
+ * This plugin is a workaround for the ɵPendingTasks symbol being renamed
4
+ * to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of
5
+ * Angular with Analog that used the ɵPendingTasks symbol.
6
+ *
7
+ * Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4
8
+ */
9
9
  export declare function pendingTasksPlugin(): Plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"angular-pending-tasks.plugin.js","names":[],"sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-pending-tasks.plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\n\nimport { angularFullVersion } from './utils/devkit.js';\n\n/**\n * This plugin is a workaround for the ɵPendingTasks symbol being renamed\n * to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of\n * Angular with Analog that used the ɵPendingTasks symbol.\n *\n * Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4\n */\nexport function pendingTasksPlugin(): Plugin {\n return {\n name: 'analogjs-pending-tasks-plugin',\n transform(code, id) {\n if (id.includes('analogjs-content.mjs')) {\n return {\n code: code.replace('ɵPendingTasksInternal', 'ɵPendingTasks'),\n };\n }\n return;\n },\n };\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,qBAA6B;AAC3C,QAAO;EACL,MAAM;EACN,UAAU,MAAM,IAAI;AAClB,OAAI,GAAG,SAAS,uBAAuB,CACrC,QAAO,EACL,MAAM,KAAK,QAAQ,yBAAyB,gBAAgB,EAC7D;;EAIN"}
1
+ {"version":3,"file":"angular-pending-tasks.plugin.js","names":[],"sources":["../../../src/lib/angular-pending-tasks.plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\n\nimport { angularFullVersion } from './utils/devkit.js';\n\n/**\n * This plugin is a workaround for the ɵPendingTasks symbol being renamed\n * to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of\n * Angular with Analog that used the ɵPendingTasks symbol.\n *\n * Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4\n */\nexport function pendingTasksPlugin(): Plugin {\n return {\n name: 'analogjs-pending-tasks-plugin',\n transform(code, id) {\n if (id.includes('analogjs-content.mjs')) {\n return {\n code: code.replace('ɵPendingTasksInternal', 'ɵPendingTasks'),\n };\n }\n return;\n },\n };\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,qBAA6B;AAC3C,QAAO;EACL,MAAM;EACN,UAAU,MAAM,IAAI;AAClB,OAAI,GAAG,SAAS,uBAAuB,CACrC,QAAO,EACL,MAAM,KAAK,QAAQ,yBAAyB,gBAAgB,EAC7D;;EAIN"}
@@ -1,76 +1,86 @@
1
- import { NgtscProgram } from '@angular/compiler-cli';
2
- import * as ts from 'typescript';
3
- import { Plugin } from 'vite';
4
- import { FileReplacement } from './plugins/file-replacements.plugin.js';
5
- export declare enum DiagnosticModes {
6
- None = 0,
7
- Option = 1,
8
- Syntactic = 2,
9
- Semantic = 4,
10
- All = 7
11
- }
1
+ import { NgtscProgram } from "@angular/compiler-cli";
2
+ import * as ts from "typescript";
3
+ import { ModuleNode, Plugin, ViteDevServer } from "vite";
4
+ import { type DebugOption } from "./utils/debug.js";
5
+ import { FileReplacement } from "./plugins/file-replacements.plugin.js";
6
+ import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
7
+ export { DiagnosticModes, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, toAngularCompilationFileReplacements, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, describeStylesheetContent, isTestWatchMode } from "./utils/compilation-shared.js";
12
8
  export interface PluginOptions {
13
- tsconfig?: string | (() => string);
14
- workspaceRoot?: string;
15
- inlineStylesExtension?: string;
16
- jit?: boolean;
17
- advanced?: {
18
- /**
19
- * Custom TypeScript transformers that are run before Angular compilation
20
- */
21
- tsTransformers?: ts.CustomTransformers;
22
- };
23
- supportedBrowsers?: string[];
24
- transformFilter?: (code: string, id: string) => boolean;
25
- /**
26
- * Additional files to include in compilation
27
- */
28
- include?: string[];
29
- additionalContentDirs?: string[];
30
- liveReload?: boolean;
31
- disableTypeChecking?: boolean;
32
- fileReplacements?: FileReplacement[];
33
- experimental?: {
34
- useAngularCompilationAPI?: boolean;
35
- };
9
+ tsconfig?: string | (() => string);
10
+ workspaceRoot?: string;
11
+ inlineStylesExtension?: string;
12
+ jit?: boolean;
13
+ supportedBrowsers?: string[];
14
+ /**
15
+ * Additional files to include in compilation
16
+ */
17
+ include?: string[];
18
+ /**
19
+ * Enables Analog's Angular live-reload/HMR pipeline during development/watch mode.
20
+ *
21
+ * This is separate from Vite's `server.hmr` option, which configures the
22
+ * HMR client transport.
23
+ *
24
+ * Defaults to `true` for watch mode. Set to `false` to disable Angular
25
+ * reload updates while keeping other stylesheet externalization behavior
26
+ * available when needed.
27
+ */
28
+ liveReload?: boolean;
29
+ disableTypeChecking?: boolean;
30
+ fileReplacements?: FileReplacement[];
31
+ /**
32
+ * Opt into the fast compile path. Skips Angular's template type-checking
33
+ * and routes compilation through an internal single-pass transform.
34
+ * Defaults to `false`.
35
+ */
36
+ fastCompile?: boolean;
37
+ /**
38
+ * Compilation output mode used when `fastCompile` is enabled.
39
+ * - `'full'` (default): Emit final Ivy definitions for application builds.
40
+ * - `'partial'`: Emit partial declarations for library publishing.
41
+ */
42
+ fastCompileMode?: "full" | "partial";
43
+ /**
44
+ * Enable debug logging for specific scopes.
45
+ *
46
+ * - `true` → enables all `analog:angular:*` scopes
47
+ * - `string[]` → enables listed namespaces (e.g. `['analog:angular:hmr']`)
48
+ * - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
49
+ * to restrict output to a specific Vite command (omit for both)
50
+ *
51
+ * Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`
52
+ * (browser), using the `obug` convention.
53
+ */
54
+ debug?: DebugOption;
36
55
  }
56
+ export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
57
+ classNamesMap: Map<string, string>;
58
+ fileTransformMap: Map<string, string>;
59
+ }): void;
37
60
  export declare function angular(options?: PluginOptions): Plugin[];
38
61
  export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
39
62
  /**
40
- * Convert Analog/Angular CLI-style file replacements into the flat record
41
- * expected by `AngularHostOptions.fileReplacements`.
42
- *
43
- * Only browser replacements (`{ replace, with }`) are converted. SSR-only
44
- * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to
45
- * handle — they should not be baked into the Angular compilation host because
46
- * that would apply them to both browser and server builds.
47
- *
48
- * Relative paths are resolved against `workspaceRoot` so that the host
49
- * receives the same absolute paths it would get from the Angular CLI.
50
- */
51
- export declare function toAngularCompilationFileReplacements(replacements: FileReplacement[], workspaceRoot: string): Record<string, string> | undefined;
63
+ * Returns every live Vite module that can legitimately represent a changed
64
+ * Angular resource file.
65
+ *
66
+ * For normal files, `getModulesByFile()` is enough. For Angular component
67
+ * stylesheets, it is not: the browser often holds virtual hashed requests
68
+ * (`/abc123.css?direct&ngcomp=...` and `/abc123.css?ngcomp=...`) that are no
69
+ * longer discoverable from the original source path alone. We therefore merge:
70
+ * - watcher event modules
71
+ * - module-graph modules by source file
72
+ * - registry-tracked live request ids resolved back through the module graph
73
+ */
74
+ export declare function getModulesForChangedFile(server: ViteDevServer, file: string, eventModules?: readonly ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
75
+ export declare function isModuleForChangedResource(mod: ModuleNode, changedFile: string, stylesheetRegistry?: AnalogStylesheetRegistry): boolean;
76
+ export declare function findComponentStylesheetWrapperModules(server: ViteDevServer, changedFile: string, directModule: ModuleNode, fileModules: ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
77
+ export declare function findTemplateOwnerModules(server: ViteDevServer, resourceFile: string): ModuleNode[];
52
78
  /**
53
- * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)
54
- * back to absolute file paths with their associated HMR code and component
55
- * class name.
56
- *
57
- * Angular's private Compilation API emits template update keys in the form
58
- * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve
59
- * them so the caller can look up updates by the same normalized absolute path
60
- * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
61
- */
62
- export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap<string, string> | undefined): Map<string, {
63
- className: string;
64
- code: string;
65
- }>;
66
- export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram['compiler'], liveReload?: boolean, disableTypeChecking?: boolean): (file: string) => {
67
- errors?: string[];
68
- warnings?: (string | ts.DiagnosticMessageChain)[];
69
- hmrUpdateCode?: string | null;
70
- hmrEligible?: boolean;
79
+ * @internal
80
+ */
81
+ export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean): (file: string) => {
82
+ errors?: string[];
83
+ warnings?: (string | ts.DiagnosticMessageChain)[];
84
+ hmrUpdateCode?: string | null;
85
+ hmrEligible?: boolean;
71
86
  };
72
- /**
73
- * Checks for vitest run from the command line
74
- * @returns boolean
75
- */
76
- export declare function isTestWatchMode(args?: string[]): boolean;