@analogjs/vite-plugin-angular 3.0.0-alpha.5 → 3.0.0-alpha.51

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 (194) 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 +41 -12
  11. package/src/index.d.ts +3 -2
  12. package/src/index.js +6 -2
  13. package/src/index.js.map +1 -1
  14. package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
  15. package/src/lib/angular-build-optimizer-plugin.js +48 -62
  16. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  17. package/src/lib/angular-jit-plugin.d.ts +3 -3
  18. package/src/lib/angular-jit-plugin.js +39 -37
  19. package/src/lib/angular-jit-plugin.js.map +1 -1
  20. package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
  21. package/src/lib/angular-pending-tasks.plugin.js +17 -18
  22. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  23. package/src/lib/angular-vite-plugin.d.ts +180 -44
  24. package/src/lib/angular-vite-plugin.js +1233 -969
  25. package/src/lib/angular-vite-plugin.js.map +1 -1
  26. package/src/lib/angular-vitest-plugin.d.ts +19 -15
  27. package/src/lib/angular-vitest-plugin.js +99 -114
  28. package/src/lib/angular-vitest-plugin.js.map +1 -1
  29. package/src/lib/compilation-api/compilation-api-plugin.d.ts +29 -0
  30. package/src/lib/compilation-api/compilation-api-plugin.js +480 -0
  31. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
  32. package/src/lib/compilation-api/index.d.ts +1 -0
  33. package/src/lib/compilation-api/index.js +1 -0
  34. package/src/lib/compiler/angular-version.d.ts +19 -0
  35. package/src/lib/compiler/angular-version.js +16 -0
  36. package/src/lib/compiler/angular-version.js.map +1 -0
  37. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  38. package/src/lib/compiler/class-field-lowering.js +131 -0
  39. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  40. package/src/lib/compiler/compile.d.ts +44 -0
  41. package/src/lib/compiler/compile.js +731 -0
  42. package/src/lib/compiler/compile.js.map +1 -0
  43. package/src/lib/compiler/constants.d.ts +18 -0
  44. package/src/lib/compiler/constants.js +52 -0
  45. package/src/lib/compiler/constants.js.map +1 -0
  46. package/src/lib/compiler/debug.d.ts +22 -0
  47. package/src/lib/compiler/debug.js +20 -0
  48. package/src/lib/compiler/debug.js.map +1 -0
  49. package/src/lib/compiler/defer.d.ts +57 -0
  50. package/src/lib/compiler/defer.js +154 -0
  51. package/src/lib/compiler/defer.js.map +1 -0
  52. package/src/lib/compiler/dts-reader.d.ts +35 -0
  53. package/src/lib/compiler/dts-reader.js +365 -0
  54. package/src/lib/compiler/dts-reader.js.map +1 -0
  55. package/src/lib/compiler/hmr.d.ts +16 -0
  56. package/src/lib/compiler/hmr.js +69 -0
  57. package/src/lib/compiler/hmr.js.map +1 -0
  58. package/src/lib/compiler/index.d.ts +7 -0
  59. package/src/lib/compiler/index.js +7 -0
  60. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  61. package/src/lib/compiler/jit-metadata.js +146 -0
  62. package/src/lib/compiler/jit-metadata.js.map +1 -0
  63. package/src/lib/compiler/jit-transform.d.ts +24 -0
  64. package/src/lib/compiler/jit-transform.js +200 -0
  65. package/src/lib/compiler/jit-transform.js.map +1 -0
  66. package/src/lib/compiler/js-emitter.d.ts +10 -0
  67. package/src/lib/compiler/js-emitter.js +445 -0
  68. package/src/lib/compiler/js-emitter.js.map +1 -0
  69. package/src/lib/compiler/metadata.d.ts +45 -0
  70. package/src/lib/compiler/metadata.js +633 -0
  71. package/src/lib/compiler/metadata.js.map +1 -0
  72. package/src/lib/compiler/registry.d.ts +49 -0
  73. package/src/lib/compiler/registry.js +164 -0
  74. package/src/lib/compiler/registry.js.map +1 -0
  75. package/src/lib/compiler/resource-inliner.d.ts +21 -0
  76. package/src/lib/compiler/resource-inliner.js +152 -0
  77. package/src/lib/compiler/resource-inliner.js.map +1 -0
  78. package/src/lib/compiler/style-ast.d.ts +8 -0
  79. package/src/lib/compiler/style-ast.js +54 -0
  80. package/src/lib/compiler/style-ast.js.map +1 -0
  81. package/src/lib/compiler/styles.d.ts +13 -0
  82. package/src/lib/compiler/test-helpers.d.ts +7 -0
  83. package/src/lib/compiler/type-elision.d.ts +26 -0
  84. package/src/lib/compiler/type-elision.js +211 -0
  85. package/src/lib/compiler/type-elision.js.map +1 -0
  86. package/src/lib/compiler/utils.d.ts +10 -0
  87. package/src/lib/compiler/utils.js +35 -0
  88. package/src/lib/compiler/utils.js.map +1 -0
  89. package/src/lib/compiler-plugin.d.ts +11 -11
  90. package/src/lib/compiler-plugin.js +43 -44
  91. package/src/lib/compiler-plugin.js.map +1 -1
  92. package/src/lib/component-resolvers.d.ts +23 -5
  93. package/src/lib/component-resolvers.js +153 -63
  94. package/src/lib/component-resolvers.js.map +1 -1
  95. package/src/lib/encapsulation-plugin.d.ts +13 -0
  96. package/src/lib/encapsulation-plugin.js +48 -0
  97. package/src/lib/encapsulation-plugin.js.map +1 -0
  98. package/src/lib/fast-compile-plugin.d.ts +28 -0
  99. package/src/lib/fast-compile-plugin.js +289 -0
  100. package/src/lib/fast-compile-plugin.js.map +1 -0
  101. package/src/lib/host.d.ts +10 -8
  102. package/src/lib/host.js +113 -101
  103. package/src/lib/host.js.map +1 -1
  104. package/src/lib/live-reload-plugin.d.ts +5 -5
  105. package/src/lib/live-reload-plugin.js +61 -62
  106. package/src/lib/live-reload-plugin.js.map +1 -1
  107. package/src/lib/models.d.ts +9 -9
  108. package/src/lib/nx-folder-plugin.d.ts +5 -5
  109. package/src/lib/nx-folder-plugin.js +18 -16
  110. package/src/lib/nx-folder-plugin.js.map +1 -1
  111. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  112. package/src/lib/plugins/file-replacements.plugin.js +40 -62
  113. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  114. package/src/lib/router-plugin.d.ts +1 -1
  115. package/src/lib/router-plugin.js +23 -23
  116. package/src/lib/router-plugin.js.map +1 -1
  117. package/src/lib/style-pipeline.d.ts +15 -0
  118. package/src/lib/style-pipeline.js +31 -0
  119. package/src/lib/style-pipeline.js.map +1 -0
  120. package/src/lib/style-preprocessor.d.ts +35 -0
  121. package/src/lib/style-preprocessor.js +35 -0
  122. package/src/lib/style-preprocessor.js.map +1 -0
  123. package/src/lib/stylesheet-registry.d.ts +73 -0
  124. package/src/lib/stylesheet-registry.js +168 -0
  125. package/src/lib/stylesheet-registry.js.map +1 -0
  126. package/src/lib/tailwind-plugin.d.ts +34 -0
  127. package/src/lib/tailwind-plugin.js +116 -0
  128. package/src/lib/tailwind-plugin.js.map +1 -0
  129. package/src/lib/template-class-binding-guard-plugin.d.ts +30 -0
  130. package/src/lib/template-class-binding-guard-plugin.js +237 -0
  131. package/src/lib/template-class-binding-guard-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 +31 -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 +58 -0
  139. package/src/lib/utils/compilation-shared.js +133 -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/debug-harness.d.ts +23 -0
  143. package/src/lib/utils/debug-harness.js +88 -0
  144. package/src/lib/utils/debug-harness.js.map +1 -0
  145. package/src/lib/utils/debug-log-file.d.ts +5 -0
  146. package/src/lib/utils/debug-log-file.js +56 -0
  147. package/src/lib/utils/debug-log-file.js.map +1 -0
  148. package/src/lib/utils/debug.d.ts +28 -0
  149. package/src/lib/utils/debug.js +39 -0
  150. package/src/lib/utils/debug.js.map +1 -0
  151. package/src/lib/utils/devkit.d.ts +6 -6
  152. package/src/lib/utils/devkit.js +34 -38
  153. package/src/lib/utils/devkit.js.map +1 -1
  154. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  155. package/src/lib/utils/plugin-config.d.ts +37 -0
  156. package/src/lib/utils/plugin-config.js +71 -0
  157. package/src/lib/utils/plugin-config.js.map +1 -0
  158. package/src/lib/utils/rolldown.d.ts +2 -0
  159. package/src/lib/utils/rolldown.js +12 -0
  160. package/src/lib/utils/rolldown.js.map +1 -0
  161. package/src/lib/utils/safe-module-paths.d.ts +16 -0
  162. package/src/lib/utils/safe-module-paths.js +29 -0
  163. package/src/lib/utils/safe-module-paths.js.map +1 -0
  164. package/src/lib/utils/source-file-cache.d.ts +8 -15
  165. package/src/lib/utils/source-file-cache.js +35 -37
  166. package/src/lib/utils/source-file-cache.js.map +1 -1
  167. package/src/lib/utils/tailwind-reference.d.ts +12 -0
  168. package/src/lib/utils/tailwind-reference.js +99 -0
  169. package/src/lib/utils/tailwind-reference.js.map +1 -0
  170. package/src/lib/utils/tsconfig-resolver.d.ts +28 -0
  171. package/src/lib/utils/tsconfig-resolver.js +191 -0
  172. package/src/lib/utils/tsconfig-resolver.js.map +1 -0
  173. package/src/lib/utils/virtual-ids.d.ts +4 -0
  174. package/src/lib/utils/virtual-ids.js +23 -0
  175. package/src/lib/utils/virtual-ids.js.map +1 -0
  176. package/src/lib/utils/virtual-resources.d.ts +19 -0
  177. package/src/lib/utils/virtual-resources.js +38 -0
  178. package/src/lib/utils/virtual-resources.js.map +1 -0
  179. package/src/lib/virtual-modules-plugin.d.ts +5 -0
  180. package/src/lib/virtual-modules-plugin.js +23 -0
  181. package/src/lib/virtual-modules-plugin.js.map +1 -0
  182. package/src/test-setup.d.ts +2 -0
  183. package/setup-vitest.d.ts +0 -4
  184. package/setup-vitest.js +0 -215
  185. package/setup-vitest.js.map +0 -1
  186. package/src/lib/models.js +0 -1
  187. package/src/lib/models.js.map +0 -1
  188. package/src/lib/tools/README.md +0 -3
  189. package/src/lib/tools/src/index.d.ts +0 -0
  190. package/src/lib/tools/src/index.js.map +0 -1
  191. package/src/lib/utils/compiler-plugin-options.js +0 -1
  192. package/src/lib/utils/compiler-plugin-options.js.map +0 -1
  193. package/src/lib/utils/hmr-candidates.js +0 -272
  194. package/src/lib/utils/hmr-candidates.js.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @analogjs/vite-plugin-angular
