@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
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.7",
3
+ "version": "3.0.0-alpha.71",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -24,8 +24,8 @@
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",
28
- "@angular/build": "^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 || ^22.0.0",
28
+ "@angular/build": "^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0 || ^22.0.0"
29
29
  },
30
30
  "peerDependenciesMeta": {
31
31
  "@angular-devkit/build-angular": {
@@ -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,26 @@
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
96
  },
63
- "./esbuild": "./esbuild.js",
64
- "./setup-vitest": "./setup-vitest.js"
97
+ "./builders/vite": {
98
+ "import": "./src/lib/tools/src/builders/vite/vite-build.impl.js",
99
+ "require": "./src/lib/tools/src/builders/vite/vite-build.impl.js",
100
+ "default": "./src/lib/tools/src/builders/vite/vite-build.impl.js"
101
+ },
102
+ "./builders/vite-dev-server": {
103
+ "import": "./src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js",
104
+ "require": "./src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js",
105
+ "default": "./src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js"
106
+ }
65
107
  },
66
108
  "publishConfig": {
67
109
  "access": "public",
68
110
  "provenance": true
69
- },
70
- "types": "./src/index.d.ts",
71
- "module": "./src/index.js",
72
- "main": "./src/index.js"
73
- }
111
+ }
112
+ }
package/src/index.d.ts CHANGED
@@ -1,3 +1,6 @@
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";
4
+ export type { AnalogIntegrationPlugin, AnalogPluginContext, AnalogPluginHooks } from "./lib/analog-plugin-interop.js";
5
+ export type { StylePreprocessor, StylesheetTransformContext, StylesheetTransformResult } from "./lib/style-preprocessor.js";
3
6
  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';\nexport type {\n AnalogIntegrationPlugin,\n AnalogPluginContext,\n AnalogPluginHooks,\n} from './lib/analog-plugin-interop.js';\nexport type {\n StylePreprocessor,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './lib/style-preprocessor.js';\n\nexport default angular;\n"],"mappings":";;AAcA,IAAA,cAAe"}
