@analogjs/vite-plugin-angular 3.0.0-alpha.7 → 3.0.0-alpha.71

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 (203) hide show
  1. package/README.md +30 -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 +51 -12
  11. package/src/index.d.ts +5 -2
  12. package/src/index.js +6 -2
  13. package/src/index.js.map +1 -1
  14. package/src/lib/analog-plugin-interop.d.ts +40 -0
  15. package/src/lib/analog-plugin-interop.js +61 -0
  16. package/src/lib/analog-plugin-interop.js.map +1 -0
  17. package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
  18. package/src/lib/angular-build-optimizer-plugin.js +57 -62
  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 +51 -37
  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 +17 -18
  25. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  26. package/src/lib/angular-vite-plugin.d.ts +177 -69
  27. package/src/lib/angular-vite-plugin.js +1227 -1084
  28. package/src/lib/angular-vite-plugin.js.map +1 -1
  29. package/src/lib/angular-vitest-plugin.d.ts +26 -17
  30. package/src/lib/angular-vitest-plugin.js +106 -114
  31. package/src/lib/angular-vitest-plugin.js.map +1 -1
  32. package/src/lib/compilation-api/compilation-api-plugin.d.ts +29 -0
  33. package/src/lib/compilation-api/compilation-api-plugin.js +491 -0
  34. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
  35. package/src/lib/compilation-api/index.d.ts +1 -0
  36. package/src/lib/compilation-api/index.js +1 -0
  37. package/src/lib/compiler/angular-version.d.ts +19 -0
  38. package/src/lib/compiler/angular-version.js +31 -0
  39. package/src/lib/compiler/angular-version.js.map +1 -0
  40. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  41. package/src/lib/compiler/class-field-lowering.js +131 -0
  42. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  43. package/src/lib/compiler/compile.d.ts +50 -0
  44. package/src/lib/compiler/compile.js +814 -0
  45. package/src/lib/compiler/compile.js.map +1 -0
  46. package/src/lib/compiler/constants.d.ts +24 -0
  47. package/src/lib/compiler/constants.js +59 -0
  48. package/src/lib/compiler/constants.js.map +1 -0
  49. package/src/lib/compiler/debug.d.ts +22 -0
  50. package/src/lib/compiler/debug.js +20 -0
  51. package/src/lib/compiler/debug.js.map +1 -0
  52. package/src/lib/compiler/defer.d.ts +57 -0
  53. package/src/lib/compiler/defer.js +154 -0
  54. package/src/lib/compiler/defer.js.map +1 -0
  55. package/src/lib/compiler/dts-reader.d.ts +45 -0
  56. package/src/lib/compiler/dts-reader.js +395 -0
  57. package/src/lib/compiler/dts-reader.js.map +1 -0
  58. package/src/lib/compiler/hmr.d.ts +16 -0
  59. package/src/lib/compiler/hmr.js +69 -0
  60. package/src/lib/compiler/hmr.js.map +1 -0
  61. package/src/lib/compiler/index.d.ts +8 -0
  62. package/src/lib/compiler/index.js +8 -0
  63. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  64. package/src/lib/compiler/jit-metadata.js +168 -0
  65. package/src/lib/compiler/jit-metadata.js.map +1 -0
  66. package/src/lib/compiler/jit-transform.d.ts +24 -0
  67. package/src/lib/compiler/jit-transform.js +204 -0
  68. package/src/lib/compiler/jit-transform.js.map +1 -0
  69. package/src/lib/compiler/js-emitter.d.ts +10 -0
  70. package/src/lib/compiler/js-emitter.js +446 -0
  71. package/src/lib/compiler/js-emitter.js.map +1 -0
  72. package/src/lib/compiler/metadata.d.ts +36 -0
  73. package/src/lib/compiler/metadata.js +710 -0
  74. package/src/lib/compiler/metadata.js.map +1 -0
  75. package/src/lib/compiler/registry.d.ts +56 -0
  76. package/src/lib/compiler/registry.js +176 -0
  77. package/src/lib/compiler/registry.js.map +1 -0
  78. package/src/lib/compiler/resource-inliner.d.ts +43 -0
  79. package/src/lib/compiler/resource-inliner.js +230 -0
  80. package/src/lib/compiler/resource-inliner.js.map +1 -0
  81. package/src/lib/compiler/style-ast.d.ts +9 -0
  82. package/src/lib/compiler/style-ast.js +54 -0
  83. package/src/lib/compiler/style-ast.js.map +1 -0
  84. package/src/lib/compiler/styles.d.ts +13 -0
  85. package/src/lib/compiler/test-helpers.d.ts +7 -0
  86. package/src/lib/compiler/type-elision.d.ts +28 -0
  87. package/src/lib/compiler/type-elision.js +211 -0
  88. package/src/lib/compiler/type-elision.js.map +1 -0
  89. package/src/lib/compiler/utils.d.ts +40 -0
  90. package/src/lib/compiler/utils.js +76 -0
  91. package/src/lib/compiler/utils.js.map +1 -0
  92. package/src/lib/compiler-plugin.d.ts +13 -12
  93. package/src/lib/compiler-plugin.js +40 -44
  94. package/src/lib/compiler-plugin.js.map +1 -1
  95. package/src/lib/component-resolvers.d.ts +23 -5
  96. package/src/lib/component-resolvers.js +107 -64
  97. package/src/lib/component-resolvers.js.map +1 -1
  98. package/src/lib/encapsulation-plugin.d.ts +13 -0
  99. package/src/lib/encapsulation-plugin.js +48 -0
  100. package/src/lib/encapsulation-plugin.js.map +1 -0
  101. package/src/lib/fast-compile-plugin.d.ts +28 -0
  102. package/src/lib/fast-compile-plugin.js +414 -0
  103. package/src/lib/fast-compile-plugin.js.map +1 -0
  104. package/src/lib/host.d.ts +10 -8
  105. package/src/lib/host.js +113 -101
  106. package/src/lib/host.js.map +1 -1
  107. package/src/lib/live-reload-plugin.d.ts +5 -5
  108. package/src/lib/live-reload-plugin.js +61 -63
  109. package/src/lib/live-reload-plugin.js.map +1 -1
  110. package/src/lib/models.d.ts +9 -9
  111. package/src/lib/nx-folder-plugin.d.ts +5 -5
  112. package/src/lib/nx-folder-plugin.js +18 -16
  113. package/src/lib/nx-folder-plugin.js.map +1 -1
  114. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  115. package/src/lib/plugins/file-replacements.plugin.js +40 -62
  116. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  117. package/src/lib/router-plugin.d.ts +1 -1
  118. package/src/lib/router-plugin.js +35 -23
  119. package/src/lib/router-plugin.js.map +1 -1
  120. package/src/lib/style-pipeline.d.ts +15 -0
  121. package/src/lib/style-pipeline.js +31 -0
  122. package/src/lib/style-pipeline.js.map +1 -0
  123. package/src/lib/style-preprocessor.d.ts +35 -0
  124. package/src/lib/style-preprocessor.js +35 -0
  125. package/src/lib/style-preprocessor.js.map +1 -0
  126. package/src/lib/stylesheet-registry.d.ts +74 -0
  127. package/src/lib/stylesheet-registry.js +174 -0
  128. package/src/lib/stylesheet-registry.js.map +1 -0
  129. package/src/lib/tailwind-plugin.d.ts +34 -0
  130. package/src/lib/tailwind-plugin.js +116 -0
  131. package/src/lib/tailwind-plugin.js.map +1 -0
  132. package/src/lib/tools/package.json +2 -7
  133. package/src/lib/tools/src/builders/vite/vite-build.impl.js +33 -38
  134. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  135. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +51 -62
  136. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  137. package/src/lib/tools/src/index.js +0 -2
  138. package/src/lib/utils/compilation-shared.d.ts +62 -0
  139. package/src/lib/utils/compilation-shared.js +138 -0
  140. package/src/lib/utils/compilation-shared.js.map +1 -0
  141. package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
  142. package/src/lib/utils/css-extension-resolver.d.ts +32 -0
  143. package/src/lib/utils/css-extension-resolver.js +73 -0
  144. package/src/lib/utils/css-extension-resolver.js.map +1 -0
  145. package/src/lib/utils/debug-harness.d.ts +23 -0
  146. package/src/lib/utils/debug-harness.js +88 -0
  147. package/src/lib/utils/debug-harness.js.map +1 -0
  148. package/src/lib/utils/debug-log-file.d.ts +5 -0
  149. package/src/lib/utils/debug-log-file.js +56 -0
  150. package/src/lib/utils/debug-log-file.js.map +1 -0
  151. package/src/lib/utils/debug.d.ts +28 -0
  152. package/src/lib/utils/debug.js +39 -0
  153. package/src/lib/utils/debug.js.map +1 -0
  154. package/src/lib/utils/devkit.d.ts +6 -6
  155. package/src/lib/utils/devkit.js +34 -38
  156. package/src/lib/utils/devkit.js.map +1 -1
  157. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  158. package/src/lib/utils/jit-inline-styles.d.ts +3 -0
  159. package/src/lib/utils/jit-inline-styles.js +16 -0
  160. package/src/lib/utils/jit-inline-styles.js.map +1 -0
  161. package/src/lib/utils/plugin-config.d.ts +41 -0
  162. package/src/lib/utils/plugin-config.js +85 -0
  163. package/src/lib/utils/plugin-config.js.map +1 -0
  164. package/src/lib/utils/rolldown.d.ts +2 -0
  165. package/src/lib/utils/rolldown.js +12 -0
  166. package/src/lib/utils/rolldown.js.map +1 -0
  167. package/src/lib/utils/safe-module-paths.d.ts +16 -0
  168. package/src/lib/utils/safe-module-paths.js +29 -0
  169. package/src/lib/utils/safe-module-paths.js.map +1 -0
  170. package/src/lib/utils/source-file-cache.d.ts +8 -15
  171. package/src/lib/utils/source-file-cache.js +35 -37
  172. package/src/lib/utils/source-file-cache.js.map +1 -1
  173. package/src/lib/utils/tailwind-reference.d.ts +12 -0
  174. package/src/lib/utils/tailwind-reference.js +99 -0
  175. package/src/lib/utils/tailwind-reference.js.map +1 -0
  176. package/src/lib/utils/transform-cache.d.ts +43 -0
  177. package/src/lib/utils/transform-cache.js +97 -0
  178. package/src/lib/utils/transform-cache.js.map +1 -0
  179. package/src/lib/utils/tsconfig-resolver.d.ts +28 -0
  180. package/src/lib/utils/tsconfig-resolver.js +191 -0
  181. package/src/lib/utils/tsconfig-resolver.js.map +1 -0
  182. package/src/lib/utils/virtual-ids.d.ts +4 -0
  183. package/src/lib/utils/virtual-ids.js +23 -0
  184. package/src/lib/utils/virtual-ids.js.map +1 -0
  185. package/src/lib/utils/virtual-resources.d.ts +19 -0
  186. package/src/lib/utils/virtual-resources.js +38 -0
  187. package/src/lib/utils/virtual-resources.js.map +1 -0
  188. package/src/lib/virtual-modules-plugin.d.ts +5 -0
  189. package/src/lib/virtual-modules-plugin.js +23 -0
  190. package/src/lib/virtual-modules-plugin.js.map +1 -0
  191. package/src/test-setup.d.ts +2 -0
  192. package/setup-vitest.d.ts +0 -4
  193. package/setup-vitest.js +0 -215
  194. package/setup-vitest.js.map +0 -1
  195. package/src/lib/models.js +0 -1
  196. package/src/lib/models.js.map +0 -1
  197. package/src/lib/tools/README.md +0 -3
  198. package/src/lib/tools/src/index.d.ts +0 -0
  199. package/src/lib/tools/src/index.js.map +0 -1
  200. package/src/lib/utils/compiler-plugin-options.js +0 -1
  201. package/src/lib/utils/compiler-plugin-options.js.map +0 -1
  202. package/src/lib/utils/hmr-candidates.js +0 -272
  203. package/src/lib/utils/hmr-candidates.js.map +0 -1