2
2
 
3
+ [![Vite Plugin Registry](https://img.shields.io/badge/vite-plugin--registry-blue?logo=vite)](https://registry.vite.dev/plugin/@analogjs/vite-plugin-angular)
4
+
3
5
  A Vite plugin for building Angular applications
4
6
 
5
7
  ## Install
@@ -48,6 +50,28 @@ export default defineConfig({
48
50
 
49
51
  > The `angular` plugin should be listed **first** in the plugins array.
50
52
 
53
+ ## Fast Compile Mode
54
+
55
+ `fastCompile` opts the plugin into a single-pass compilation path that emits Ivy instructions directly and skips Angular's template type-checking. It's intended for content-focused apps and faster dev iteration where build throughput matters more than inline type-safety feedback.
56
+
57
+ ```ts
58
+ export default defineConfig({
59
+ plugins: [angular({ fastCompile: true })],
60
+ });
61
+ ```
62
+
63
+ When `fastCompile` is enabled, template and input type errors will not surface during compilation — run `ngc -p tsconfig.app.json --noEmit` as a separate step in your build script to keep full type safety:
64
+
65
+ ```json
66
+ {
67
+ "scripts": {
68
+ "build": "ngc -p tsconfig.app.json --noEmit && vite build"
69
+ }
70
+ }
71
+ ```
72
+
73
+ The fast compile path currently passes ~91% of Angular's conformance suite. Behavior and output may change between minor releases.
74
+
51
75
  ## Setting up the TypeScript config
52
76
 
53
77
  The integration needs a `tsconfig.app.json` at the root of the project for compilation.
@@ -89,3 +113,9 @@ Create a `tsconfig.app.json` in the root of the project.
89
113
  "include": ["src/**/*.ts"]
90
114
  }
91
115
  ```
116
+
117
+ ## Tailwind CSS v4
118
+
119
+ For Angular component styles that use Tailwind utilities like `@apply`, configure `tailwindCss.rootStylesheet` and follow the Tailwind guide for Analog:
120
+
121
+ - https://analogjs.org/docs/integrations/tailwind
@@ -0,0 +1,2 @@
1
+ import { Rule } from "@angular-devkit/schematics";
2
+ export default function migrateSetupVitest(): Rule;
@@ -0,0 +1,49 @@
1
+ import { NodePackageInstallTask } from "@angular-devkit/schematics/tasks";
2
+ //#region packages/vite-plugin-angular/migrations/migrate-setup-vitest/migrate-setup-vitest.ts
3
+ var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
4
+ var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
5
+ function addVitestAngularDependency(tree, context) {
6
+ const pkgPath = "/package.json";
7
+ const content = tree.read(pkgPath);
8
+ if (!content) return;
9
+ const pkg = JSON.parse(content.toString("utf-8"));
10
+ const devDeps = pkg["devDependencies"] || {};
11
+ const deps = pkg["dependencies"] || {};
12
+ if (!devDeps["@analogjs/vitest-angular"] && !deps["@analogjs/vitest-angular"]) {
13
+ const analogVersion = devDeps["@analogjs/vite-plugin-angular"] || deps["@analogjs/vite-plugin-angular"] || "*";
14
+ pkg["devDependencies"] = {
15
+ ...devDeps,
16
+ "@analogjs/vitest-angular": analogVersion
17
+ };
18
+ tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
19
+ context.addTask(new NodePackageInstallTask());
20
+ context.logger.info(`Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`);
21
+ }
22
+ }
23
+ function migrateSetupVitest() {
24
+ return (tree, context) => {
25
+ const filesToUpdate = [];
26
+ tree.visit((filePath) => {
27
+ if (!filePath.endsWith(".ts") && !filePath.endsWith(".mts") && !filePath.endsWith(".js") && !filePath.endsWith(".mjs")) return;
28
+ if (filePath.includes("/node_modules/")) return;
29
+ const content = tree.read(filePath);
30
+ if (!content) return;
31
+ const text = content.toString("utf-8");
32
+ if (text.includes(OLD_IMPORT)) {
33
+ const updated = text.replace(new RegExp(OLD_IMPORT.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), NEW_IMPORT);
34
+ tree.overwrite(filePath, updated);
35
+ filesToUpdate.push(filePath);
36
+ }
37
+ });
38
+ if (filesToUpdate.length > 0) {
39
+ context.logger.info(`Migrated ${filesToUpdate.length} file(s) from '${OLD_IMPORT}' to '${NEW_IMPORT}':`);
40
+ for (const file of filesToUpdate) context.logger.info(` - ${file}`);
41
+ }
42
+ if (filesToUpdate.length > 0) addVitestAngularDependency(tree, context);
43
+ return tree;
44
+ };
45
+ }
46
+ //#endregion
47
+ export { migrateSetupVitest as default };
48
+
49
+ //# sourceMappingURL=migrate-setup-vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/migrate-setup-vitest/migrate-setup-vitest.ts"],"sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\n\nfunction addVitestAngularDependency(\n tree: Tree,\n context: SchematicContext,\n): void {\n const pkgPath = '/package.json';\n const content = tree.read(pkgPath);\n if (!content) {\n return;\n }\n\n const pkg = JSON.parse(content.toString('utf-8'));\n const devDeps = pkg['devDependencies'] || {};\n const deps = pkg['dependencies'] || {};\n\n if (\n !devDeps['@analogjs/vitest-angular'] &&\n !deps['@analogjs/vitest-angular']\n ) {\n const analogVersion =\n devDeps['@analogjs/vite-plugin-angular'] ||\n deps['@analogjs/vite-plugin-angular'] ||\n '*';\n\n pkg['devDependencies'] = {\n ...devDeps,\n '@analogjs/vitest-angular': analogVersion,\n };\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\\n');\n context.addTask(new NodePackageInstallTask());\n context.logger.info(\n `Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`,\n );\n }\n}\n\nexport default function migrateSetupVitest(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const filesToUpdate: string[] = [];\n\n tree.visit((filePath) => {\n if (\n !filePath.endsWith('.ts') &&\n !filePath.endsWith('.mts') &&\n !filePath.endsWith('.js') &&\n !filePath.endsWith('.mjs')\n ) {\n return;\n }\n if (filePath.includes('/node_modules/')) {\n return;\n }\n\n const content = tree.read(filePath);\n if (!content) {\n return;\n }\n\n const text = content.toString('utf-8');\n if (text.includes(OLD_IMPORT)) {\n const updated = text.replace(\n new RegExp(OLD_IMPORT.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n NEW_IMPORT,\n );\n tree.overwrite(filePath, updated);\n filesToUpdate.push(filePath);\n }\n });\n\n if (filesToUpdate.length > 0) {\n context.logger.info(\n `Migrated ${filesToUpdate.length} file(s) from '${OLD_IMPORT}' to '${NEW_IMPORT}':`,\n );\n for (const file of filesToUpdate) {\n context.logger.info(` - ${file}`);\n }\n }\n\n if (filesToUpdate.length > 0) {\n addVitestAngularDependency(tree, context);\n }\n\n return tree;\n };\n}\n"],"mappings":";;AAGA,IAAM,aAAa;AACnB,IAAM,aAAa;AAEnB,SAAS,2BACP,MACA,SACM;CACN,MAAM,UAAU;CAChB,MAAM,UAAU,KAAK,KAAK,QAAQ;AAClC,KAAI,CAAC,QACH;CAGF,MAAM,MAAM,KAAK,MAAM,QAAQ,SAAS,QAAQ,CAAC;CACjD,MAAM,UAAU,IAAI,sBAAsB,EAAE;CAC5C,MAAM,OAAO,IAAI,mBAAmB,EAAE;AAEtC,KACE,CAAC,QAAQ,+BACT,CAAC,KAAK,6BACN;EACA,MAAM,gBACJ,QAAQ,oCACR,KAAK,oCACL;AAEF,MAAI,qBAAqB;GACvB,GAAG;GACH,4BAA4B;GAC7B;AAED,OAAK,UAAU,SAAS,KAAK,UAAU,KAAK,MAAM,EAAE,GAAG,KAAK;AAC5D,UAAQ,QAAQ,IAAI,wBAAwB,CAAC;AAC7C,UAAQ,OAAO,KACb,sCAAsC,cAAc,uBACrD;;;AAIL,SAAwB,qBAA2B;AACjD,SAAQ,MAAY,YAA8B;EAChD,MAAM,gBAA0B,EAAE;AAElC,OAAK,OAAO,aAAa;AACvB,OACE,CAAC,SAAS,SAAS,MAAM,IACzB,CAAC,SAAS,SAAS,OAAO,IAC1B,CAAC,SAAS,SAAS,MAAM,IACzB,CAAC,SAAS,SAAS,OAAO,CAE1B;AAEF,OAAI,SAAS,SAAS,iBAAiB,CACrC;GAGF,MAAM,UAAU,KAAK,KAAK,SAAS;AACnC,OAAI,CAAC,QACH;GAGF,MAAM,OAAO,QAAQ,SAAS,QAAQ;AACtC,OAAI,KAAK,SAAS,WAAW,EAAE;IAC7B,MAAM,UAAU,KAAK,QACnB,IAAI,OAAO,WAAW,QAAQ,uBAAuB,OAAO,EAAE,IAAI,EAClE,WACD;AACD,SAAK,UAAU,UAAU,QAAQ;AACjC,kBAAc,KAAK,SAAS;;IAE9B;AAEF,MAAI,cAAc,SAAS,GAAG;AAC5B,WAAQ,OAAO,KACb,YAAY,cAAc,OAAO,iBAAiB,WAAW,QAAQ,WAAW,IACjF;AACD,QAAK,MAAM,QAAQ,cACjB,SAAQ,OAAO,KAAK,OAAO,OAAO;;AAItC,MAAI,cAAc,SAAS,EACzB,4BAA2B,MAAM,QAAQ;AAG3C,SAAO"}
@@ -1,4 +1,10 @@
1
1
  {
2
2
  "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
- "schematics": {}
3
+ "schematics": {
4
+ "migrate-setup-vitest": {
5
+ "version": "3.0.0-alpha.16",
6
+ "description": "Migrate from @analogjs/vite-plugin-angular/setup-vitest to @analogjs/vitest-angular/setup-zone",
7
+ "factory": "./migrate-setup-vitest/migrate-setup-vitest"
8
+ }
9
+ }
4
10
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "generators": {
3
+ "update-3-0-0-migrate-setup-vitest": {
4
+ "version": "3.0.0-alpha.25",
5
+ "description": "Migrate from @analogjs/vite-plugin-angular/setup-vitest to @analogjs/vitest-angular/setup-zone in Nx workspaces",
6
+ "implementation": "./update-3-0-0/migrate-setup-vitest"
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,2 @@
1
+ import { Tree } from "@nx/devkit";
2
+ export default function migrateSetupVitest(tree: Tree);
@@ -0,0 +1,36 @@
1
+ import { addDependenciesToPackageJson, readJson, runTasksInSerial, visitNotIgnoredFiles } from "@nx/devkit";
2
+ //#region packages/vite-plugin-angular/migrations/update-3-0-0/migrate-setup-vitest.ts
3
+ var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
4
+ var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
5
+ var SUPPORTED_EXTENSIONS = new Set([
6
+ ".cjs",
7
+ ".cts",
8
+ ".js",
9
+ ".jsx",
10
+ ".mjs",
11
+ ".mts",
12
+ ".ts",
13
+ ".tsx"
14
+ ]);
15
+ function getAnalogVersion(tree) {
16
+ if (!tree.exists("package.json")) return "*";
17
+ const packageJson = readJson(tree, "package.json");
18
+ return packageJson.devDependencies?.["@analogjs/vite-plugin-angular"] || packageJson.dependencies?.["@analogjs/vite-plugin-angular"] || "*";
19
+ }
20
+ async function migrateSetupVitest(tree) {
21
+ const filesToUpdate = [];
22
+ visitNotIgnoredFiles(tree, "", (filePath) => {
23
+ const extension = filePath.slice(filePath.lastIndexOf("."));
24
+ if (!SUPPORTED_EXTENSIONS.has(extension)) return;
25
+ const content = tree.read(filePath, "utf-8");
26
+ if (!content?.includes(OLD_IMPORT)) return;
27
+ tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));
28
+ filesToUpdate.push(filePath);
29
+ });
30
+ if (filesToUpdate.length === 0) return;
31
+ return runTasksInSerial(addDependenciesToPackageJson(tree, {}, { "@analogjs/vitest-angular": getAnalogVersion(tree) }, "package.json", true));
32
+ }
33
+ //#endregion
34
+ export { migrateSetupVitest as default };
35
+
36
+ //# sourceMappingURL=migrate-setup-vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/update-3-0-0/migrate-setup-vitest.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n readJson,\n runTasksInSerial,\n Tree,\n visitNotIgnoredFiles,\n} from '@nx/devkit';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\nconst SUPPORTED_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n]);\n\nfunction getAnalogVersion(tree: Tree): string {\n if (!tree.exists('package.json')) {\n return '*';\n }\n\n const packageJson = readJson<{\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n }>(tree, 'package.json');\n\n return (\n packageJson.devDependencies?.['@analogjs/vite-plugin-angular'] ||\n packageJson.dependencies?.['@analogjs/vite-plugin-angular'] ||\n '*'\n );\n}\n\nexport default async function migrateSetupVitest(tree: Tree) {\n const filesToUpdate: string[] = [];\n\n visitNotIgnoredFiles(tree, '', (filePath) => {\n const extension = filePath.slice(filePath.lastIndexOf('.'));\n if (!SUPPORTED_EXTENSIONS.has(extension)) {\n return;\n }\n\n const content = tree.read(filePath, 'utf-8');\n if (!content?.includes(OLD_IMPORT)) {\n return;\n }\n\n tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));\n filesToUpdate.push(filePath);\n });\n\n if (filesToUpdate.length === 0) {\n return;\n }\n\n const installTask = addDependenciesToPackageJson(\n tree,\n {},\n {\n '@analogjs/vitest-angular': getAnalogVersion(tree),\n },\n 'package.json',\n true,\n );\n\n return runTasksInSerial(installTask);\n}\n"],"mappings":";;AAQA,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,uBAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,iBAAiB,MAAoB;AAC5C,KAAI,CAAC,KAAK,OAAO,eAAe,CAC9B,QAAO;CAGT,MAAM,cAAc,SAGjB,MAAM,eAAe;AAExB,QACE,YAAY,kBAAkB,oCAC9B,YAAY,eAAe,oCAC3B;;AAIJ,eAA8B,mBAAmB,MAAY;CAC3D,MAAM,gBAA0B,EAAE;AAElC,sBAAqB,MAAM,KAAK,aAAa;EAC3C,MAAM,YAAY,SAAS,MAAM,SAAS,YAAY,IAAI,CAAC;AAC3D,MAAI,CAAC,qBAAqB,IAAI,UAAU,CACtC;EAGF,MAAM,UAAU,KAAK,KAAK,UAAU,QAAQ;AAC5C,MAAI,CAAC,SAAS,SAAS,WAAW,CAChC;AAGF,OAAK,MAAM,UAAU,QAAQ,WAAW,YAAY,WAAW,CAAC;AAChE,gBAAc,KAAK,SAAS;GAC5B;AAEF,KAAI,cAAc,WAAW,EAC3B;AAaF,QAAO,iBAVa,6BAClB,MACA,EAAE,EACF,EACE,4BAA4B,iBAAiB,KAAK,EACnD,EACD,gBACA,KACD,CAEmC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/vite-plugin-angular",
3
- "version": "3.0.0-alpha.5",
3
+ "version": "3.0.0-alpha.51",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/sponsors/brandonroberts"
25
25
  },
26
26
  "peerDependencies": {
27
- "@angular-devkit/build-angular": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
27
+ "@angular-devkit/build-angular": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0",
28
28
  "@angular/build": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0"
29
29
  },
30
30
  "peerDependenciesMeta": {
@@ -33,13 +33,46 @@
33
33
  },
34
34
  "@angular/build": {
35
35
  "optional": true
36
+ },
37
+ "vite": {
38
+ "optional": true
36
39
  }
37
40
  },
41
+ "compatiblePackages": {
42
+ "vite": [
43
+ "^6.0.0",
44
+ "^7.0.0",
45
+ "^8.0.0"
46
+ ],
47
+ "rollup": [
48
+ "^4.0.0"
49
+ ],
50
+ "rolldown": [
51
+ "^1.0.0"
52
+ ]
53
+ },
38
54
  "dependencies": {
39
- "tinyglobby": "^0.2.14",
40
- "ts-morph": "^21.0.0"
55
+ "es-toolkit": "^1.45.1",
56
+ "magic-string": "^0.30.21",
57
+ "obug": "^2.1.1",
58
+ "oxc-parser": "^0.124.0",
59
+ "oxc-resolver": "^11.19.1",
60
+ "rolldown": "^1.0.0-rc.13",
61
+ "tinyglobby": "^0.2.15"
41
62
  },
42
63
  "builders": "./src/lib/tools/builders.json",
64
+ "nx-migrations": {
65
+ "packageGroup": [
66
+ "@analogjs/platform",
67
+ "@analogjs/content",
68
+ "@analogjs/router",
69
+ "@analogjs/storybook-angular",
70
+ "@analogjs/vite-plugin-angular",
71
+ "@analogjs/vite-plugin-nitro",
72
+ "@analogjs/vitest-angular"
73
+ ],
74
+ "migrations": "./migrations/migrations.json"
75
+ },
43
76
  "ng-update": {
44
77
  "packageGroup": [
45
78
  "@analogjs/platform",
@@ -54,20 +87,16 @@
54
87
  },
55
88
  "exports": {
56
89
  "./package.json": "./package.json",
90
+ "./migrations.json": "./migrations/migrations.json",
57
91
  ".": {
58
92
  "types": "./src/index.d.ts",
59
93
  "import": "./src/index.js",
60
94
  "require": "./src/index.js",
61
95
  "default": "./src/index.js"
62
- },
63
- "./esbuild": "./esbuild.js",
64
- "./setup-vitest": "./setup-vitest.js"
96
+ }
65
97
  },
66
98
  "publishConfig": {
67
99
  "access": "public",
68
100
  "provenance": true
69
- },
70
- "types": "./src/index.d.ts",
71
- "module": "./src/index.js",
72
- "main": "./src/index.js"
73
- }
101
+ }
102
+ }
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { angular } from './lib/angular-vite-plugin.js';
2
- export { PluginOptions } from './lib/angular-vite-plugin.js';
1
+ import { angular } from "./lib/angular-vite-plugin.js";
2
+ export { angular } from "./lib/angular-vite-plugin.js";
3
+ export type { PluginOptions } from "./lib/angular-vite-plugin.js";
3
4
  export default angular;
package/src/index.js CHANGED
@@ -1,3 +1,7 @@
1
- import { angular } from './lib/angular-vite-plugin.js';
2
- export default angular;
1
+ import { angular } from "./lib/angular-vite-plugin.js";
2
+ //#region packages/vite-plugin-angular/src/index.ts
3
+ var src_default = angular;
4
+ //#endregion
5
+ export { angular, src_default as default };
6
+
3
7
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/vite-plugin-angular/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAGvD,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { angular } from './lib/angular-vite-plugin.js';\nexport { angular } from './lib/angular-vite-plugin.js';\nexport type { PluginOptions } from './lib/angular-vite-plugin.js';\n\nexport default angular;\n"],"mappings":";;AAIA,IAAA,cAAe"}
@@ -1,5 +1,5 @@
1
- import type { Plugin } from 'vite';
2
- export declare function buildOptimizerPlugin({ jit, }: {
3
- supportedBrowsers: string[];
4
- jit: boolean;
1
+ import type { Plugin } from "vite";
2
+ export declare function buildOptimizerPlugin({ jit }: {
3
+ supportedBrowsers: string[];
4
+ jit: boolean;
5
5
  }): Plugin;
@@ -1,64 +1,50 @@
1
- import * as vite from 'vite';
2
- import { JavaScriptTransformer } from './utils/devkit.js';
3
- export function buildOptimizerPlugin({ jit, }) {
4
- const javascriptTransformer = new JavaScriptTransformer({
5
- sourcemap: false,
6
- thirdPartySourcemaps: false,
7
- advancedOptimizations: true,
8
- jit: true,
9
- }, 1);
10
- let isProd = false;
11
- return {
12
- name: '@analogjs/vite-plugin-angular-optimizer',
13
- apply: 'build',
14
- config(userConfig) {
15
- isProd =
16
- userConfig.mode === 'production' ||
17
- process.env['NODE_ENV'] === 'production';
18
- return {
19
- define: isProd
20
- ? {
21
- ngJitMode: 'false',
22
- ngI18nClosureMode: 'false',
23
- ngDevMode: 'false',
24
- ngServerMode: `${!!userConfig.build?.ssr}`,
25
- }
26
- : {},
27
- [vite.rolldownVersion ? 'oxc' : 'esbuild']: {
28
- define: isProd
29
- ? {
30
- ngDevMode: 'false',
31
- ngJitMode: 'false',
32
- ngI18nClosureMode: 'false',
33
- ngServerMode: `${!!userConfig.build?.ssr}`,
34
- }
35
- : undefined,
36
- },
37
- };
38
- },
39
- transform: {
40
- filter: {
41
- id: /\.[cm]?js$/,
42
- },
43
- async handler(code, id) {
44
- const angularPackage = /fesm20/.test(id);
45
- if (!angularPackage) {
46
- return {
47
- code: isProd
48
- ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '')
49
- : code,
50
- map: {
51
- mappings: '',
52
- },
53
- };
54
- }
55
- const sideEffects = jit && id.includes('@angular/compiler') ? true : false;
56
- const result = await javascriptTransformer.transformData(id, code, false, sideEffects);
57
- return {
58
- code: Buffer.from(result).toString(),
59
- };
60
- },
61
- },
62
- };
1
+ import { jt } from "./utils/devkit.js";
2
+ import { getJsTransformConfigKey } from "./utils/rolldown.js";
3
+ //#region packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts
4
+ function buildOptimizerPlugin({ jit }) {
5
+ const javascriptTransformer = new jt({
6
+ sourcemap: false,
7
+ thirdPartySourcemaps: false,
8
+ advancedOptimizations: true,
9
+ jit: true
10
+ }, 1);
11
+ let isProd = false;
12
+ return {
13
+ name: "@analogjs/vite-plugin-angular-optimizer",
14
+ apply: "build",
15
+ 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
+ };
32
+ },
33
+ transform: {
34
+ filter: { id: /\.[cm]?js$/ },
35
+ async handler(code, id) {
36
+ if (!/fesm20/.test(id)) return {
37
+ code: isProd ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, "") : code,
38
+ map: { mappings: "" }
39
+ };
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() };
43
+ }
44
+ }
45
+ };
63
46
  }
47
+ //#endregion
48
+ export { buildOptimizerPlugin };
49
+
64
50
  //# sourceMappingURL=angular-build-optimizer-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"angular-build-optimizer-plugin.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,MAAM,UAAU,oBAAoB,CAAC,EACnC,GAAG,GAIJ;IACC,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,CACrD;QACE,SAAS,EAAE,KAAK;QAChB,oBAAoB,EAAE,KAAK;QAC3B,qBAAqB,EAAE,IAAI;QAC3B,GAAG,EAAE,IAAI;KACV,EACD,CAAC,CACF,CAAC;IACF,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,OAAO;QACL,IAAI,EAAE,yCAAyC;QAC/C,KAAK,EAAE,OAAO;QACd,MAAM,CAAC,UAAU;YACf,MAAM;gBACJ,UAAU,CAAC,IAAI,KAAK,YAAY;oBAChC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,YAAY,CAAC;YAE3C,OAAO;gBACL,MAAM,EAAE,MAAM;oBACZ,CAAC,CAAC;wBACE,SAAS,EAAE,OAAO;wBAClB,iBAAiB,EAAE,OAAO;wBAC1B,SAAS,EAAE,OAAO;wBAClB,YAAY,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE;qBAC3C;oBACH,CAAC,CAAC,EAAE;gBACN,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE;oBAC1C,MAAM,EAAE,MAAM;wBACZ,CAAC,CAAC;4BACE,SAAS,EAAE,OAAO;4BAClB,SAAS,EAAE,OAAO;4BAClB,iBAAiB,EAAE,OAAO;4BAC1B,YAAY,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE;yBAC3C;wBACH,CAAC,CAAC,SAAS;iBACd;aACY,CAAC;QAClB,CAAC;QACD,SAAS,EAAE;YACT,MAAM,EAAE;gBACN,EAAE,EAAE,YAAY;aACjB;YACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;gBACpB,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAEzC,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,OAAO;wBACL,IAAI,EAAE,MAAM;4BACV,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,oCAAoC,EAAE,EAAE,CAAC;4BACxD,CAAC,CAAC,IAAI;wBACR,GAAG,EAAE;4BACH,QAAQ,EAAE,EAAE;yBACb;qBACF,CAAC;gBACJ,CAAC;gBAED,MAAM,WAAW,GACf,GAAG,IAAI,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;gBACzD,MAAM,MAAM,GAAe,MAAM,qBAAqB,CAAC,aAAa,CAClE,EAAE,EACF,IAAI,EACJ,KAAK,EACL,WAAW,CACZ,CAAC;gBAEF,OAAO;oBACL,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;iBACrC,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
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 { 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,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,39 +1,41 @@
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 { debugStyles } from "./utils/debug.js";
2
+ import { isTailwindReferenceError } from "./utils/tailwind-reference.js";
3
+ import { preprocessCSS } from "vite";
4
+ import { createHash } from "node:crypto";
5
+ //#region packages/vite-plugin-angular/src/lib/angular-jit-plugin.ts
6
+ function jitPlugin({ inlineStylesExtension }) {
7
+ let config;
8
+ return {
9
+ name: "@analogjs/vite-plugin-angular-jit",
10
+ configResolved(_config) {
11
+ config = _config;
12
+ },
13
+ resolveId(id) {
14
+ if (id.startsWith("virtual:angular")) return `\0${id}`;
15
+ },
16
+ async load(id) {
17
+ if (id.includes("virtual:angular:jit:style:inline;")) {
18
+ const styleId = id.split("style:inline;")[1];
19
+ const styleIdHash = createHash("sha256").update(styleId).digest("hex").slice(0, 16);
20
+ const decodedStyles = Buffer.from(decodeURIComponent(styleId), "base64").toString();
21
+ let styles = "";
22
+ try {
23
+ styles = (await preprocessCSS(decodedStyles, `${styleIdHash}.${inlineStylesExtension}?direct`, config))?.code;
24
+ } catch (e) {
25
+ if (isTailwindReferenceError(e)) throw e;
26
+ const errorMessage = e instanceof Error ? e.message : String(e);
27
+ debugStyles("jit css compilation error", {
28
+ styleIdHash,
29
+ error: errorMessage
30
+ });
31
+ console.warn("[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s", styleIdHash, errorMessage);
32
+ }
33
+ return `export default \`${styles}\``;
34
+ }
35
+ }
36
+ };
38
37
  }
38
+ //#endregion
39
+ export { jitPlugin };
40
+
39
41
  //# 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 { createHash } from 'node:crypto';\nimport { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport { debugStyles } from './utils/debug.js';\nimport { isTailwindReferenceError } from './utils/tailwind-reference.js';\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 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":";;;;;AAKA,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,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"}