@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
@@ -0,0 +1,34 @@
1
+ import { Plugin, ResolvedConfig } from "vite";
2
+ import type { StylePreprocessor } from "./style-preprocessor.js";
3
+ import type { AngularStylePipelineOptions } from "./style-pipeline.js";
4
+ export interface TailwindCssOptions {
5
+ rootStylesheet: string;
6
+ prefixes?: string[];
7
+ }
8
+ export interface TailwindReferencePluginOptions {
9
+ tailwindCss?: TailwindCssOptions;
10
+ }
11
+ export declare function tailwindReferencePlugin(options: TailwindReferencePluginOptions): Plugin;
12
+ /**
13
+ * Builds a resolved stylePreprocessor function from plugin options.
14
+ *
15
+ * When `tailwindCss` is configured, creates an injector that prepends
16
+ * `@reference "<rootStylesheet>"` into component CSS that uses Tailwind
17
+ * utilities. Uses absolute paths because Angular's externalRuntimeStyles
18
+ * serves component CSS as virtual modules (hash-based IDs) with no
19
+ * meaningful directory — relative paths can't resolve from a hash.
20
+ *
21
+ * If both `tailwindCss` and `stylePreprocessor` are provided, they are
22
+ * chained: Tailwind reference injection runs first, then the user's
23
+ * custom preprocessor.
24
+ */
25
+ export declare function buildStylePreprocessor(options?: {
26
+ stylePreprocessor?: StylePreprocessor;
27
+ stylePipeline?: AngularStylePipelineOptions;
28
+ tailwindCss?: TailwindCssOptions;
29
+ }): StylePreprocessor | undefined;
30
+ /**
31
+ * Validates the Tailwind CSS integration configuration and emits actionable
32
+ * warnings for common misconfigurations that cause silent failures.
33
+ */
34
+ export declare function validateTailwindConfig(tailwindCss: TailwindCssOptions | undefined, config: ResolvedConfig, isWatchMode: boolean): void;
@@ -0,0 +1,116 @@
1
+ import { debugTailwind, debugTailwindV } from "./utils/debug.js";
2
+ import { inspectCssTailwindDirectives, throwTailwindReferenceTextError } from "./utils/tailwind-reference.js";
3
+ import { composeStylePreprocessors } from "./style-preprocessor.js";
4
+ import { stylePipelinePreprocessorFromPlugins } from "./style-pipeline.js";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { basename, dirname, isAbsolute } from "node:path";
7
+ import { normalizePath } from "vite";
8
+ //#region packages/vite-plugin-angular/src/lib/tailwind-plugin.ts
9
+ /**
10
+ * Core injection logic shared by both the Vite pre-transform plugin and the
11
+ * Angular style preprocessor. Returns the `@reference`-prepended CSS when
12
+ * injection is needed, or `undefined` when the file should be left alone.
13
+ */
14
+ function injectTailwindReference(code, opts) {
15
+ const directiveState = inspectCssTailwindDirectives(code);
16
+ if (directiveState.hasReferenceDirective || directiveState.hasTailwindImportDirective) return;
17
+ if (!(opts.prefixes ? opts.prefixes.some((p) => directiveState.commentlessCode.includes(p)) : directiveState.commentlessCode.includes("@apply"))) return;
18
+ if (directiveState.hasReferenceText) throwTailwindReferenceTextError(opts.fileId, opts.rootStylesheet);
19
+ return `@reference "${opts.rootStylesheet.replace(/\\/g, "/")}";\n${code}`;
20
+ }
21
+ function tailwindReferencePlugin(options) {
22
+ return {
23
+ name: "@analogjs/vite-plugin-angular:tailwind-reference",
24
+ enforce: "pre",
25
+ transform(code, id) {
26
+ const tw = options.tailwindCss;
27
+ if (!tw || !id.includes(".css")) return;
28
+ if (id.split("?")[0] === tw.rootStylesheet) return;
29
+ const rootBasename = basename(tw.rootStylesheet);
30
+ if (inspectCssTailwindDirectives(code).commentlessCode.includes(rootBasename)) return;
31
+ const result = injectTailwindReference(code, {
32
+ rootStylesheet: tw.rootStylesheet,
33
+ prefixes: tw.prefixes,
34
+ fileId: id
35
+ });
36
+ if (result) debugTailwind("injected @reference via pre-transform", { id: id.split("/").slice(-2).join("/") });
37
+ return result;
38
+ }
39
+ };
40
+ }
41
+ /**
42
+ * Builds a resolved stylePreprocessor function from plugin options.
43
+ *
44
+ * When `tailwindCss` is configured, creates an injector that prepends
45
+ * `@reference "<rootStylesheet>"` into component CSS that uses Tailwind
46
+ * utilities. Uses absolute paths because Angular's externalRuntimeStyles
47
+ * serves component CSS as virtual modules (hash-based IDs) with no
48
+ * meaningful directory — relative paths can't resolve from a hash.
49
+ *
50
+ * If both `tailwindCss` and `stylePreprocessor` are provided, they are
51
+ * chained: Tailwind reference injection runs first, then the user's
52
+ * custom preprocessor.
53
+ */
54
+ function buildStylePreprocessor(options) {
55
+ const userPreprocessor = options?.stylePreprocessor;
56
+ const stylePipelinePreprocessor = stylePipelinePreprocessorFromPlugins(options?.stylePipeline);
57
+ const tw = options?.tailwindCss;
58
+ if (!tw && !userPreprocessor && !stylePipelinePreprocessor) return;
59
+ let tailwindPreprocessor;
60
+ if (tw) {
61
+ const rootStylesheet = tw.rootStylesheet;
62
+ const prefixes = tw.prefixes;
63
+ debugTailwind("configured", {
64
+ rootStylesheet,
65
+ prefixes
66
+ });
67
+ if (!existsSync(rootStylesheet)) console.warn(`[@analogjs/vite-plugin-angular] tailwindCss.rootStylesheet not found at "${rootStylesheet}". @reference directives will point to a non-existent file, which will cause Tailwind CSS errors. Ensure the path is absolute and the file exists.`);
68
+ tailwindPreprocessor = (code, filename) => {
69
+ const result = injectTailwindReference(code, {
70
+ rootStylesheet,
71
+ prefixes,
72
+ fileId: filename
73
+ });
74
+ if (result) {
75
+ debugTailwind("injected @reference via preprocessor", { filename });
76
+ return result;
77
+ }
78
+ debugTailwindV("skip (no injection needed)", { filename });
79
+ return code;
80
+ };
81
+ }
82
+ if (tailwindPreprocessor && (stylePipelinePreprocessor || userPreprocessor)) debugTailwind("chained with style pipeline or user stylePreprocessor");
83
+ return composeStylePreprocessors([
84
+ tailwindPreprocessor,
85
+ stylePipelinePreprocessor,
86
+ userPreprocessor
87
+ ]);
88
+ }
89
+ /**
90
+ * Validates the Tailwind CSS integration configuration and emits actionable
91
+ * warnings for common misconfigurations that cause silent failures.
92
+ */
93
+ function validateTailwindConfig(tailwindCss, config, isWatchMode) {
94
+ const PREFIX = "[@analogjs/vite-plugin-angular]";
95
+ const tw = tailwindCss;
96
+ if (!tw) return;
97
+ if (!isAbsolute(tw.rootStylesheet)) console.warn(`${PREFIX} tailwindCss.rootStylesheet must be an absolute path. Got: "${tw.rootStylesheet}". Use path.resolve(__dirname, '...') in your vite.config to convert it.`);
98
+ const hasTailwindPlugin = config.plugins.some((p) => p.name.startsWith("@tailwindcss/vite") || p.name.startsWith("tailwindcss"));
99
+ if (isWatchMode && !hasTailwindPlugin) throw new Error(`${PREFIX} tailwindCss is configured but no @tailwindcss/vite plugin was found. Component CSS with @apply directives will not be processed.\n\n Fix: npm install @tailwindcss/vite --save-dev\n Then add tailwindcss() to your vite.config plugins array.\n`);
100
+ if (isWatchMode && tw.rootStylesheet) {
101
+ const projectRoot = normalizePath(config.root);
102
+ const normalizedRootStylesheet = normalizePath(tw.rootStylesheet);
103
+ if (!normalizedRootStylesheet.startsWith(projectRoot)) {
104
+ if (!(config.server?.fs?.allow ?? []).some((allowed) => normalizedRootStylesheet.startsWith(normalizePath(allowed)))) console.warn(`${PREFIX} tailwindCss.rootStylesheet is outside the Vite project root. The dev server may reject it with 403.\n\n Root: ${projectRoot}\n Stylesheet: ${tw.rootStylesheet}\n\n Fix: server.fs.allow: ['${dirname(tw.rootStylesheet)}']\n`);
105
+ }
106
+ }
107
+ if (tw.prefixes !== void 0 && tw.prefixes.length === 0) console.warn(`${PREFIX} tailwindCss.prefixes is an empty array. No component stylesheets will receive @reference injection. Either remove the prefixes option (to use @apply detection) or specify your prefixes: ['tw:']\n`);
108
+ if (existsSync(tw.rootStylesheet)) try {
109
+ const rootContent = readFileSync(tw.rootStylesheet, "utf-8");
110
+ if (!rootContent.includes("@import \"tailwindcss\"") && !rootContent.includes("@import 'tailwindcss'")) console.warn(`${PREFIX} tailwindCss.rootStylesheet does not contain @import "tailwindcss". The @reference directive will point to a file without Tailwind configuration.\n\n File: ${tw.rootStylesheet}\n`);
111
+ } catch {}
112
+ }
113
+ //#endregion
114
+ export { buildStylePreprocessor, tailwindReferencePlugin, validateTailwindConfig };
115
+
116
+ //# sourceMappingURL=tailwind-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-plugin.js","names":[],"sources":["../../../src/lib/tailwind-plugin.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { basename, dirname, isAbsolute } from 'node:path';\nimport { normalizePath, Plugin, ResolvedConfig } from 'vite';\nimport {\n inspectCssTailwindDirectives,\n throwTailwindReferenceTextError,\n} from './utils/tailwind-reference.js';\nimport { debugTailwind, debugTailwindV } from './utils/debug.js';\nimport { composeStylePreprocessors } from './style-preprocessor.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { stylePipelinePreprocessorFromPlugins } from './style-pipeline.js';\nimport type { AngularStylePipelineOptions } from './style-pipeline.js';\n\nexport interface TailwindCssOptions {\n rootStylesheet: string;\n prefixes?: string[];\n}\n\nexport interface TailwindReferencePluginOptions {\n tailwindCss?: TailwindCssOptions;\n}\n\n/**\n * Core injection logic shared by both the Vite pre-transform plugin and the\n * Angular style preprocessor. Returns the `@reference`-prepended CSS when\n * injection is needed, or `undefined` when the file should be left alone.\n */\nfunction injectTailwindReference(\n code: string,\n opts: {\n rootStylesheet: string;\n prefixes?: string[];\n fileId: string;\n },\n): string | undefined {\n const directiveState = inspectCssTailwindDirectives(code);\n\n if (\n directiveState.hasReferenceDirective ||\n directiveState.hasTailwindImportDirective\n ) {\n return undefined;\n }\n\n const needsRef = opts.prefixes\n ? opts.prefixes.some((p) => directiveState.commentlessCode.includes(p))\n : directiveState.commentlessCode.includes('@apply');\n\n if (!needsRef) {\n return undefined;\n }\n\n if (directiveState.hasReferenceText) {\n throwTailwindReferenceTextError(opts.fileId, opts.rootStylesheet);\n }\n\n return `@reference \"${opts.rootStylesheet.replace(/\\\\/g, '/')}\";\\n${code}`;\n}\n\nexport function tailwindReferencePlugin(\n options: TailwindReferencePluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:tailwind-reference',\n enforce: 'pre',\n transform(code: string, id: string) {\n const tw = options.tailwindCss;\n if (!tw || !id.includes('.css')) return;\n\n const cleanId = id.split('?')[0];\n if (cleanId === tw.rootStylesheet) return;\n\n // Skip entry stylesheets that @import the root config\n const rootBasename = basename(tw.rootStylesheet);\n const directiveState = inspectCssTailwindDirectives(code);\n if (directiveState.commentlessCode.includes(rootBasename)) return;\n\n const result = injectTailwindReference(code, {\n rootStylesheet: tw.rootStylesheet,\n prefixes: tw.prefixes,\n fileId: id,\n });\n\n if (result) {\n debugTailwind('injected @reference via pre-transform', {\n id: id.split('/').slice(-2).join('/'),\n });\n }\n\n return result;\n },\n };\n}\n\n/**\n * Builds a resolved stylePreprocessor function from plugin options.\n *\n * When `tailwindCss` is configured, creates an injector that prepends\n * `@reference \"<rootStylesheet>\"` into component CSS that uses Tailwind\n * utilities. Uses absolute paths because Angular's externalRuntimeStyles\n * serves component CSS as virtual modules (hash-based IDs) with no\n * meaningful directory — relative paths can't resolve from a hash.\n *\n * If both `tailwindCss` and `stylePreprocessor` are provided, they are\n * chained: Tailwind reference injection runs first, then the user's\n * custom preprocessor.\n */\nexport function buildStylePreprocessor(options?: {\n stylePreprocessor?: StylePreprocessor;\n stylePipeline?: AngularStylePipelineOptions;\n tailwindCss?: TailwindCssOptions;\n}): StylePreprocessor | undefined {\n const userPreprocessor = options?.stylePreprocessor;\n const stylePipelinePreprocessor = stylePipelinePreprocessorFromPlugins(\n options?.stylePipeline,\n );\n const tw = options?.tailwindCss;\n\n if (!tw && !userPreprocessor && !stylePipelinePreprocessor) {\n return undefined;\n }\n\n let tailwindPreprocessor:\n | ((code: string, filename: string) => string)\n | undefined;\n\n if (tw) {\n const rootStylesheet = tw.rootStylesheet;\n const prefixes = tw.prefixes;\n debugTailwind('configured', { rootStylesheet, prefixes });\n\n if (!existsSync(rootStylesheet)) {\n console.warn(\n `[@analogjs/vite-plugin-angular] tailwindCss.rootStylesheet not found ` +\n `at \"${rootStylesheet}\". @reference directives will point to a ` +\n `non-existent file, which will cause Tailwind CSS errors. ` +\n `Ensure the path is absolute and the file exists.`,\n );\n }\n\n tailwindPreprocessor = (code: string, filename: string): string => {\n const result = injectTailwindReference(code, {\n rootStylesheet,\n prefixes,\n fileId: filename,\n });\n\n if (result) {\n debugTailwind('injected @reference via preprocessor', { filename });\n return result;\n }\n\n debugTailwindV('skip (no injection needed)', { filename });\n return code;\n };\n }\n\n if (tailwindPreprocessor && (stylePipelinePreprocessor || userPreprocessor)) {\n debugTailwind('chained with style pipeline or user stylePreprocessor');\n }\n\n return composeStylePreprocessors([\n tailwindPreprocessor,\n stylePipelinePreprocessor,\n userPreprocessor,\n ]);\n}\n\n/**\n * Validates the Tailwind CSS integration configuration and emits actionable\n * warnings for common misconfigurations that cause silent failures.\n */\nexport function validateTailwindConfig(\n tailwindCss: TailwindCssOptions | undefined,\n config: ResolvedConfig,\n isWatchMode: boolean,\n): void {\n const PREFIX = '[@analogjs/vite-plugin-angular]';\n const tw = tailwindCss;\n\n if (!tw) return;\n\n if (!isAbsolute(tw.rootStylesheet)) {\n console.warn(\n `${PREFIX} tailwindCss.rootStylesheet must be an absolute path. ` +\n `Got: \"${tw.rootStylesheet}\". Use path.resolve(__dirname, '...') ` +\n `in your vite.config to convert it.`,\n );\n }\n\n const resolvedPlugins = config.plugins;\n const hasTailwindPlugin = resolvedPlugins.some(\n (p) =>\n p.name.startsWith('@tailwindcss/vite') ||\n p.name.startsWith('tailwindcss'),\n );\n\n if (isWatchMode && !hasTailwindPlugin) {\n throw new Error(\n `${PREFIX} tailwindCss is configured but no @tailwindcss/vite ` +\n `plugin was found. Component CSS with @apply directives will ` +\n `not be processed.\\n\\n` +\n ` Fix: npm install @tailwindcss/vite --save-dev\\n` +\n ` Then add tailwindcss() to your vite.config plugins array.\\n`,\n );\n }\n\n if (isWatchMode && tw.rootStylesheet) {\n const projectRoot = normalizePath(config.root);\n const normalizedRootStylesheet = normalizePath(tw.rootStylesheet);\n if (!normalizedRootStylesheet.startsWith(projectRoot)) {\n const fsAllow = config.server?.fs?.allow ?? [];\n const isAllowed = fsAllow.some((allowed) =>\n normalizedRootStylesheet.startsWith(normalizePath(allowed)),\n );\n if (!isAllowed) {\n console.warn(\n `${PREFIX} tailwindCss.rootStylesheet is outside the Vite ` +\n `project root. The dev server may reject it with 403.\\n\\n` +\n ` Root: ${projectRoot}\\n` +\n ` Stylesheet: ${tw.rootStylesheet}\\n\\n` +\n ` Fix: server.fs.allow: ['${dirname(tw.rootStylesheet)}']\\n`,\n );\n }\n }\n }\n\n if (tw.prefixes !== undefined && tw.prefixes.length === 0) {\n console.warn(\n `${PREFIX} tailwindCss.prefixes is an empty array. No component ` +\n `stylesheets will receive @reference injection. Either remove ` +\n `the prefixes option (to use @apply detection) or specify your ` +\n `prefixes: ['tw:']\\n`,\n );\n }\n\n if (existsSync(tw.rootStylesheet)) {\n try {\n const rootContent = readFileSync(tw.rootStylesheet, 'utf-8');\n if (\n !rootContent.includes('@import \"tailwindcss\"') &&\n !rootContent.includes(\"@import 'tailwindcss'\")\n ) {\n console.warn(\n `${PREFIX} tailwindCss.rootStylesheet does not contain ` +\n `@import \"tailwindcss\". The @reference directive will ` +\n `point to a file without Tailwind configuration.\\n\\n` +\n ` File: ${tw.rootStylesheet}\\n`,\n );\n }\n } catch {\n // Silently skip — existence check already warned in buildStylePreprocessor.\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAS,wBACP,MACA,MAKoB;CACpB,MAAM,iBAAiB,6BAA6B,KAAK;AAEzD,KACE,eAAe,yBACf,eAAe,2BAEf;AAOF,KAAI,EAJa,KAAK,WAClB,KAAK,SAAS,MAAM,MAAM,eAAe,gBAAgB,SAAS,EAAE,CAAC,GACrE,eAAe,gBAAgB,SAAS,SAAS,EAGnD;AAGF,KAAI,eAAe,iBACjB,iCAAgC,KAAK,QAAQ,KAAK,eAAe;AAGnE,QAAO,eAAe,KAAK,eAAe,QAAQ,OAAO,IAAI,CAAC,MAAM;;AAGtE,SAAgB,wBACd,SACQ;AACR,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,MAAc,IAAY;GAClC,MAAM,KAAK,QAAQ;AACnB,OAAI,CAAC,MAAM,CAAC,GAAG,SAAS,OAAO,CAAE;AAGjC,OADgB,GAAG,MAAM,IAAI,CAAC,OACd,GAAG,eAAgB;GAGnC,MAAM,eAAe,SAAS,GAAG,eAAe;AAEhD,OADuB,6BAA6B,KAAK,CACtC,gBAAgB,SAAS,aAAa,CAAE;GAE3D,MAAM,SAAS,wBAAwB,MAAM;IAC3C,gBAAgB,GAAG;IACnB,UAAU,GAAG;IACb,QAAQ;IACT,CAAC;AAEF,OAAI,OACF,eAAc,yCAAyC,EACrD,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,IAAI,EACtC,CAAC;AAGJ,UAAO;;EAEV;;;;;;;;;;;;;;;AAgBH,SAAgB,uBAAuB,SAIL;CAChC,MAAM,mBAAmB,SAAS;CAClC,MA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C5D,CAEC,SAAQ,KACN,GAAG,OAAO,kHAEG,YAAY,kBACN,GAAG,eAAe,gCACN,QAAQ,GAAG,eAAe,CAAC,MAC3D;;;AAKP,KAAI,GAAG,aAAa,KAAA,KAAa,GAAG,SAAS,WAAW,EACtD,SAAQ,KACN,GAAG,OAAO,sMAIX;AAGH,KAAI,WAAW,GAAG,eAAe,CAC/B,KAAI;EACF,MAAM,cAAc,aAAa,GAAG,gBAAgB,QAAQ;AAC5D,MACE,CAAC,YAAY,SAAS,0BAAwB,IAC9C,CAAC,YAAY,SAAS,wBAAwB,CAE9C,SAAQ,KACN,GAAG,OAAO,+JAGG,GAAG,eAAe,IAChC;SAEG"}
@@ -1,8 +1,3 @@
1
1
  {
2
- "name": "@analogjs/vite-plugin-angular-tools",
3
- "version": "0.0.1",
4
- "main": "src/index.js",
5
- "types": "./src/index.d.ts",
6
- "module": "./src/index.js",
7
- "type": "module"
8
- }
2
+ "type": "commonjs"
3
+ }
@@ -1,41 +1,36 @@
1
- import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect';
1
+ let _angular_devkit_architect = require("@angular-devkit/architect");
2
+ //#region packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts
2
3
  async function viteBuilder(options, context) {
3
- const { createBuilder } = await Function('return import("vite")')();
4
- if (!context.target) {
5
- throw new Error('Builder must be executed with a target');
6
- }
7
- const projectConfig = await context.getProjectMetadata(context.target);
8
- const projectName = context.target.project;
9
- const configuration = context.target.configuration || 'production';
10
- const buildTargetSpecifier = `::${configuration}`;
11
- const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');
12
- const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
13
- const rawBuildOptions = await context.getTargetOptions(buildTarget);
14
- const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
15
- const buildConfig = {
16
- configFile: options.configFile,
17
- root: projectConfig.root,
18
- mode: (process.env.NODE_ENV ??
19
- buildOptions.mode ??
20
- configuration),
21
- build: {
22
- outDir: options.outputPath,
23
- sourcemap: !!buildOptions.sourcemap,
24
- },
25
- };
26
- try {
27
- const builder = await createBuilder(buildConfig, false);
28
- await builder.buildApp();
29
- return {
30
- success: true,
31
- };
32
- }
33
- catch (e) {
34
- console.error(e);
35
- return {
36
- success: false,
37
- };
38
- }
4
+ const { createBuilder } = await Function("return import(\"vite\")")();
5
+ if (!context.target) throw new Error("Builder must be executed with a target");
6
+ const projectConfig = await context.getProjectMetadata(context.target);
7
+ const projectName = context.target.project;
8
+ const configuration = context.target.configuration || "production";
9
+ const buildTarget = (0, _angular_devkit_architect.targetFromTargetString)(`::${configuration}`, projectName, "build");
10
+ const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
11
+ const rawBuildOptions = await context.getTargetOptions(buildTarget);
12
+ const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
13
+ const mode = buildOptions.mode ?? configuration;
14
+ if (process.env.NODE_ENV && process.env.NODE_ENV !== mode) context.logger.warn(`NODE_ENV is set to "${process.env.NODE_ENV}" but is ignored because the build resolved mode "${mode}" from the build options and configuration.`);
15
+ const buildConfig = {
16
+ configFile: options.configFile,
17
+ root: projectConfig.root,
18
+ mode,
19
+ build: {
20
+ outDir: options.outputPath,
21
+ sourcemap: !!buildOptions.sourcemap
22
+ }
23
+ };
24
+ try {
25
+ await (await createBuilder(buildConfig, false)).buildApp();
26
+ return { success: true };
27
+ } catch (e) {
28
+ console.error(e);
29
+ return { success: false };
30
+ }
39
31
  }