@@ -1,39 +1,53 @@
1
- import { createHash } from 'node:crypto';
2
- import { preprocessCSS } from 'vite';
3
- export function jitPlugin({ inlineStylesExtension, }) {
4
- let config;
5
- return {
6
- name: '@analogjs/vite-plugin-angular-jit',
7
- configResolved(_config) {
8
- config = _config;
9
- },
10
- resolveId(id) {
11
- if (id.startsWith('virtual:angular')) {
12
- return `\0${id}`;
13
- }
14
- return;
15
- },
16
- async load(id) {
17
- if (id.includes('virtual:angular:jit:style:inline;')) {
18
- const styleId = id.split('style:inline;')[1];
19
- // styleId may exceed 255 bytes of base64-encoded content, limit to 16
20
- const styleIdHash = createHash('sha256')
21
- .update(styleId)
22
- .digest('hex')
23
- .slice(0, 16);
24
- const decodedStyles = Buffer.from(decodeURIComponent(styleId), 'base64').toString();
25
- let styles = '';
26
- try {
27
- const compiled = await preprocessCSS(decodedStyles, `${styleIdHash}.${inlineStylesExtension}?direct`, config);
28
- styles = compiled?.code;
29
- }
30
- catch (e) {
31
- console.error(`${e}`);
32
- }
33
- return `export default \`${styles}\``;
34
- }
35
- return;
36
- },
37
- };
1
+ import { getJitInlineStyles } from "./utils/jit-inline-styles.js";
2
+ import { debugStyles } from "./utils/debug.js";
3
+ import { isTailwindReferenceError } from "./utils/tailwind-reference.js";
4
+ import { resolveStylePreprocessor } from "./analog-plugin-interop.js";
5
+ import { preprocessStylesheet } from "./stylesheet-registry.js";
6
+ import { preprocessCSS } from "vite";
7
+ //#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
8
+ function jitPlugin({ inlineStylesExtension }) {
9
+ let config;
10
+ let stylePreprocessor;
11
+ return {
12
+ name: "@analogjs/vite-plugin-angular-jit",
13
+ configResolved(_config) {
14
+ config = _config;
15
+ },
16
+ async buildStart() {
17
+ stylePreprocessor = await resolveStylePreprocessor(config);
18
+ },
19
+ resolveId(id) {
20
+ if (id.startsWith("virtual:angular")) return `\0${id}`;
21
+ },
22
+ async load(id) {
23
+ if (id.includes("virtual:angular:jit:style:inline;")) {
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
+ });
33
+ let styles = "";
34
+ try {
35
+ styles = (await preprocessCSS(preprocessed, `${filename}?direct`, config))?.code;
36
+ } catch (e) {
37
+ if (isTailwindReferenceError(e)) throw e;
38
+ const errorMessage = e instanceof Error ? e.message : String(e);
39
+ debugStyles("jit css compilation error", {
40
+ styleIdHash,
41
+ error: errorMessage
42
+ });
43
+ console.warn("[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s", styleIdHash, errorMessage);
44
+ }
45
+ return `export default \`${styles}\``;
46
+ }
47
+ }
48
+ };
38
49
  }