@@ -0,0 +1,40 @@
1
+ import type { Plugin, ResolvedConfig } from "vite";
2
+ import { type StylePreprocessor } from "./style-preprocessor.js";
3
+ /**
4
+ * Narrow framework context handed to a Vite plugin's `analog.setup()` hook.
5
+ * Only grows when a concrete integration needs another seam.
6
+ */
7
+ export interface AnalogPluginContext {
8
+ /**
9
+ * Registers a pre-transform that runs on every Angular component stylesheet
10
+ * before it enters Vite's `preprocessCSS` pipeline.
11
+ */
12
+ registerStylePreprocessor(preprocessor: StylePreprocessor): void;
13
+ }
14
+ export interface AnalogPluginHooks {
15
+ setup?(context: AnalogPluginContext): void | Promise<void>;
16
+ }
17
+ /**
18
+ * A normal Vite plugin that optionally exposes an `analog` setup hook.
19
+ * Discovery is structural (`plugin.analog?.setup`), so this type is a DX aid
20
+ * rather than a requirement.
21
+ */
22
+ export type AnalogIntegrationPlugin = Plugin & {
23
+ analog?: AnalogPluginHooks;
24
+ };
25
+ export interface AnalogIntegrations {
26
+ stylePreprocessor?: StylePreprocessor;
27
+ }
28
+ /**
29
+ * Runs every `analog.setup()` hook found in the resolved Vite plugin list,
30
+ * once per resolved config, and composes the registrations in plugin order.
31
+ */
32
+ export declare function discoverAnalogIntegrations(config: ResolvedConfig): Promise<AnalogIntegrations>;
33
+ export declare function runAnalogSetupHooks(plugins: readonly Plugin[]): Promise<AnalogIntegrations>;
34
+ /**
35
+ * Resolves the stylesheet preprocessor a compilation path should use:
36
+ * plugin-registered preprocessors first, then the chain configured through
37
+ * `angular()` options (Tailwind reference injection, `stylePipeline`,
38
+ * `stylePreprocessor`).
39
+ */
40
+ export declare function resolveStylePreprocessor(config: ResolvedConfig, configured?: StylePreprocessor): Promise<StylePreprocessor | undefined>;
@@ -0,0 +1,61 @@
1
+ import { debugStylePipeline } from "./utils/debug.js";
2
+ import { composeStylePreprocessors } from "./style-preprocessor.js";
3
+ //#region packages/vite-plugin-angular/src/lib/analog-plugin-interop.ts
4
+ var integrationsByConfig = /* @__PURE__ */ new WeakMap();
5
+ /**
6
+ * Runs every `analog.setup()` hook found in the resolved Vite plugin list,
7
+ * once per resolved config, and composes the registrations in plugin order.
8
+ */
9
+ function discoverAnalogIntegrations(config) {
10
+ let pending = integrationsByConfig.get(config);
11
+ if (!pending) {
12
+ pending = runAnalogSetupHooks(config.plugins ?? []);
13
+ integrationsByConfig.set(config, pending);
14
+ }
15
+ return pending;
16
+ }
17
+ async function runAnalogSetupHooks(plugins) {
18
+ const preprocessors = [];
19
+ for (const plugin of plugins) {
20
+ if (typeof plugin.analog?.setup !== "function") continue;
21
+ const registeredBefore = preprocessors.length;
22
+ const context = { registerStylePreprocessor(preprocessor) {
23
+ preprocessors.push(wrapStylePreprocessor(plugin.name, preprocessor));
24
+ } };
25
+ try {
26
+ await plugin.analog.setup(context);
27
+ } catch (error) {
28
+ throw new Error(`[analog] analog.setup() from plugin "${plugin.name}" failed: ${describeError(error)}`);
29
+ }
30
+ debugStylePipeline("analog.setup() completed", {
31
+ plugin: plugin.name,
32
+ stylePreprocessors: preprocessors.length - registeredBefore
33
+ });
34
+ }
35
+ return { stylePreprocessor: composeStylePreprocessors(preprocessors) };
36
+ }
37
+ /**
38
+ * Resolves the stylesheet preprocessor a compilation path should use:
39
+ * plugin-registered preprocessors first, then the chain configured through
40
+ * `angular()` options (Tailwind reference injection, `stylePipeline`,
41
+ * `stylePreprocessor`).
42
+ */
43
+ async function resolveStylePreprocessor(config, configured) {
44
+ return composeStylePreprocessors([(await discoverAnalogIntegrations(config)).stylePreprocessor, configured]);
45
+ }
46
+ function wrapStylePreprocessor(pluginName, preprocessor) {
47
+ return (code, filename, context) => {
48
+ try {
49
+ return preprocessor(code, filename, context);
50
+ } catch (error) {
51
+ throw new Error(`[analog] Style preprocessor from plugin "${pluginName}" failed for "${filename}": ${describeError(error)}`);
52
+ }
53
+ };
54
+ }
55
+ function describeError(error) {
56
+ return error instanceof Error ? error.message : String(error);
57
+ }
58
+ //#endregion
59
+ export { resolveStylePreprocessor };
60
+
61
+ //# sourceMappingURL=analog-plugin-interop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analog-plugin-interop.js","names":[],"sources":["../../../src/lib/analog-plugin-interop.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from 'vite';\nimport {\n composeStylePreprocessors,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport { debugStylePipeline } from './utils/debug.js';\n\n/**\n * Narrow framework context handed to a Vite plugin's `analog.setup()` hook.\n * Only grows when a concrete integration needs another seam.\n */\nexport interface AnalogPluginContext {\n /**\n * Registers a pre-transform that runs on every Angular component stylesheet\n * before it enters Vite's `preprocessCSS` pipeline.\n */\n registerStylePreprocessor(preprocessor: StylePreprocessor): void;\n}\n\nexport interface AnalogPluginHooks {\n setup?(context: AnalogPluginContext): void | Promise<void>;\n}\n\n/**\n * A normal Vite plugin that optionally exposes an `analog` setup hook.\n * Discovery is structural (`plugin.analog?.setup`), so this type is a DX aid\n * rather than a requirement.\n */\nexport type AnalogIntegrationPlugin = Plugin & { analog?: AnalogPluginHooks };\n\nexport interface AnalogIntegrations {\n stylePreprocessor?: StylePreprocessor;\n}\n\nconst integrationsByConfig = new WeakMap<\n ResolvedConfig,\n Promise<AnalogIntegrations>\n>();\n\n/**\n * Runs every `analog.setup()` hook found in the resolved Vite plugin list,\n * once per resolved config, and composes the registrations in plugin order.\n */\nexport function discoverAnalogIntegrations(\n config: ResolvedConfig,\n): Promise<AnalogIntegrations> {\n let pending = integrationsByConfig.get(config);\n if (!pending) {\n pending = runAnalogSetupHooks(config.plugins ?? []);\n integrationsByConfig.set(config, pending);\n }\n return pending;\n}\n\nexport async function runAnalogSetupHooks(\n plugins: readonly Plugin[],\n): Promise<AnalogIntegrations> {\n const preprocessors: StylePreprocessor[] = [];\n\n for (const plugin of plugins as readonly AnalogIntegrationPlugin[]) {\n if (typeof plugin.analog?.setup !== 'function') {\n continue;\n }\n\n const registeredBefore = preprocessors.length;\n const context: AnalogPluginContext = {\n registerStylePreprocessor(preprocessor) {\n preprocessors.push(wrapStylePreprocessor(plugin.name, preprocessor));\n },\n };\n\n try {\n await plugin.analog.setup(context);\n } catch (error) {\n throw new Error(\n `[analog] analog.setup() from plugin \"${plugin.name}\" failed: ${describeError(error)}`,\n );\n }\n\n debugStylePipeline('analog.setup() completed', {\n plugin: plugin.name,\n stylePreprocessors: preprocessors.length - registeredBefore,\n });\n }\n\n return { stylePreprocessor: composeStylePreprocessors(preprocessors) };\n}\n\n/**\n * Resolves the stylesheet preprocessor a compilation path should use:\n * plugin-registered preprocessors first, then the chain configured through\n * `angular()` options (Tailwind reference injection, `stylePipeline`,\n * `stylePreprocessor`).\n */\nexport async function resolveStylePreprocessor(\n config: ResolvedConfig,\n configured?: StylePreprocessor,\n): Promise<StylePreprocessor | undefined> {\n const integrations = await discoverAnalogIntegrations(config);\n return composeStylePreprocessors([\n integrations.stylePreprocessor,\n configured,\n ]);\n}\n\nfunction wrapStylePreprocessor(\n pluginName: string,\n preprocessor: StylePreprocessor,\n): StylePreprocessor {\n return (code, filename, context) => {\n try {\n return preprocessor(code, filename, context);\n } catch (error) {\n throw new Error(\n `[analog] Style preprocessor from plugin \"${pluginName}\" failed for \"${filename}\": ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;AAkCA,IAAM,uCAAuB,IAAI,SAG9B;;;;;AAMH,SAAgB,2BACd,QAC6B;CAC7B,IAAI,UAAU,qBAAqB,IAAI,OAAO;AAC9C,KAAI,CAAC,SAAS;AACZ,YAAU,oBAAoB,OAAO,WAAW,EAAE,CAAC;AACnD,uBAAqB,IAAI,QAAQ,QAAQ;;AAE3C,QAAO;;AAGT,eAAsB,oBACpB,SAC6B;CAC7B,MAAM,gBAAqC,EAAE;AAE7C,MAAK,MAAM,UAAU,SAA+C;AAClE,MAAI,OAAO,OAAO,QAAQ,UAAU,WAClC;EAGF,MAAM,mBAAmB,cAAc;EACvC,MAAM,UAA+B,EACnC,0BAA0B,cAAc;AACtC,iBAAc,KAAK,sBAAsB,OAAO,MAAM,aAAa,CAAC;KAEvE;AAED,MAAI;AACF,SAAM,OAAO,OAAO,MAAM,QAAQ;WAC3B,OAAO;AACd,SAAM,IAAI,MACR,wCAAwC,OAAO,KAAK,YAAY,cAAc,MAAM,GACrF;;AAGH,qBAAmB,4BAA4B;GAC7C,QAAQ,OAAO;GACf,oBAAoB,cAAc,SAAS;GAC5C,CAAC;;AAGJ,QAAO,EAAE,mBAAmB,0BAA0B,cAAc,EAAE;;;;;;;;AASxE,eAAsB,yBACpB,QACA,YACwC;AAExC,QAAO,0BAA0B,EADZ,MAAM,2BAA2B,OAAO,EAE9C,mBACb,WACD,CAAC;;AAGJ,SAAS,sBACP,YACA,cACmB;AACnB,SAAQ,MAAM,UAAU,YAAY;AAClC,MAAI;AACF,UAAO,aAAa,MAAM,UAAU,QAAQ;WACrC,OAAO;AACd,SAAM,IAAI,MACR,4CAA4C,WAAW,gBAAgB,SAAS,KAAK,cAAc,MAAM,GAC1G;;;;AAKP,SAAS,cAAc,OAAwB;AAC7C,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM"}
@@ -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,59 @@
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 { isProdMode } from "./utils/plugin-config.js";
3
+ import { getJsTransformConfigKey } from "./utils/rolldown.js";
4
+ //#region packages/vite-plugin-angular/src/lib/angular-build-optimizer-plugin.ts
5
+ function buildOptimizerPlugin({ jit }) {
6
+ let javascriptTransformer;
7
+ let isProd = false;
8
+ let preserveVendorMaps = false;
9
+ return {
10
+ name: "@analogjs/vite-plugin-angular-optimizer",
11
+ apply(_config, env) {
12
+ return env.command === "build" || process.env.NODE_ENV === "production";
13
+ },
14
+ config(userConfig) {
15
+ isProd = isProdMode(userConfig.mode);
16
+ javascriptTransformer ??= new jt({
17
+ sourcemap: false,
18
+ thirdPartySourcemaps: false,
19
+ advancedOptimizations: isProd,
20
+ jit: true
21
+ }, 1);
22
+ const jsTransformConfigKey = getJsTransformConfigKey();
23
+ return {
24
+ define: isProd ? {
25
+ ngJitMode: "false",
26
+ ngI18nClosureMode: "false",
27
+ ngDevMode: "false",
28
+ ngServerMode: `${!!userConfig.build?.ssr}`
29
+ } : {},
30
+ [jsTransformConfigKey]: { define: isProd ? {
31
+ ngDevMode: "false",
32
+ ngJitMode: "false",
33
+ ngI18nClosureMode: "false",
34
+ ngServerMode: `${!!userConfig.build?.ssr}`
35
+ } : void 0 }
36
+ };
37
+ },
38
+ configResolved(config) {
39
+ preserveVendorMaps = !!config.build.sourcemap;
40
+ },
41
+ transform: {
42
+ filter: { id: /\.[cm]?js(?:\?|$)/ },
43
+ async handler(code, id) {
44
+ const cleanId = id.split("?")[0];
45
+ if (!/fesm20/.test(cleanId)) return {
46
+ code: isProd && !preserveVendorMaps ? code.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, "") : code,
47
+ map: preserveVendorMaps ? null : { mappings: "" }
48
+ };
49
+ const sideEffects = jit && cleanId.includes("@angular/compiler") ? true : false;
50
+ const result = await javascriptTransformer.transformData(cleanId, code, false, sideEffects);
51
+ return { code: Buffer.from(result).toString() };
52
+ }
53
+ }
54
+ };
63
55
  }