40
- export default createBuilder(viteBuilder);
32
+ var vite_build_impl_default = (0, _angular_devkit_architect.createBuilder)(viteBuilder);
33
+ //#endregion
34
+ module.exports = vite_build_impl_default;
35
+
41
36
  //# sourceMappingURL=vite-build.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-build.impl.js","sourceRoot":"","sources":["../../../../../../../../../packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACb,sBAAsB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AAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACxD,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEzB,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO;YACL,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC;AACH,CAAC;AAED,eAAe,aAAa,CAAC,WAAW,CAAQ,CAAC"}
1
+ {"version":3,"file":"vite-build.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteBuildSchema } from './schema';\n\nasync function viteBuilder(\n options: ViteBuildSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createBuilder } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const configuration = context.target.configuration || 'production';\n const buildTargetSpecifier = `::${configuration}`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n // Explicit build options and the requested configuration win over an\n // ambient NODE_ENV, so `build:production` cannot silently produce a\n // development build when NODE_ENV happens to be set. See #2458.\n const mode = (buildOptions.mode ?? configuration) as string;\n\n if (process.env.NODE_ENV && process.env.NODE_ENV !== mode) {\n context.logger.warn(\n `NODE_ENV is set to \"${process.env.NODE_ENV}\" but is ignored because the build resolved mode \"${mode}\" from the build options and configuration.`,\n );\n }\n\n const buildConfig: InlineConfig = {\n configFile: options.configFile,\n root: projectConfig.root as string,\n mode,\n build: {\n outDir: options.outputPath,\n sourcemap: !!buildOptions.sourcemap,\n },\n };\n\n try {\n const builder = await createBuilder(buildConfig, false);\n await builder.buildApp();\n\n return {\n success: true,\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n };\n }\n}\n\nexport default createBuilder(viteBuilder) as any;\n"],"mappings":";;AASA,eAAe,YACb,SACA,SACwB;CACxB,MAAM,EAAE,kBAAkB,MAAM,SAAS,0BAAwB,EAAE;AACnE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CACnC,MAAM,gBAAgB,QAAQ,OAAO,iBAAiB;CAEtD,MAAM,eAAA,GAAA,0BAAA,wBADuB,KAAK,iBAGhC,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAKD,MAAM,OAAQ,aAAa,QAAQ;AAEnC,KAAA,QAAA,IAAA,YAAA,QAAA,IAAA,aAAqD,KACnD,SAAQ,OAAO,KACb,uBAAA,QAAA,IAAA,SAA4C,oDAAoD,KAAK,6CACtG;CAGH,MAAM,cAA4B;EAChC,YAAY,QAAQ;EACpB,MAAM,cAAc;EACpB;EACA,OAAO;GACL,QAAQ,QAAQ;GAChB,WAAW,CAAC,CAAC,aAAa;GAC3B;EACF;AAED,KAAI;AAEF,SADgB,MAAM,cAAc,aAAa,MAAM,EACzC,UAAU;AAExB,SAAO,EACL,SAAS,MACV;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO,EACL,SAAS,OACV;;;AAIL,IAAA,2BAAA,GAAA,0BAAA,eAA6B,YAAY"}
@@ -1,65 +1,54 @@
1
- import { createBuilder, targetFromTargetString, } from '@angular-devkit/architect';
1
+ let _angular_devkit_architect = require("@angular-devkit/architect");
2
+ //#region packages/vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts
2
3
  async function viteDevServerBuilder(options, context) {
3
- const { createServer } = await Function('return import("vite")')();
4
- if (!context.target) {
5
- throw new Error('Builder must be executed with a target');
6
- }
7
- const projectConfig = await context.getProjectMetadata(context.target);
8
- const projectName = context.target.project;
9
- const buildTargetSpecifier = options.buildTarget ?? `::development`;
10
- const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');
11
- const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
12
- const rawBuildOptions = await context.getTargetOptions(buildTarget);
13
- const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
14
- const serverConfig = {
15
- configFile: buildOptions.configFile,
16
- root: projectConfig.root,
17
- mode: (process.env.NODE_ENV ??
18
- buildOptions.mode ??
19
- 'development'),
20
- build: {
21
- sourcemap: !!buildOptions.sourcemap,
22
- },
23
- server: {
24
- hmr: options?.hmr,
25
- port: options?.port,
26
- },
27
- };
28
- try {
29
- const server = await createServer(serverConfig);
30
- await runViteDevServer(server);
31
- const resolvedUrls = [
32
- ...server.resolvedUrls.local,
33
- ...server.resolvedUrls.network,
34
- ];
35
- await new Promise((resolve) => {
36
- process.once('SIGINT', () => resolve());
37
- process.once('SIGTERM', () => resolve());
38
- process.once('exit', () => resolve());
39
- });
40
- return {
41
- success: true,
42
- baseUrl: resolvedUrls[0] ?? '',
43
- };
44
- }
45
- catch (e) {
46
- console.error(e);
47
- return {
48
- success: false,
49
- baseUrl: '',
50
- };
51
- }
4
+ const { createServer } = await Function("return import(\"vite\")")();
5
+ if (!context.target) throw new Error("Builder must be executed with a target");
6
+ const projectConfig = await context.getProjectMetadata(context.target);
7
+ const projectName = context.target.project;
8
+ const buildTarget = (0, _angular_devkit_architect.targetFromTargetString)(options.buildTarget ?? `::development`, projectName, "build");
9
+ const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
10
+ const rawBuildOptions = await context.getTargetOptions(buildTarget);
11
+ const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
12
+ const serverConfig = {
13
+ configFile: buildOptions.configFile,
14
+ root: projectConfig.root,
15
+ mode: buildOptions.mode ?? process.env.NODE_ENV ?? "development",
16
+ build: { sourcemap: !!buildOptions.sourcemap },
17
+ server: {
18
+ hmr: options?.hmr,
19
+ port: options?.port
20
+ }
21
+ };
22
+ try {
23
+ const server = await createServer(serverConfig);
24
+ await server.listen();
25
+ server.printUrls();
26
+ const resolvedUrls = [...server.resolvedUrls.local, ...server.resolvedUrls.network];
27
+ const processOnExit = async () => {
28
+ await server.close();
29
+ };
30
+ await new Promise((resolve) => {
31
+ const shutdown = () => {
32
+ processOnExit().then(() => resolve(), () => resolve());
33
+ };
34
+ process.once("SIGINT", shutdown);
35
+ process.once("SIGTERM", shutdown);
36
+ process.once("exit", shutdown);
37
+ });
38
+ return {
39
+ success: true,
40
+ baseUrl: resolvedUrls[0] ?? ""
41
+ };
42
+ } catch (e) {
43
+ console.error(e);
44
+ return {
45
+ success: false,
46
+ baseUrl: ""
47
+ };
48
+ }
52
49
  }