50
+ //#endregion
51
+ export { jitPlugin };
52
+
39
53
  //# sourceMappingURL=angular-jit-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"angular-jit-plugin.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAA0B,aAAa,EAAE,MAAM,MAAM,CAAC;AAE7D,MAAM,UAAU,SAAS,CAAC,EACxB,qBAAqB,GAGtB;IACC,IAAI,MAAsB,CAAC;IAE3B,OAAO;QACL,IAAI,EAAE,mCAAmC;QACzC,cAAc,CAAC,OAAO;YACpB,MAAM,GAAG,OAAO,CAAC;QACnB,CAAC;QACD,SAAS,CAAC,EAAU;YAClB,IAAI,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACrC,OAAO,KAAK,EAAE,EAAE,CAAC;YACnB,CAAC;YAED,OAAO;QACT,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAU;YACnB,IAAI,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC,EAAE,CAAC;gBACrD,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7C,sEAAsE;gBACtE,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC;qBACrC,MAAM,CAAC,OAAO,CAAC;qBACf,MAAM,CAAC,KAAK,CAAC;qBACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAEhB,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAC/B,kBAAkB,CAAC,OAAO,CAAC,EAC3B,QAAQ,CACT,CAAC,QAAQ,EAAE,CAAC;gBAEb,IAAI,MAAM,GAAuB,EAAE,CAAC;gBAEpC,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,MAAM,aAAa,CAClC,aAAa,EACb,GAAG,WAAW,IAAI,qBAAqB,SAAS,EAChD,MAAM,CACP,CAAC;oBACF,MAAM,GAAG,QAAQ,EAAE,IAAI,CAAC;gBAC1B,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACxB,CAAC;gBAED,OAAO,oBAAoB,MAAM,IAAI,CAAC;YACxC,CAAC;YAED,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
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 { isTailwindReferenceError } from './utils/tailwind-reference.js';\nimport { resolveStylePreprocessor } from './analog-plugin-interop.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { StylePreprocessor } from './style-preprocessor.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 resolveStylePreprocessor(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(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 if (isTailwindReferenceError(e)) {\n throw e;\n }\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 };\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,uBAAoB,MAAM,yBAAyB,OAAO;;EAE5D,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;AACV,SAAI,yBAAyB,EAAE,CAC7B,OAAM;KAER,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;;;EAKvC"}
@@ -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,21 +1,20 @@
1
+ //#region packages/vite-plugin-angular/src/lib/angular-pending-tasks.plugin.ts
1
2
  /**
2
- * This plugin is a workaround for the ɵPendingTasks symbol being renamed
3
- * to ɵPendingTasksInternal in Angular v19.0.4. The symbol is renamed to support previous versions of
4
- * Angular with Analog that used the ɵPendingTasks symbol.
5
- *
6
- * Commmit: https://github.com/angular/angular/commit/24e317cb157bf1ef159ed8554f1b79cb3443edf4
7
- */
8
- export function pendingTasksPlugin() {
9
- return {
10
- name: 'analogjs-pending-tasks-plugin',
11
- transform(code, id) {
12
- if (id.includes('analogjs-content.mjs')) {
13
- return {
14
- code: code.replace('ɵPendingTasksInternal', 'ɵPendingTasks'),
15
- };
16
- }
17
- return;
18
- },
19
- };
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
+ function pendingTasksPlugin() {
10
+ return {
11
+ name: "analogjs-pending-tasks-plugin",
12
+ transform(code, id) {
13
+ if (id.includes("analogjs-content.mjs")) return { code: code.replace("ɵPendingTasksInternal", "ɵPendingTasks") };
14
+ }
15
+ };
20
16
  }
17
+ //#endregion
18
+ export { pendingTasksPlugin };
19
+
21
20
  //# sourceMappingURL=angular-pending-tasks.plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"angular-pending-tasks.plugin.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-pending-tasks.plugin.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,+BAA+B;QACrC,SAAS,CAAC,IAAI,EAAE,EAAE;YAChB,IAAI,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBACxC,OAAO;oBACL,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,eAAe,CAAC;iBAC7D,CAAC;YACJ,CAAC;YACD,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC"}
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,184 @@
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 { StylePreprocessor } from "./style-preprocessor.js";
5
+ import { type DebugOption } from "./utils/debug.js";
6
+ import { FileReplacement } from "./plugins/file-replacements.plugin.js";
7
+ import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
8
+ import { AngularStylePipelineOptions } from "./style-pipeline.js";
9
+ export { DiagnosticModes, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, toAngularCompilationFileReplacements, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, describeStylesheetContent, isTestWatchMode } from "./utils/compilation-shared.js";
10
+ export { buildStylePreprocessor } from "./tailwind-plugin.js";
12
11
  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
- };
12
+ tsconfig?: string | (() => string);
13
+ workspaceRoot?: string;
14
+ inlineStylesExtension?: string;
15
+ jit?: boolean;
16
+ advanced?: {
17
+ /**
18
+ * Custom TypeScript transformers that are run before Angular compilation
19
+ */
20
+ tsTransformers?: ts.CustomTransformers;
21
+ };
22
+ supportedBrowsers?: string[];
23
+ transformFilter?: (code: string, id: string) => boolean;
24
+ /**
25
+ * Additional files to include in compilation
26
+ */
27
+ include?: string[];
28
+ additionalContentDirs?: string[];
29
+ /**
30
+ * Enables Analog's Angular live-reload/HMR pipeline during development/watch mode.
31
+ *
32
+ * This is separate from Vite's `server.hmr` option, which configures the
33
+ * HMR client transport.
34
+ *
35
+ * Defaults to `true` for watch mode. Set to `false` to disable Angular
36
+ * reload updates while keeping other stylesheet externalization behavior
37
+ * available when needed.
38
+ */
39
+ liveReload?: boolean;
40
+ disableTypeChecking?: boolean;
41
+ fileReplacements?: FileReplacement[];
42
+ /**
43
+ * Opt into the fast compile path. Skips Angular's template type-checking
44
+ * and routes compilation through an internal single-pass transform.
45
+ * Defaults to `false`.
46
+ */
47
+ fastCompile?: boolean;
48
+ /**
49
+ * Compilation output mode used when `fastCompile` is enabled.
50
+ * - `'full'` (default): Emit final Ivy definitions for application builds.
51
+ * - `'partial'`: Emit partial declarations for library publishing.
52
+ */
53
+ fastCompileMode?: "full" | "partial";
54
+ experimental?: {
55
+ useAngularCompilationAPI?: boolean;
56
+ };
57
+ /**
58
+ * Enable debug logging for specific scopes.
59
+ *
60
+ * - `true` → enables all `analog:angular:*` scopes
61
+ * - `string[]` → enables listed namespaces (e.g. `['analog:angular:tailwind']`)
62
+ * - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
63
+ * to restrict output to a specific Vite command (omit for both)
64
+ *
65
+ * Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`
66
+ * (browser), using the `obug` convention.
67
+ */
68
+ debug?: DebugOption;
69
+ /**
70
+ * Optional preprocessor that transforms component CSS before it enters Vite's
71
+ * preprocessCSS pipeline. Runs on every component stylesheet (both external
72
+ * `.component.css` files and inline `styles: [...]` blocks).
73
+ *
74
+ * @param code - Raw CSS content of the component stylesheet
75
+ * @param filename - Resolved file path of the stylesheet (or containing .ts file for inline styles)
76
+ * @returns Transformed CSS string, or the original code if no transformation is needed
77
+ */
78
+ stylePreprocessor?: StylePreprocessor;
79
+ /**
80
+ * Experimental Angular stylesheet-resource hooks for community-maintained
81
+ * style-pipeline plugins.
82
+ *
83
+ * These hooks run inside the Angular resource pipeline, which is the seam a
84
+ * standalone Vite plugin cannot own on its own.
85
+ */
86
+ stylePipeline?: AngularStylePipelineOptions;
87
+ /**
88
+ * First-class Tailwind CSS v4 integration for Angular component styles.
89
+ *
90
+ * Angular's compiler processes component CSS through Vite's `preprocessCSS()`,
91
+ * which runs `@tailwindcss/vite` — but each component stylesheet is processed
92
+ * in isolation without access to the root Tailwind configuration (prefix, @theme,
93
+ * @custom-variant, @plugin definitions). This causes errors like:
94
+ *
95
+ * "Cannot apply utility class `sa:grid` because the `sa` variant does not exist"
96
+ *
97
+ * The `tailwindCss` option solves this by auto-injecting a `@reference` directive
98
+ * into every component CSS file that uses Tailwind utilities, pointing it to the
99
+ * root Tailwind stylesheet so `@tailwindcss/vite` can resolve the full configuration.
100
+ *
101
+ * @example Basic usage — reference a root Tailwind CSS file:
102
+ * ```ts
103
+ * import { resolve } from 'node:path';
104
+ *
105
+ * angular({
106
+ * tailwindCss: {
107
+ * rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
108
+ * },
109
+ * })
110
+ * ```
111
+ *
112
+ * @example With prefix detection — only inject for files using specific prefixes:
113
+ * ```ts
114
+ * angular({
115
+ * tailwindCss: {
116
+ * rootStylesheet: resolve(__dirname, 'src/styles/tailwind.css'),
117
+ * // Only inject @reference into files that use these prefixed classes
118
+ * prefixes: ['sa:', 'tw:'],
119
+ * },
120
+ * })
121
+ * ```
122
+ *
123
+ * @example AnalogJS platform — passed through the `vite` option:
124
+ * ```ts
125
+ * analog({
126
+ * vite: {
127
+ * tailwindCss: {
128
+ * rootStylesheet: resolve(__dirname, '../../../libs/meritos/tailwind.config.css'),
129
+ * },
130
+ * },
131
+ * })
132
+ * ```
133
+ */
134
+ tailwindCss?: {
135
+ /**
136
+ * Absolute path to the root Tailwind CSS file that contains `@import "tailwindcss"`,
137
+ * `@theme`, `@custom-variant`, and `@plugin` definitions.
138
+ *
139
+ * A `@reference` directive pointing to this file will be auto-injected into
140
+ * component CSS files that use Tailwind utilities.
141
+ */
142
+ rootStylesheet: string;
143
+ /**
144
+ * Optional list of class prefixes to detect (e.g. `['sa:', 'tw:']`).
145
+ * When provided, `@reference` is only injected into component CSS files that
146
+ * contain at least one of these prefixes. When omitted, `@reference` is injected
147
+ * into all component CSS files that contain `@apply` or `@` directives.
148
+ *
149
+ * @default undefined — inject into all component CSS files with `@apply`
150
+ */
151
+ prefixes?: string[];
152
+ };
36
153
  }