56
+ //#endregion
57
+ export { buildOptimizerPlugin };
58
+
64
59
  //# 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 { isProdMode } from './utils/plugin-config.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function buildOptimizerPlugin({\n jit,\n}: {\n supportedBrowsers: string[];\n jit: boolean;\n}): Plugin {\n let javascriptTransformer: InstanceType<typeof JavaScriptTransformer>;\n let isProd = false;\n let preserveVendorMaps = false;\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 javascriptTransformer ??= new JavaScriptTransformer(\n {\n sourcemap: false,\n thirdPartySourcemaps: false,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\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 configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\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 result: Uint8Array = await javascriptTransformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n return {\n code: Buffer.from(result).toString(),\n };\n },\n },\n };\n}\n"],"mappings":";;;;AAKA,SAAgB,qBAAqB,EACnC,OAIS;CACT,IAAI;CACJ,IAAI,SAAS;CACb,IAAI,qBAAqB;AAEzB,QAAO;EACL,MAAM;EASN,MAAM,SAAS,KAAK;AAClB,UACE,IAAI,YAAY,WAAA,QAAA,IAAA,aAAuC;;EAG3D,OAAO,YAAY;AACjB,YAAS,WAAW,WAAW,KAAK;AAGpC,6BAA0B,IAAI,GAC5B;IACE,WAAW;IACX,sBAAsB;IACtB,uBAAuB;IACvB,KAAK;IACN,EACD,EACD;GACD,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,eAAe,QAAQ;AACrB,wBAAqB,CAAC,CAAC,OAAO,MAAM;;EAEtC,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;IACxD,MAAM,SAAqB,MAAM,sBAAsB,cACrD,SACA,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;