53
- // vite ViteDevServer
54
- async function runViteDevServer(server) {
55
- await server.listen();
56
- server.printUrls();
57
- const processOnExit = async () => {
58
- await server.close();
59
- };
60
- process.once('SIGINT', processOnExit);
61
- process.once('SIGTERM', processOnExit);
62
- process.once('exit', processOnExit);
63
- }
64
- export default createBuilder(viteDevServerBuilder);
50
+ var dev_server_impl_default = (0, _angular_devkit_architect.createBuilder)(viteDevServerBuilder);
51
+ //#endregion
52
+ module.exports = dev_server_impl_default;
53
+
65
54
  //# sourceMappingURL=dev-server.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev-server.impl.js","sourceRoot":"","sources":["../../../../../../../../../packages/vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,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CAAC;AACtC,CAAC;AAED,eAAe,aAAa,CAAC,oBAAoB,CAAQ,CAAC"}
1
+ {"version":3,"file":"dev-server.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteDevServerSchema } from './schema';\n\nasync function viteDevServerBuilder(\n options: ViteDevServerSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createServer } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const buildTargetSpecifier = options.buildTarget ?? `::development`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const serverConfig: InlineConfig = {\n configFile: buildOptions.configFile as string,\n root: projectConfig.root as string,\n // An explicit mode from the build options wins over an ambient NODE_ENV.\n // See #2458.\n mode: (buildOptions.mode ??\n process.env.NODE_ENV ??\n 'development') as string,\n build: {\n sourcemap: !!buildOptions.sourcemap,\n },\n server: {\n hmr: options?.hmr,\n port: options?.port,\n },\n };\n\n try {\n const server = await createServer(serverConfig);\n await server.listen();\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n const processOnExit = async () => {\n await server.close();\n };\n\n // Use process.once to avoid listener accumulation when Nx invokes\n // multiple builders in the same process during a large build graph.\n await new Promise<void>((resolve) => {\n const shutdown = () => {\n processOnExit().then(\n () => resolve(),\n () => resolve(),\n );\n };\n process.once('SIGINT', shutdown);\n process.once('SIGTERM', shutdown);\n process.once('exit', shutdown);\n });\n\n return {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n baseUrl: '',\n };\n }\n}\n\nexport default createBuilder(viteDevServerBuilder) as any;\n"],"mappings":";;AASA,eAAe,qBACb,SACA,SACwB;CACxB,MAAM,EAAE,iBAAiB,MAAM,SAAS,0BAAwB,EAAE;AAClE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CAEnC,MAAM,eAAA,GAAA,0BAAA,wBADuB,QAAQ,eAAe,iBAGlD,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAED,MAAM,eAA6B;EACjC,YAAY,aAAa;EACzB,MAAM,cAAc;EAGpB,MAAO,aAAa,QAAA,QAAA,IAAA,YAElB;EACF,OAAO,EACL,WAAW,CAAC,CAAC,aAAa,WAC3B;EACD,QAAQ;GACN,KAAK,SAAS;GACd,MAAM,SAAS;GAChB;EACF;AAED,KAAI;EACF,MAAM,SAAS,MAAM,aAAa,aAAa;AAC/C,QAAM,OAAO,QAAQ;AACrB,SAAO,WAAW;EAElB,MAAM,eAAe,CACnB,GAAG,OAAO,aAAa,OACvB,GAAG,OAAO,aAAa,QACxB;EAED,MAAM,gBAAgB,YAAY;AAChC,SAAM,OAAO,OAAO;;AAKtB,QAAM,IAAI,SAAe,YAAY;GACnC,MAAM,iBAAiB;AACrB,mBAAe,CAAC,WACR,SAAS,QACT,SAAS,CAChB;;AAEH,WAAQ,KAAK,UAAU,SAAS;AAChC,WAAQ,KAAK,WAAW,SAAS;AACjC,WAAQ,KAAK,QAAQ,SAAS;IAC9B;AAEF,SAAO;GACL,SAAS;GACT,SAAS,aAAa,MAAM;GAC7B;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO;GACL,SAAS;GACT,SAAS;GACV;;;AAIL,IAAA,2BAAA,GAAA,0BAAA,eAA6B,qBAAqB"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,62 @@
1
+ import { AnalogStylesheetRegistry } from "../stylesheet-registry.js";
2
+ import type { StylePreprocessor } from "../style-preprocessor.js";
3
+ import type { FileReplacement } from "../plugins/file-replacements.plugin.js";
4
+ export declare enum DiagnosticModes {
5
+ None = 0,
6
+ Option = 1,
7
+ Syntactic = 2,
8
+ Semantic = 4,
9
+ All = 7
10
+ }
11
+ export declare function injectViteIgnoreForHmrMetadata(code: string): string;
12
+ export declare function isIgnoredHmrFile(file: string): boolean;
13
+ /**
14
+ * Convert Analog/Angular CLI-style file replacements into the flat record
15
+ * expected by `AngularHostOptions.fileReplacements`.
16
+ *
17
+ * Only browser replacements (`{ replace, with }`) are converted. SSR-only
18
+ * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to
19
+ * handle — they should not be baked into the Angular compilation host because
20
+ * that would apply them to both browser and server builds.
21
+ *
22
+ * Relative paths are resolved against `workspaceRoot` so that the host
23
+ * receives the same absolute paths it would get from the Angular CLI.
24
+ */
25
+ export declare function toAngularCompilationFileReplacements(replacements: FileReplacement[], workspaceRoot: string): Record<string, string> | undefined;
26
+ /**
27
+ * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)
28
+ * back to absolute file paths with their associated HMR code and component
29
+ * class name.
30
+ *
31
+ * Angular's private Compilation API emits template update keys in the form
32
+ * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve
33
+ * them so the caller can look up updates by the same normalized absolute path
34
+ * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
35
+ */
36
+ export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap<string, string> | undefined): Map<string, {
37
+ className: string;
38
+ code: string;
39
+ }>;
40
+ export declare function describeStylesheetContent(code: string): {
41
+ length: number;
42
+ digest: string;
43
+ preview: string;
44
+ };
45
+ /**
46
+ * Refreshes any already-served stylesheet records that map back to a changed
47
+ * source file.
48
+ *
49
+ * This is the critical bridge for externalized Angular component styles during
50
+ * HMR. Angular's resource watcher can notice that `/src/...component.css`
51
+ * changed before Angular recompilation has had a chance to repopulate the
52
+ * stylesheet registry. If we emit a CSS update against the existing virtual
53
+ * stylesheet id without first refreshing the registry content, the browser gets
54
+ * a hot update containing stale CSS. By rewriting the existing served records
55
+ * from disk up front, HMR always pushes the latest source content.
56
+ */
57
+ export declare function refreshStylesheetRegistryForFile(file: string, stylesheetRegistry?: AnalogStylesheetRegistry, stylePreprocessor?: StylePreprocessor): void;
58
+ /**
59
+ * Checks for vitest run from the command line
60
+ * @returns boolean
61
+ */
62
+ export declare function isTestWatchMode(args?): boolean;
@@ -0,0 +1,138 @@
1
+ import { debugStylesV } from "./debug.js";
2
+ import { normalizeStylesheetDependencies } from "../style-preprocessor.js";
3
+ import { preprocessStylesheetResult, rewriteRelativeCssImports } from "../stylesheet-registry.js";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { basename, isAbsolute, resolve } from "node:path";
6
+ import { normalizePath } from "vite";
7
+ import { createHash } from "node:crypto";
8
+ //#region packages/vite-plugin-angular/src/lib/utils/compilation-shared.ts
9
+ /**
10
+ * Shared utilities used by both angular-vite-plugin.ts and
11
+ * compilation-api/compilation-api-plugin.ts.
12
+ */
13
+ var DiagnosticModes = /* @__PURE__ */ function(DiagnosticModes) {
14
+ DiagnosticModes[DiagnosticModes["None"] = 0] = "None";
15
+ DiagnosticModes[DiagnosticModes["Option"] = 1] = "Option";
16
+ DiagnosticModes[DiagnosticModes["Syntactic"] = 2] = "Syntactic";
17
+ DiagnosticModes[DiagnosticModes["Semantic"] = 4] = "Semantic";
18
+ DiagnosticModes[DiagnosticModes["All"] = 7] = "All";
19
+ return DiagnosticModes;
20
+ }({});
21
+ function injectViteIgnoreForHmrMetadata(code) {
22
+ let patched = code.replace(/\bimport\(([a-zA-Z_$][\w$]*\.\u0275\u0275getReplaceMetadataURL)/g, "import(/* @vite-ignore */ $1");
23
+ if (patched === code) patched = patched.replace(/import\((\S+getReplaceMetadataURL)/g, "import(/* @vite-ignore */ $1");
24
+ return patched;
25
+ }
26
+ function isIgnoredHmrFile(file) {
27
+ return file.endsWith(".tsbuildinfo");
28
+ }
29
+ /**
30
+ * Convert Analog/Angular CLI-style file replacements into the flat record
31
+ * expected by `AngularHostOptions.fileReplacements`.
32
+ *
33
+ * Only browser replacements (`{ replace, with }`) are converted. SSR-only
34
+ * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to
35
+ * handle — they should not be baked into the Angular compilation host because
36
+ * that would apply them to both browser and server builds.
37
+ *
38
+ * Relative paths are resolved against `workspaceRoot` so that the host
39
+ * receives the same absolute paths it would get from the Angular CLI.
40
+ */
41
+ function toAngularCompilationFileReplacements(replacements, workspaceRoot) {
42
+ const mappedReplacements = replacements.flatMap((replacement) => {
43
+ if (!("with" in replacement)) return [];
44
+ return [[isAbsolute(replacement.replace) ? replacement.replace : resolve(workspaceRoot, replacement.replace), isAbsolute(replacement.with) ? replacement.with : resolve(workspaceRoot, replacement.with)]];
45
+ });
46
+ return mappedReplacements.length ? Object.fromEntries(mappedReplacements) : void 0;
47
+ }
48
+ /**
49
+ * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)
50
+ * back to absolute file paths with their associated HMR code and component
51
+ * class name.
52
+ *
53
+ * Angular's private Compilation API emits template update keys in the form
54
+ * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve
55
+ * them so the caller can look up updates by the same normalized absolute path
56
+ * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
57
+ */
58
+ function mapTemplateUpdatesToFiles(templateUpdates) {
59
+ const updatesByFile = /* @__PURE__ */ new Map();
60
+ templateUpdates?.forEach((code, encodedUpdateId) => {
61
+ const [file, className = ""] = decodeURIComponent(encodedUpdateId).split("@");
62
+ const resolvedFile = normalizePath(resolve(process.cwd(), file));
63
+ updatesByFile.set(resolvedFile, {
64
+ className,
65
+ code
66
+ });
67
+ });
68
+ return updatesByFile;
69
+ }
70
+ function describeStylesheetContent(code) {
71
+ return {
72
+ length: code.length,
73
+ digest: createHash("sha256").update(code).digest("hex").slice(0, 12),
74
+ preview: code.replace(/\s+/g, " ").trim().slice(0, 160)
75
+ };
76
+ }
77
+ /**
78
+ * Refreshes any already-served stylesheet records that map back to a changed
79
+ * source file.
80
+ *
81
+ * This is the critical bridge for externalized Angular component styles during
82
+ * HMR. Angular's resource watcher can notice that `/src/...component.css`
83
+ * changed before Angular recompilation has had a chance to repopulate the
84
+ * stylesheet registry. If we emit a CSS update against the existing virtual
85
+ * stylesheet id without first refreshing the registry content, the browser gets
86
+ * a hot update containing stale CSS. By rewriting the existing served records
87
+ * from disk up front, HMR always pushes the latest source content.
88
+ */
89
+ function refreshStylesheetRegistryForFile(file, stylesheetRegistry, stylePreprocessor) {
90
+ const normalizedFile = normalizePath(file.split("?")[0]);
91
+ if (!stylesheetRegistry || !existsSync(normalizedFile)) return;
92
+ const publicIds = stylesheetRegistry.getPublicIdsForSource(normalizedFile);
93
+ if (publicIds.length === 0) return;
94
+ const rawCss = readFileSync(normalizedFile, "utf-8");
95
+ const preprocessed = preprocessStylesheetResult(rawCss, normalizedFile, stylePreprocessor);
96
+ const servedCss = rewriteRelativeCssImports(preprocessed.code, normalizedFile);
97
+ for (const publicId of publicIds) stylesheetRegistry.registerServedStylesheet({
98
+ publicId,
99
+ sourcePath: normalizedFile,
100
+ originalCode: rawCss,
101
+ normalizedCode: servedCss,
102
+ dependencies: normalizeStylesheetDependencies(preprocessed.dependencies),
103
+ diagnostics: preprocessed.diagnostics,
104
+ tags: preprocessed.tags
105
+ }, [
106
+ normalizedFile,
107
+ normalizePath(normalizedFile),
108
+ basename(normalizedFile),
109
+ normalizedFile.replace(/^\//, "")
110
+ ]);
111
+ debugStylesV("stylesheet registry refreshed from source file", {
112
+ file: normalizedFile,
113
+ publicIds,
114
+ dependencies: preprocessed.dependencies,
115
+ diagnostics: preprocessed.diagnostics,
116
+ tags: preprocessed.tags,
117
+ source: describeStylesheetContent(rawCss),
118
+ served: describeStylesheetContent(servedCss)
119
+ });
120
+ }
121
+ /**
122
+ * Checks for vitest run from the command line
123
+ * @returns boolean
124
+ */
125
+ function isTestWatchMode(args = process.argv) {
126
+ if (args.find((arg) => arg.includes("--run"))) return false;
127
+ if (args.includes("run")) return false;
128
+ if (args.find((arg) => arg.includes("--no-run"))) return true;
129
+ const hasWatch = args.find((arg) => arg.includes("watch"));
130
+ if (hasWatch && ["false", "no"].some((neg) => hasWatch.includes(neg))) return false;
131
+ const watchArg = args[args.findIndex((arg) => arg.includes("watch")) + 1];
132
+ if (watchArg && watchArg === "false") return false;
133
+ return true;
134
+ }
135
+ //#endregion
136
+ export { DiagnosticModes, describeStylesheetContent, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, toAngularCompilationFileReplacements };
137
+
138
+ //# sourceMappingURL=compilation-shared.js.map