154
+ export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
155
+ classNamesMap: Map<string, string>;
156
+ fileTransformMap: Map<string, string>;
157
+ }): void;
37
158
  export declare function angular(options?: PluginOptions): Plugin[];
38
159
  export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
39
160
  /**
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;
161
+ * Returns every live Vite module that can legitimately represent a changed
162
+ * Angular resource file.
163
+ *
164
+ * For normal files, `getModulesByFile()` is enough. For Angular component
165
+ * stylesheets, it is not: the browser often holds virtual hashed requests
166
+ * (`/abc123.css?direct&ngcomp=...` and `/abc123.css?ngcomp=...`) that are no
167
+ * longer discoverable from the original source path alone. We therefore merge:
168
+ * - watcher event modules
169
+ * - module-graph modules by source file
170
+ * - registry-tracked live request ids resolved back through the module graph
171
+ */
172
+ export declare function getModulesForChangedFile(server: ViteDevServer, file: string, eventModules?: readonly ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
173
+ export declare function isModuleForChangedResource(mod: ModuleNode, changedFile: string, stylesheetRegistry?: AnalogStylesheetRegistry): boolean;
174
+ export declare function findComponentStylesheetWrapperModules(server: ViteDevServer, changedFile: string, directModule: ModuleNode, fileModules: ModuleNode[], stylesheetRegistry?: AnalogStylesheetRegistry): Promise<ModuleNode[]>;
175
+ export declare function findTemplateOwnerModules(server: ViteDevServer, resourceFile: string): ModuleNode[];
52
176
  /**
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;
177
+ * @internal
178
+ */
179
+ export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean): (file: string) => {
180
+ errors?: string[];
181
+ warnings?: (string | ts.DiagnosticMessageChain)[];
182
+ hmrUpdateCode?: string | null;
183
+ hmrEligible?: boolean;
71
184
  };
72
- /**
73
- * Checks for vitest run from the command line
74
- * @returns boolean
75
- */
76
- export declare function isTestWatchMode(args?: string[]): boolean;