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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/README.md +30 -0
  2. package/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
  3. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
  4. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
  5. package/migrations/migration.json +7 -1
  6. package/migrations/migrations.json +9 -0
  7. package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
  8. package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
  9. package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
  10. package/package.json +51 -12
  11. package/src/index.d.ts +5 -2
  12. package/src/index.js +6 -2
  13. package/src/index.js.map +1 -1
  14. package/src/lib/analog-plugin-interop.d.ts +40 -0
  15. package/src/lib/analog-plugin-interop.js +61 -0
  16. package/src/lib/analog-plugin-interop.js.map +1 -0
  17. package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
  18. package/src/lib/angular-build-optimizer-plugin.js +57 -62
  19. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  20. package/src/lib/angular-jit-plugin.d.ts +3 -3
  21. package/src/lib/angular-jit-plugin.js +51 -37
  22. package/src/lib/angular-jit-plugin.js.map +1 -1
  23. package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
  24. package/src/lib/angular-pending-tasks.plugin.js +17 -18
  25. package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
  26. package/src/lib/angular-vite-plugin.d.ts +177 -69
  27. package/src/lib/angular-vite-plugin.js +1227 -1084
  28. package/src/lib/angular-vite-plugin.js.map +1 -1
  29. package/src/lib/angular-vitest-plugin.d.ts +26 -17
  30. package/src/lib/angular-vitest-plugin.js +106 -114
  31. package/src/lib/angular-vitest-plugin.js.map +1 -1
  32. package/src/lib/compilation-api/compilation-api-plugin.d.ts +29 -0
  33. package/src/lib/compilation-api/compilation-api-plugin.js +491 -0
  34. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
  35. package/src/lib/compilation-api/index.d.ts +1 -0
  36. package/src/lib/compilation-api/index.js +1 -0
  37. package/src/lib/compiler/angular-version.d.ts +19 -0
  38. package/src/lib/compiler/angular-version.js +31 -0
  39. package/src/lib/compiler/angular-version.js.map +1 -0
  40. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  41. package/src/lib/compiler/class-field-lowering.js +131 -0
  42. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  43. package/src/lib/compiler/compile.d.ts +50 -0
  44. package/src/lib/compiler/compile.js +814 -0
  45. package/src/lib/compiler/compile.js.map +1 -0
  46. package/src/lib/compiler/constants.d.ts +24 -0
  47. package/src/lib/compiler/constants.js +59 -0
  48. package/src/lib/compiler/constants.js.map +1 -0
  49. package/src/lib/compiler/debug.d.ts +22 -0
  50. package/src/lib/compiler/debug.js +20 -0
  51. package/src/lib/compiler/debug.js.map +1 -0
  52. package/src/lib/compiler/defer.d.ts +57 -0
  53. package/src/lib/compiler/defer.js +154 -0
  54. package/src/lib/compiler/defer.js.map +1 -0
  55. package/src/lib/compiler/dts-reader.d.ts +45 -0
  56. package/src/lib/compiler/dts-reader.js +395 -0
  57. package/src/lib/compiler/dts-reader.js.map +1 -0
  58. package/src/lib/compiler/hmr.d.ts +16 -0
  59. package/src/lib/compiler/hmr.js +69 -0
  60. package/src/lib/compiler/hmr.js.map +1 -0
  61. package/src/lib/compiler/index.d.ts +8 -0
  62. package/src/lib/compiler/index.js +8 -0
  63. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  64. package/src/lib/compiler/jit-metadata.js +168 -0
  65. package/src/lib/compiler/jit-metadata.js.map +1 -0
  66. package/src/lib/compiler/jit-transform.d.ts +24 -0
  67. package/src/lib/compiler/jit-transform.js +204 -0
  68. package/src/lib/compiler/jit-transform.js.map +1 -0
  69. package/src/lib/compiler/js-emitter.d.ts +10 -0
  70. package/src/lib/compiler/js-emitter.js +446 -0
  71. package/src/lib/compiler/js-emitter.js.map +1 -0
  72. package/src/lib/compiler/metadata.d.ts +36 -0
  73. package/src/lib/compiler/metadata.js +710 -0
  74. package/src/lib/compiler/metadata.js.map +1 -0
  75. package/src/lib/compiler/registry.d.ts +56 -0
  76. package/src/lib/compiler/registry.js +176 -0
  77. package/src/lib/compiler/registry.js.map +1 -0
  78. package/src/lib/compiler/resource-inliner.d.ts +43 -0
  79. package/src/lib/compiler/resource-inliner.js +230 -0
  80. package/src/lib/compiler/resource-inliner.js.map +1 -0
  81. package/src/lib/compiler/style-ast.d.ts +9 -0
  82. package/src/lib/compiler/style-ast.js +54 -0
  83. package/src/lib/compiler/style-ast.js.map +1 -0
  84. package/src/lib/compiler/styles.d.ts +13 -0
  85. package/src/lib/compiler/test-helpers.d.ts +7 -0
  86. package/src/lib/compiler/type-elision.d.ts +28 -0
  87. package/src/lib/compiler/type-elision.js +211 -0
  88. package/src/lib/compiler/type-elision.js.map +1 -0
  89. package/src/lib/compiler/utils.d.ts +40 -0
  90. package/src/lib/compiler/utils.js +76 -0
  91. package/src/lib/compiler/utils.js.map +1 -0
  92. package/src/lib/compiler-plugin.d.ts +13 -12
  93. package/src/lib/compiler-plugin.js +40 -44
  94. package/src/lib/compiler-plugin.js.map +1 -1
  95. package/src/lib/component-resolvers.d.ts +23 -5
  96. package/src/lib/component-resolvers.js +107 -64
  97. package/src/lib/component-resolvers.js.map +1 -1
  98. package/src/lib/encapsulation-plugin.d.ts +13 -0
  99. package/src/lib/encapsulation-plugin.js +48 -0
  100. package/src/lib/encapsulation-plugin.js.map +1 -0
  101. package/src/lib/fast-compile-plugin.d.ts +28 -0
  102. package/src/lib/fast-compile-plugin.js +414 -0
  103. package/src/lib/fast-compile-plugin.js.map +1 -0
  104. package/src/lib/host.d.ts +10 -8
  105. package/src/lib/host.js +113 -101
  106. package/src/lib/host.js.map +1 -1
  107. package/src/lib/live-reload-plugin.d.ts +5 -5
  108. package/src/lib/live-reload-plugin.js +61 -63
  109. package/src/lib/live-reload-plugin.js.map +1 -1
  110. package/src/lib/models.d.ts +9 -9
  111. package/src/lib/nx-folder-plugin.d.ts +5 -5
  112. package/src/lib/nx-folder-plugin.js +18 -16
  113. package/src/lib/nx-folder-plugin.js.map +1 -1
  114. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  115. package/src/lib/plugins/file-replacements.plugin.js +40 -62
  116. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  117. package/src/lib/router-plugin.d.ts +1 -1
  118. package/src/lib/router-plugin.js +35 -23
  119. package/src/lib/router-plugin.js.map +1 -1
  120. package/src/lib/style-pipeline.d.ts +15 -0
  121. package/src/lib/style-pipeline.js +31 -0
  122. package/src/lib/style-pipeline.js.map +1 -0
  123. package/src/lib/style-preprocessor.d.ts +35 -0
  124. package/src/lib/style-preprocessor.js +35 -0
  125. package/src/lib/style-preprocessor.js.map +1 -0
  126. package/src/lib/stylesheet-registry.d.ts +74 -0
  127. package/src/lib/stylesheet-registry.js +174 -0
  128. package/src/lib/stylesheet-registry.js.map +1 -0
  129. package/src/lib/tailwind-plugin.d.ts +34 -0
  130. package/src/lib/tailwind-plugin.js +116 -0
  131. package/src/lib/tailwind-plugin.js.map +1 -0
  132. package/src/lib/tools/package.json +2 -7
  133. package/src/lib/tools/src/builders/vite/vite-build.impl.js +33 -38
  134. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  135. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +51 -62
  136. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  137. package/src/lib/tools/src/index.js +0 -2
  138. package/src/lib/utils/compilation-shared.d.ts +62 -0
  139. package/src/lib/utils/compilation-shared.js +138 -0
  140. package/src/lib/utils/compilation-shared.js.map +1 -0
  141. package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
  142. package/src/lib/utils/css-extension-resolver.d.ts +32 -0
  143. package/src/lib/utils/css-extension-resolver.js +73 -0
  144. package/src/lib/utils/css-extension-resolver.js.map +1 -0
  145. package/src/lib/utils/debug-harness.d.ts +23 -0
  146. package/src/lib/utils/debug-harness.js +88 -0
  147. package/src/lib/utils/debug-harness.js.map +1 -0
  148. package/src/lib/utils/debug-log-file.d.ts +5 -0
  149. package/src/lib/utils/debug-log-file.js +56 -0
  150. package/src/lib/utils/debug-log-file.js.map +1 -0
  151. package/src/lib/utils/debug.d.ts +28 -0
  152. package/src/lib/utils/debug.js +39 -0
  153. package/src/lib/utils/debug.js.map +1 -0
  154. package/src/lib/utils/devkit.d.ts +6 -6
  155. package/src/lib/utils/devkit.js +34 -38
  156. package/src/lib/utils/devkit.js.map +1 -1
  157. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  158. package/src/lib/utils/jit-inline-styles.d.ts +3 -0
  159. package/src/lib/utils/jit-inline-styles.js +16 -0
  160. package/src/lib/utils/jit-inline-styles.js.map +1 -0
  161. package/src/lib/utils/plugin-config.d.ts +41 -0
  162. package/src/lib/utils/plugin-config.js +85 -0
  163. package/src/lib/utils/plugin-config.js.map +1 -0
  164. package/src/lib/utils/rolldown.d.ts +2 -0
  165. package/src/lib/utils/rolldown.js +12 -0
  166. package/src/lib/utils/rolldown.js.map +1 -0
  167. package/src/lib/utils/safe-module-paths.d.ts +16 -0
  168. package/src/lib/utils/safe-module-paths.js +29 -0
  169. package/src/lib/utils/safe-module-paths.js.map +1 -0
  170. package/src/lib/utils/source-file-cache.d.ts +8 -15
  171. package/src/lib/utils/source-file-cache.js +35 -37
  172. package/src/lib/utils/source-file-cache.js.map +1 -1
  173. package/src/lib/utils/tailwind-reference.d.ts +12 -0
  174. package/src/lib/utils/tailwind-reference.js +99 -0
  175. package/src/lib/utils/tailwind-reference.js.map +1 -0
  176. package/src/lib/utils/transform-cache.d.ts +43 -0
  177. package/src/lib/utils/transform-cache.js +97 -0
  178. package/src/lib/utils/transform-cache.js.map +1 -0
  179. package/src/lib/utils/tsconfig-resolver.d.ts +28 -0
  180. package/src/lib/utils/tsconfig-resolver.js +191 -0
  181. package/src/lib/utils/tsconfig-resolver.js.map +1 -0
  182. package/src/lib/utils/virtual-ids.d.ts +4 -0
  183. package/src/lib/utils/virtual-ids.js +23 -0
  184. package/src/lib/utils/virtual-ids.js.map +1 -0
  185. package/src/lib/utils/virtual-resources.d.ts +19 -0
  186. package/src/lib/utils/virtual-resources.js +38 -0
  187. package/src/lib/utils/virtual-resources.js.map +1 -0
  188. package/src/lib/virtual-modules-plugin.d.ts +5 -0
  189. package/src/lib/virtual-modules-plugin.js +23 -0
  190. package/src/lib/virtual-modules-plugin.js.map +1 -0
  191. package/src/test-setup.d.ts +2 -0
  192. package/setup-vitest.d.ts +0 -4
  193. package/setup-vitest.js +0 -215
  194. package/setup-vitest.js.map +0 -1
  195. package/src/lib/models.js +0 -1
  196. package/src/lib/models.js.map +0 -1
  197. package/src/lib/tools/README.md +0 -3
  198. package/src/lib/tools/src/index.d.ts +0 -0
  199. package/src/lib/tools/src/index.js.map +0 -1
  200. package/src/lib/utils/compiler-plugin-options.js +0 -1
  201. package/src/lib/utils/compiler-plugin-options.js.map +0 -1
  202. package/src/lib/utils/hmr-candidates.js +0 -272
  203. package/src/lib/utils/hmr-candidates.js.map +0 -1
@@ -1,32 +1,32 @@
1
1
  /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.dev/license
7
- */
8
- import { NgtscProgram } from '@angular/compiler-cli';
9
- import ts from 'typescript';
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { NgtscProgram } from "@angular/compiler-cli";
9
+ import ts from "typescript";
10
10
  /**
11
- * Analyzes one or more modified files for changes to determine if any
12
- * class declarations for Angular components are candidates for hot
13
- * module replacement (HMR). If any source files are also modified but
14
- * are not candidates then all candidates become invalid. This invalidation
15
- * ensures that a full rebuild occurs and the running application stays
16
- * synchronized with the code.
17
- * @param modifiedFiles A set of modified files to analyze.
18
- * @param param1 An Angular compiler instance
19
- * @param staleSourceFiles A map of paths to previous source file instances.
20
- * @returns A set of HMR candidate component class declarations.
21
- */
11
+ * Analyzes one or more modified files for changes to determine if any
12
+ * class declarations for Angular components are candidates for hot
13
+ * module replacement (HMR). If any source files are also modified but
14
+ * are not candidates then all candidates become invalid. This invalidation
15
+ * ensures that a full rebuild occurs and the running application stays
16
+ * synchronized with the code.
17
+ * @param modifiedFiles A set of modified files to analyze.
18
+ * @param param1 An Angular compiler instance
19
+ * @param staleSourceFiles A map of paths to previous source file instances.
20
+ * @returns A set of HMR candidate component class declarations.
21
+ */
22
22
  export declare function collectHmrCandidates(modifiedFiles: Set<string>, { compiler }: NgtscProgram, staleSourceFiles: Map<string, ts.SourceFile> | undefined): Set<ts.ClassDeclaration>;
23
23
  /**
24
- * Analyzes the updates of a source file for potential HMR component class candidates.
25
- * A source file can contain candidates if only the Angular component metadata of a class
26
- * has been changed and the metadata changes are only of supported fields.
27
- * @param stale The stale (previous) source file instance.
28
- * @param updated The updated source file instance.
29
- * @param compiler An Angular compiler instance.
30
- * @returns An array of candidate class declarations; or `null` if unsupported changes are present.
31
- */
32
- export declare function analyzeFileUpdates(stale: ts.SourceFile, updated: ts.SourceFile, compiler: NgtscProgram['compiler']): ts.ClassDeclaration[] | null;
24
+ * Analyzes the updates of a source file for potential HMR component class candidates.
25
+ * A source file can contain candidates if only the Angular component metadata of a class
26
+ * has been changed and the metadata changes are only of supported fields.
27
+ * @param stale The stale (previous) source file instance.
28
+ * @param updated The updated source file instance.
29
+ * @param compiler An Angular compiler instance.
30
+ * @returns An array of candidate class declarations; or `null` if unsupported changes are present.
31
+ */
32
+ export declare function analyzeFileUpdates(stale: ts.SourceFile, updated: ts.SourceFile, compiler: NgtscProgram["compiler"]): ts.ClassDeclaration[] | null;
@@ -0,0 +1,3 @@
1
+ export declare const JIT_INLINE_STYLE_PREFIX = "virtual:angular:jit:style:inline;";
2
+ export declare function toJitInlineStyleId(encodedStyles: string): string;
3
+ export declare function getJitInlineStyles(hash: string): string | undefined;
@@ -0,0 +1,16 @@
1
+ import { createHash } from "node:crypto";
2
+ //#region packages/vite-plugin-angular/src/lib/utils/jit-inline-styles.ts
3
+ var JIT_INLINE_STYLE_PREFIX = "virtual:angular:jit:style:inline;";
4
+ var inlineStyles = /* @__PURE__ */ new Map();
5
+ function toJitInlineStyleId(encodedStyles) {
6
+ const hash = createHash("sha256").update(encodedStyles).digest("hex").slice(0, 16);
7
+ inlineStyles.set(hash, encodedStyles);
8
+ return `${JIT_INLINE_STYLE_PREFIX}${hash}`;
9
+ }
10
+ function getJitInlineStyles(hash) {
11
+ return inlineStyles.get(hash);
12
+ }
13
+ //#endregion
14
+ export { JIT_INLINE_STYLE_PREFIX, getJitInlineStyles, toJitInlineStyleId };
15
+
16
+ //# sourceMappingURL=jit-inline-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jit-inline-styles.js","names":[],"sources":["../../../../src/lib/utils/jit-inline-styles.ts"],"sourcesContent":["// Angular's JIT resource transformer emits inline component styles as\n// `angular:jit:style:inline;<base64 of the whole stylesheet>`. Keeping that\n// payload in the module id makes the emitted chunk name grow with the\n// stylesheet, so a large inline style blows past the 255-byte filename\n// limit and the build fails with ENAMETOOLONG. Hash the payload into the\n// id and keep the base64 in a lookup table instead. (#2459)\n\nimport { createHash } from 'node:crypto';\n\nexport const JIT_INLINE_STYLE_PREFIX = 'virtual:angular:jit:style:inline;';\n\nconst inlineStyles = new Map<string, string>();\n\nexport function toJitInlineStyleId(encodedStyles: string): string {\n const hash = createHash('sha256')\n .update(encodedStyles)\n .digest('hex')\n .slice(0, 16);\n inlineStyles.set(hash, encodedStyles);\n return `${JIT_INLINE_STYLE_PREFIX}${hash}`;\n}\n\nexport function getJitInlineStyles(hash: string): string | undefined {\n return inlineStyles.get(hash);\n}\n"],"mappings":";;AASA,IAAa,0BAA0B;AAEvC,IAAM,+BAAe,IAAI,KAAqB;AAE9C,SAAgB,mBAAmB,eAA+B;CAChE,MAAM,OAAO,WAAW,SAAS,CAC9B,OAAO,cAAc,CACrB,OAAO,MAAM,CACb,MAAM,GAAG,GAAG;AACf,cAAa,IAAI,MAAM,cAAc;AACrC,QAAO,GAAG,0BAA0B;;AAGtC,SAAgB,mBAAmB,MAAkC;AACnE,QAAO,aAAa,IAAI,KAAK"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * TypeScript file extension regex
3
+ * Match .ts / .cts / .mts extensions with an optional ?query suffix.
4
+ * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via
5
+ * a negative-lookahead on a following ASCII letter, so only genuine TS
6
+ * files pass.
7
+ *
8
+ * Previous form `/\.[cm]?(ts)[^x]?\??/` was intended to exclude `.tsx`
9
+ * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows
10
+ * zero characters, and any non-`x` letter was admitted — so `.tsrx`
11
+ * and similar extensions matched by accident.
12
+ */
13
+ export declare const TS_EXT_REGEX: unknown;
14
+ /**
15
+ * Resolves whether Angular should be compiled for production. An explicit
16
+ * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by
17
+ * `storybook build` at CLI entry), so a build can opt into Angular's
18
+ * development compilation. See #2458 and #2462.
19
+ */
20
+ export declare function isProdMode(mode: string | undefined): boolean;
21
+ export interface TsConfigResolutionContext {
22
+ root: string;
23
+ isProd: boolean;
24
+ isLib: boolean;
25
+ }
26
+ export declare function getTsConfigPath(root: string, tsconfig: string, isProd: boolean, isTest: boolean, isLib: boolean, workspaceRoot?: string);
27
+ export declare function createTsConfigGetter(tsconfigOrGetter?: string | (() => string));
28
+ export interface DepOptimizerOptions {
29
+ tsconfig: string;
30
+ isProd: boolean;
31
+ jit: boolean;
32
+ watchMode: boolean;
33
+ isTest: boolean;
34
+ isAstroIntegration: boolean;
35
+ }
36
+ export declare function createDepOptimizerConfig(opts: DepOptimizerOptions): {
37
+ optimizeDeps: {
38
+ include: unknown;
39
+ exclude: unknown;
40
+ };
41
+ };
@@ -0,0 +1,85 @@
1
+ import { createCompilerPlugin, createRolldownCompilerPlugin } from "../compiler-plugin.js";
2
+ import { createPersistentTransformCache, resolveTransformCacheDir } from "./transform-cache.js";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, isAbsolute, resolve } from "node:path";
5
+ import * as vite from "vite";
6
+ //#region packages/vite-plugin-angular/src/lib/utils/plugin-config.ts
7
+ /**
8
+ * TypeScript file extension regex
9
+ * Match .ts / .cts / .mts extensions with an optional ?query suffix.
10
+ * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via
11
+ * a negative-lookahead on a following ASCII letter, so only genuine TS
12
+ * files pass.
13
+ *
14
+ * Previous form `/\.[cm]?(ts)[^x]?\??/` was intended to exclude `.tsx`
15
+ * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows
16
+ * zero characters, and any non-`x` letter was admitted — so `.tsrx`
17
+ * and similar extensions matched by accident.
18
+ */
19
+ var TS_EXT_REGEX = /\.[cm]?ts(?![a-z])/;
20
+ /**
21
+ * Resolves whether Angular should be compiled for production. An explicit
22
+ * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by
23
+ * `storybook build` at CLI entry), so a build can opt into Angular's
24
+ * development compilation. See #2458 and #2462.
25
+ */
26
+ function isProdMode(mode) {
27
+ if (mode === "development") return false;
28
+ return mode === "production" || process.env.NODE_ENV === "production";
29
+ }
30
+ function getTsConfigPath(root, tsconfig, isProd, isTest, isLib, workspaceRoot) {
31
+ if (tsconfig && isAbsolute(tsconfig)) {
32
+ if (!existsSync(tsconfig)) console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
33
+ return tsconfig;
34
+ }
35
+ let tsconfigFilePath = "./tsconfig.app.json";
36
+ if (isLib) tsconfigFilePath = isProd ? "./tsconfig.lib.prod.json" : "./tsconfig.lib.json";
37
+ if (isTest) tsconfigFilePath = "./tsconfig.spec.json";
38
+ if (tsconfig) tsconfigFilePath = tsconfig;
39
+ const resolvedPath = resolve(root, tsconfigFilePath);
40
+ if (existsSync(resolvedPath)) return resolvedPath;
41
+ const workspacePath = workspaceRoot ? resolve(workspaceRoot, tsconfigFilePath) : void 0;
42
+ if (workspacePath && existsSync(workspacePath)) return workspacePath;
43
+ const attemptedPaths = workspacePath && workspacePath !== resolvedPath ? `${resolvedPath} or ${workspacePath}` : resolvedPath;
44
+ console.error(`[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the "tsconfig" property with an absolute path.`);
45
+ return resolvedPath;
46
+ }
47
+ function createTsConfigGetter(tsconfigOrGetter) {
48
+ if (typeof tsconfigOrGetter === "function") return tsconfigOrGetter;
49
+ return () => tsconfigOrGetter || "";
50
+ }
51
+ function createDepOptimizerConfig(opts) {
52
+ const defineOptions = {
53
+ ngJitMode: "false",
54
+ ngI18nClosureMode: "false",
55
+ ...opts.watchMode ? {} : { ngDevMode: "false" }
56
+ };
57
+ const transformCacheDir = resolveTransformCacheDir(dirname(opts.tsconfig));
58
+ const transformCache = transformCacheDir ? createPersistentTransformCache(transformCacheDir) : void 0;
59
+ const rolldownOptions = { plugins: [createRolldownCompilerPlugin({
60
+ tsconfig: opts.tsconfig,
61
+ sourcemap: !opts.isProd,
62
+ advancedOptimizations: opts.isProd,
63
+ jit: opts.jit,
64
+ incremental: opts.watchMode
65
+ }, opts.isTest, !opts.isAstroIntegration, transformCache)] };
66
+ const esbuildOptions = {
67
+ plugins: [createCompilerPlugin({
68
+ tsconfig: opts.tsconfig,
69
+ sourcemap: !opts.isProd,
70
+ advancedOptimizations: opts.isProd,
71
+ jit: opts.jit,
72
+ incremental: opts.watchMode
73
+ }, opts.isTest, !opts.isAstroIntegration, transformCache)],
74
+ define: defineOptions
75
+ };
76
+ return { optimizeDeps: {
77
+ include: ["rxjs/operators", "rxjs"],
78
+ exclude: ["@angular/platform-server"],
79
+ ...vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }
80
+ } };
81
+ }
82
+ //#endregion
83
+ export { TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath, isProdMode };
84
+
85
+ //# sourceMappingURL=plugin-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-config.js","names":[],"sources":["../../../../src/lib/utils/plugin-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport * as vite from 'vite';\n\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n createPersistentTransformCache,\n resolveTransformCacheDir,\n} from './transform-cache.js';\n\n/**\n * TypeScript file extension regex\n * Match .ts / .cts / .mts extensions with an optional ?query suffix.\n * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via\n * a negative-lookahead on a following ASCII letter, so only genuine TS\n * files pass.\n *\n * Previous form `/\\.[cm]?(ts)[^x]?\\??/` was intended to exclude `.tsx`\n * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows\n * zero characters, and any non-`x` letter was admitted — so `.tsrx`\n * and similar extensions matched by accident.\n */\nexport const TS_EXT_REGEX = /\\.[cm]?ts(?![a-z])/;\n\n/**\n * Resolves whether Angular should be compiled for production. An explicit\n * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by\n * `storybook build` at CLI entry), so a build can opt into Angular's\n * development compilation. See #2458 and #2462.\n */\nexport function isProdMode(mode: string | undefined): boolean {\n if (mode === 'development') {\n return false;\n }\n\n return mode === 'production' || process.env['NODE_ENV'] === 'production';\n}\n\nexport interface TsConfigResolutionContext {\n root: string;\n isProd: boolean;\n isLib: boolean;\n}\n\nexport function getTsConfigPath(\n root: string,\n tsconfig: string,\n isProd: boolean,\n isTest: boolean,\n isLib: boolean,\n workspaceRoot?: string,\n) {\n if (tsconfig && isAbsolute(tsconfig)) {\n if (!existsSync(tsconfig)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return tsconfig;\n }\n\n let tsconfigFilePath = './tsconfig.app.json';\n\n if (isLib) {\n tsconfigFilePath = isProd\n ? './tsconfig.lib.prod.json'\n : './tsconfig.lib.json';\n }\n\n if (isTest) {\n tsconfigFilePath = './tsconfig.spec.json';\n }\n\n if (tsconfig) {\n tsconfigFilePath = tsconfig;\n }\n\n const resolvedPath = resolve(root, tsconfigFilePath);\n\n if (existsSync(resolvedPath)) {\n return resolvedPath;\n }\n\n // Callers such as Storybook's Angular builder document their `tsConfig` as\n // workspace-relative while setting the Vite root to the project directory,\n // so the path joins onto the project root twice. Fall back to the workspace\n // root before failing.\n const workspacePath = workspaceRoot\n ? resolve(workspaceRoot, tsconfigFilePath)\n : undefined;\n\n if (workspacePath && existsSync(workspacePath)) {\n return workspacePath;\n }\n\n const attemptedPaths =\n workspacePath && workspacePath !== resolvedPath\n ? `${resolvedPath} or ${workspacePath}`\n : resolvedPath;\n\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n\n return resolvedPath;\n}\n\nexport function createTsConfigGetter(\n tsconfigOrGetter?: string | (() => string),\n) {\n if (typeof tsconfigOrGetter === 'function') {\n return tsconfigOrGetter;\n }\n\n return () => tsconfigOrGetter || '';\n}\n\nexport interface DepOptimizerOptions {\n tsconfig: string;\n isProd: boolean;\n jit: boolean;\n watchMode: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n}\n\nexport function createDepOptimizerConfig(opts: DepOptimizerOptions) {\n const defineOptions = {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ...(opts.watchMode ? {} : { ngDevMode: 'false' }),\n };\n\n // Persist linked dependency output across dep-optimizer runs. The\n // transformer's own key covers file bytes + options, and the directory\n // is namespaced by Angular version, so entries never go stale.\n const transformCacheDir = resolveTransformCacheDir(dirname(opts.tsconfig));\n const transformCache = transformCacheDir\n ? createPersistentTransformCache(transformCacheDir)\n : undefined;\n\n const rolldownOptions: vite.DepOptimizationOptions['rolldownOptions'] = {\n plugins: [\n createRolldownCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n };\n\n const esbuildOptions: vite.DepOptimizationOptions['esbuildOptions'] = {\n plugins: [\n createCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n define: defineOptions,\n };\n\n // No top-level `resolve` block: the `style` package-export condition\n // is now scoped to `.css`-extension requests via\n // `cssExtensionStyleResolverPlugin`, so this dep optimizer config no\n // longer needs to leak it into Vite's global `resolve.conditions`.\n return {\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs'],\n exclude: ['@angular/platform-server'],\n ...(vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAa,eAAe;;;;;;;AAQ5B,SAAgB,WAAW,MAAmC;AAC5D,KAAI,SAAS,cACX,QAAO;AAGT,QAAO,SAAS,gBAAA,QAAA,IAAA,aAA4C;;AAS9D,SAAgB,gBACd,MACA,UACA,QACA,QACA,OACA,eACA;AACA,KAAI,YAAY,WAAW,SAAS,EAAE;AACpC,MAAI,CAAC,WAAW,SAAS,CACvB,SAAQ,MACN,kEAAkE,SAAS,wGAC5E;AAGH,SAAO;;CAGT,IAAI,mBAAmB;AAEvB,KAAI,MACF,oBAAmB,SACf,6BACA;AAGN,KAAI,OACF,oBAAmB;AAGrB,KAAI,SACF,oBAAmB;CAGrB,MAAM,eAAe,QAAQ,MAAM,iBAAiB;AAEpD,KAAI,WAAW,aAAa,CAC1B,QAAO;CAOT,MAAM,gBAAgB,gBAClB,QAAQ,eAAe,iBAAiB,GACxC,KAAA;AAEJ,KAAI,iBAAiB,WAAW,cAAc,CAC5C,QAAO;CAGT,MAAM,iBACJ,iBAAiB,kBAAkB,eAC/B,GAAG,aAAa,MAAM,kBACtB;AAEN,SAAQ,MACN,kEAAkE,eAAe,wGAClF;AAED,QAAO;;AAGT,SAAgB,qBACd,kBACA;AACA,KAAI,OAAO,qBAAqB,WAC9B,QAAO;AAGT,cAAa,oBAAoB;;AAYnC,SAAgB,yBAAyB,MAA2B;CAClE,MAAM,gBAAgB;EACpB,WAAW;EACX,mBAAmB;EACnB,GAAI,KAAK,YAAY,EAAE,GAAG,EAAE,WAAW,SAAS;EACjD;CAKD,MAAM,oBAAoB,yBAAyB,QAAQ,KAAK,SAAS,CAAC;CAC1E,MAAM,iBAAiB,oBACnB,+BAA+B,kBAAkB,GACjD,KAAA;CAEJ,MAAM,kBAAkE,EACtE,SAAS,CACP,6BACE;EACE,UAAU,KAAK;EACf,WAAW,CAAC,KAAK;EACjB,uBAAuB,KAAK;EAC5B,KAAK,KAAK;EACV,aAAa,KAAK;EACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF,EACF;CAED,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;GACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF;EACD,QAAQ;EACT;AAMD,QAAO,EACL,cAAc;EACZ,SAAS,CAAC,kBAAkB,OAAO;EACnC,SAAS,CAAC,2BAA2B;EACrC,GAAI,KAAK,kBAAkB,EAAE,iBAAiB,GAAG,EAAE,gBAAgB;EACpE,EACF"}
@@ -0,0 +1,2 @@
1
+ export declare function isRolldown(): boolean;
2
+ export declare function getJsTransformConfigKey(): "oxc" | "esbuild";
@@ -0,0 +1,12 @@
1
+ import * as vite from "vite";
2
+ //#region packages/vite-plugin-angular/src/lib/utils/rolldown.ts
3
+ function isRolldown() {
4
+ return !!vite.rolldownVersion;
5
+ }
6
+ function getJsTransformConfigKey() {
7
+ return isRolldown() ? "oxc" : "esbuild";
8
+ }
9
+ //#endregion
10
+ export { getJsTransformConfigKey, isRolldown };
11
+
12
+ //# sourceMappingURL=rolldown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rolldown.js","names":[],"sources":["../../../../src/lib/utils/rolldown.ts"],"sourcesContent":["import * as vite from 'vite';\n\nexport function isRolldown(): boolean {\n return !!vite.rolldownVersion;\n}\n\nexport function getJsTransformConfigKey(): 'oxc' | 'esbuild' {\n return isRolldown() ? 'oxc' : 'esbuild';\n}\n"],"mappings":";;AAEA,SAAgB,aAAsB;AACpC,QAAO,CAAC,CAAC,KAAK;;AAGhB,SAAgB,0BAA6C;AAC3D,QAAO,YAAY,GAAG,QAAQ"}
@@ -0,0 +1,16 @@
1
+ import { type ResolvedConfig } from "vite";
2
+ /**
3
+ * Mark a style file path as safe in Vite's `safeModulePaths` set so the
4
+ * `?inline` import passes the Denied ID security check without needing
5
+ * the plugin to intercept the load.
6
+ *
7
+ * Vite's own import-analysis transform does the same thing (adds the clean
8
+ * URL to `safeModulePaths` during transform). We additionally add the
9
+ * `?inline` form because `isServerAccessDeniedForTransform` checks *both*
10
+ * `cleanUrl(id)` and the full `id` (with query) against the allow list.
11
+ *
12
+ * This lets `?inline` CSS flow through Vite's native CSS pipeline, which
13
+ * handles preprocessing, `test.css` semantics, and browser-vs-node
14
+ * differences without the plugin having to reimplement any of it.
15
+ */
16
+ export declare function markStylePathSafe(config: ResolvedConfig | undefined, absPath: string): void;
@@ -0,0 +1,29 @@
1
+ import { normalizePath } from "vite";
2
+ //#region packages/vite-plugin-angular/src/lib/utils/safe-module-paths.ts
3
+ /**
4
+ * Mark a style file path as safe in Vite's `safeModulePaths` set so the
5
+ * `?inline` import passes the Denied ID security check without needing
6
+ * the plugin to intercept the load.
7
+ *
8
+ * Vite's own import-analysis transform does the same thing (adds the clean
9
+ * URL to `safeModulePaths` during transform). We additionally add the
10
+ * `?inline` form because `isServerAccessDeniedForTransform` checks *both*
11
+ * `cleanUrl(id)` and the full `id` (with query) against the allow list.
12
+ *
13
+ * This lets `?inline` CSS flow through Vite's native CSS pipeline, which
14
+ * handles preprocessing, `test.css` semantics, and browser-vs-node
15
+ * differences without the plugin having to reimplement any of it.
16
+ */
17
+ function markStylePathSafe(config, absPath) {
18
+ if (!config) return;
19
+ const normalized = normalizePath(absPath);
20
+ const safeModulePaths = config.safeModulePaths;
21
+ if (safeModulePaths) {
22
+ safeModulePaths.add(normalized);
23
+ safeModulePaths.add(normalized + "?inline");
24
+ }
25
+ }
26
+ //#endregion
27
+ export { markStylePathSafe };
28
+
29
+ //# sourceMappingURL=safe-module-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-module-paths.js","names":[],"sources":["../../../../src/lib/utils/safe-module-paths.ts"],"sourcesContent":["import { normalizePath, type ResolvedConfig } from 'vite';\n\n/**\n * Mark a style file path as safe in Vite's `safeModulePaths` set so the\n * `?inline` import passes the Denied ID security check without needing\n * the plugin to intercept the load.\n *\n * Vite's own import-analysis transform does the same thing (adds the clean\n * URL to `safeModulePaths` during transform). We additionally add the\n * `?inline` form because `isServerAccessDeniedForTransform` checks *both*\n * `cleanUrl(id)` and the full `id` (with query) against the allow list.\n *\n * This lets `?inline` CSS flow through Vite's native CSS pipeline, which\n * handles preprocessing, `test.css` semantics, and browser-vs-node\n * differences without the plugin having to reimplement any of it.\n */\nexport function markStylePathSafe(\n config: ResolvedConfig | undefined,\n absPath: string,\n): void {\n if (!config) return;\n const normalized = normalizePath(absPath);\n const safeModulePaths = (config as any).safeModulePaths as\n | Set<string>\n | undefined;\n if (safeModulePaths) {\n safeModulePaths.add(normalized);\n safeModulePaths.add(normalized + '?inline');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,kBACd,QACA,SACM;AACN,KAAI,CAAC,OAAQ;CACb,MAAM,aAAa,cAAc,QAAQ;CACzC,MAAM,kBAAmB,OAAe;AAGxC,KAAI,iBAAiB;AACnB,kBAAgB,IAAI,WAAW;AAC/B,kBAAgB,IAAI,aAAa,UAAU"}
@@ -1,17 +1,10 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import type ts from 'typescript';
1
+ import type ts from "typescript";
9
2
  export declare class SourceFileCache extends Map<string, ts.SourceFile> {
10
- readonly persistentCachePath?: string | undefined;
11
- readonly modifiedFiles: Set<string>;
12
- readonly babelFileCache: Map<string, Uint8Array>;
13
- readonly typeScriptFileCache: Map<string, string | Uint8Array>;
14
- referencedFiles?: readonly string[];
15
- constructor(persistentCachePath?: string | undefined);
16
- invalidate(files: Iterable<string>): void;
3
+ readonly persistentCachePath?: string | undefined;
4
+ readonly modifiedFiles: Set<string>;
5
+ readonly babelFileCache: Map<string, Uint8Array>;
6
+ readonly typeScriptFileCache: Map<string, string | Uint8Array>;
7
+ referencedFiles?: readonly string[];
8
+ constructor(persistentCachePath?: string | undefined);
9
+ invalidate(files: Iterable<string>): void;
17
10
  }
@@ -1,39 +1,37 @@
1
+ import * as path$1 from "node:path";
2
+ import { platform } from "node:os";
3
+ import { pathToFileURL } from "node:url";
4
+ //#region packages/vite-plugin-angular/src/lib/utils/source-file-cache.ts
1
5
  /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { platform } from 'node:os';
9
- import * as path from 'node:path';
10
- import { pathToFileURL } from 'node:url';
11
- const USING_WINDOWS = platform() === 'win32';
12
- const WINDOWS_SEP_REGEXP = new RegExp(`\\${path.win32.sep}`, 'g');
13
- export class SourceFileCache extends Map {
14
- persistentCachePath;
15
- modifiedFiles = new Set();
16
- babelFileCache = new Map();
17
- typeScriptFileCache = new Map();
18
- referencedFiles;
19
- constructor(persistentCachePath) {
20
- super();
21
- this.persistentCachePath = persistentCachePath;
22
- }
23
- invalidate(files) {
24
- if (files !== this.modifiedFiles) {
25
- this.modifiedFiles.clear();
26
- }
27
- for (let file of files) {
28
- this.babelFileCache.delete(file);
29
- this.typeScriptFileCache.delete(pathToFileURL(file).href);
30
- // Normalize separators to allow matching TypeScript Host paths
31
- if (USING_WINDOWS) {
32
- file = file.replace(WINDOWS_SEP_REGEXP, path.posix.sep);
33
- }
34
- this.delete(file);
35
- this.modifiedFiles.add(file);
36
- }
37
- }
38
- }
6
+ * @license
7
+ * Copyright Google LLC All Rights Reserved.
8
+ *
9
+ * Use of this source code is governed by an MIT-style license that can be
10
+ * found in the LICENSE file at https://angular.io/license
11
+ */
12
+ var USING_WINDOWS = platform() === "win32";
13
+ var WINDOWS_SEP_REGEXP = new RegExp(`\\${path$1.win32.sep}`, "g");
14
+ var SourceFileCache = class extends Map {
15
+ modifiedFiles = /* @__PURE__ */ new Set();
16
+ babelFileCache = /* @__PURE__ */ new Map();
17
+ typeScriptFileCache = /* @__PURE__ */ new Map();
18
+ referencedFiles;
19
+ constructor(persistentCachePath) {
20
+ super();
21
+ this.persistentCachePath = persistentCachePath;
22
+ }
23
+ invalidate(files) {
24
+ if (files !== this.modifiedFiles) this.modifiedFiles.clear();
25
+ for (let file of files) {
26
+ this.babelFileCache.delete(file);
27
+ this.typeScriptFileCache.delete(pathToFileURL(file).href);
28
+ if (USING_WINDOWS) file = file.replace(WINDOWS_SEP_REGEXP, path$1.posix.sep);
29
+ this.delete(file);
30
+ this.modifiedFiles.add(file);
31
+ }
32
+ }
33
+ };
34
+ //#endregion
35
+ export { SourceFileCache };
36
+
39
37
  //# sourceMappingURL=source-file-cache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-file-cache.js","sourceRoot":"","sources":["../../../../../../packages/vite-plugin-angular/src/lib/utils/source-file-cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,MAAM,aAAa,GAAG,QAAQ,EAAE,KAAK,OAAO,CAAC;AAC7C,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;AAElE,MAAM,OAAO,eAAgB,SAAQ,GAA0B;IAaxC;IAZZ,aAAa,GAAgB,IAAI,GAAG,EAAU,CAAC;IAC/C,cAAc,GAA4B,IAAI,GAAG,EAGvD,CAAC;IACK,mBAAmB,GAAqC,IAAI,GAAG,EAGrE,CAAC;IAEJ,eAAe,CAAqB;IAEpC,YAAqB,mBAA4B;QAC/C,KAAK,EAAE,CAAC;QADW,wBAAmB,GAAnB,mBAAmB,CAAS;IAEjD,CAAC;IAED,UAAU,CAAC,KAAuB;QAChC,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa,EAAE,CAAC;YACjC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;QACD,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;YAE1D,+DAA+D;YAC/D,IAAI,aAAa,EAAE,CAAC;gBAClB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1D,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAClB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"source-file-cache.js","names":[],"sources":["../../../../src/lib/utils/source-file-cache.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport { platform } from 'node:os';\nimport * as path from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type ts from 'typescript';\n\nconst USING_WINDOWS = platform() === 'win32';\nconst WINDOWS_SEP_REGEXP = new RegExp(`\\\\${path.win32.sep}`, 'g');\n\nexport class SourceFileCache extends Map<string, ts.SourceFile> {\n readonly modifiedFiles: Set<string> = new Set<string>();\n readonly babelFileCache: Map<string, Uint8Array> = new Map<\n string,\n Uint8Array\n >();\n readonly typeScriptFileCache: Map<string, string | Uint8Array> = new Map<\n string,\n string | Uint8Array\n >();\n\n referencedFiles?: readonly string[];\n\n constructor(readonly persistentCachePath?: string) {\n super();\n }\n\n invalidate(files: Iterable<string>): void {\n if (files !== this.modifiedFiles) {\n this.modifiedFiles.clear();\n }\n for (let file of files) {\n this.babelFileCache.delete(file);\n this.typeScriptFileCache.delete(pathToFileURL(file).href);\n\n // Normalize separators to allow matching TypeScript Host paths\n if (USING_WINDOWS) {\n file = file.replace(WINDOWS_SEP_REGEXP, path.posix.sep);\n }\n\n this.delete(file);\n this.modifiedFiles.add(file);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAM,gBAAgB,UAAU,KAAK;AACrC,IAAM,qBAAqB,IAAI,OAAO,KAAK,OAAK,MAAM,OAAO,IAAI;AAEjE,IAAa,kBAAb,cAAqC,IAA2B;CAC9D,gCAAsC,IAAI,KAAa;CACvD,iCAAmD,IAAI,KAGpD;CACH,sCAAiE,IAAI,KAGlE;CAEH;CAEA,YAAY,qBAAuC;AACjD,SAAO;AADY,OAAA,sBAAA;;CAIrB,WAAW,OAA+B;AACxC,MAAI,UAAU,KAAK,cACjB,MAAK,cAAc,OAAO;AAE5B,OAAK,IAAI,QAAQ,OAAO;AACtB,QAAK,eAAe,OAAO,KAAK;AAChC,QAAK,oBAAoB,OAAO,cAAc,KAAK,CAAC,KAAK;AAGzD,OAAI,cACF,QAAO,KAAK,QAAQ,oBAAoB,OAAK,MAAM,IAAI;AAGzD,QAAK,OAAO,KAAK;AACjB,QAAK,cAAc,IAAI,KAAK"}
@@ -0,0 +1,12 @@
1
+ export interface CssTailwindDirectiveState {
2
+ commentlessCode: string;
3
+ hasReferenceDirective: boolean;
4
+ hasReferenceText: boolean;
5
+ hasTailwindImportDirective: boolean;
6
+ }
7
+ export declare class TailwindReferenceError extends Error {
8
+ readonly name = "TailwindReferenceError";
9
+ }
10
+ export declare function inspectCssTailwindDirectives(code: string): CssTailwindDirectiveState;
11
+ export declare function throwTailwindReferenceTextError(filename: string, rootStylesheet: string): never;
12
+ export declare function isTailwindReferenceError(error: unknown): error is TailwindReferenceError;
@@ -0,0 +1,99 @@
1
+ //#region packages/vite-plugin-angular/src/lib/utils/tailwind-reference.ts
2
+ var ANGULAR_TAILWIND_PREFIX = "[@analogjs/vite-plugin-angular]";
3
+ var CSS_REFERENCE_DIRECTIVE_REGEX = /(^|[;}\n\r])\s*@reference\b/m;
4
+ var CSS_TAILWIND_IMPORT_REGEX = /(^|[;}\n\r])\s*@import\s+["']tailwindcss["']/m;
5
+ var TailwindReferenceError = class extends Error {
6
+ name = "TailwindReferenceError";
7
+ };
8
+ function stripCssBlockComments(code) {
9
+ let result = "";
10
+ let quote = null;
11
+ for (let index = 0; index < code.length; index++) {
12
+ const character = code[index];
13
+ const nextCharacter = code[index + 1];
14
+ if (quote) {
15
+ if (character === "\\" && nextCharacter) {
16
+ result += character;
17
+ result += nextCharacter;
18
+ index++;
19
+ continue;
20
+ }
21
+ if (character === quote) quote = null;
22
+ result += character;
23
+ continue;
24
+ }
25
+ if (character === "\"" || character === "'" || character === "`") {
26
+ quote = character;
27
+ result += character;
28
+ continue;
29
+ }
30
+ if (character === "/" && nextCharacter === "*") {
31
+ result += " ";
32
+ index += 2;
33
+ while (index < code.length) {
34
+ const commentCharacter = code[index];
35
+ const commentNextCharacter = code[index + 1];
36
+ if (commentCharacter === "*" && commentNextCharacter === "/") {
37
+ result += " ";
38
+ index++;
39
+ break;
40
+ }
41
+ result += commentCharacter === "\n" || commentCharacter === "\r" ? commentCharacter : " ";
42
+ index++;
43
+ }
44
+ continue;
45
+ }
46
+ result += character;
47
+ }
48
+ return result;
49
+ }
50
+ function hasReferenceTextInComments(code) {
51
+ let quote = null;
52
+ for (let index = 0; index < code.length; index++) {
53
+ const character = code[index];
54
+ const nextCharacter = code[index + 1];
55
+ if (quote) {
56
+ if (character === "\\" && nextCharacter) {
57
+ index++;
58
+ continue;
59
+ }
60
+ if (character === quote) quote = null;
61
+ continue;
62
+ }
63
+ if (character === "\"" || character === "'" || character === "`") {
64
+ quote = character;
65
+ continue;
66
+ }
67
+ if (character === "/" && nextCharacter === "*") {
68
+ const commentStart = index + 2;
69
+ index += 2;
70
+ while (index < code.length) {
71
+ const commentCharacter = code[index];
72
+ const commentNextCharacter = code[index + 1];
73
+ if (commentCharacter === "*" && commentNextCharacter === "/") break;
74
+ index++;
75
+ }
76
+ if (code.slice(commentStart, index).includes("@reference")) return true;
77
+ }
78
+ }
79
+ return false;
80
+ }
81
+ function inspectCssTailwindDirectives(code) {
82
+ const commentlessCode = stripCssBlockComments(code);
83
+ return {
84
+ commentlessCode,
85
+ hasReferenceDirective: CSS_REFERENCE_DIRECTIVE_REGEX.test(commentlessCode),
86
+ hasReferenceText: hasReferenceTextInComments(code),
87
+ hasTailwindImportDirective: CSS_TAILWIND_IMPORT_REGEX.test(commentlessCode)
88
+ };
89
+ }
90
+ function throwTailwindReferenceTextError(filename, rootStylesheet) {
91
+ throw new TailwindReferenceError(`${ANGULAR_TAILWIND_PREFIX} Tailwind @reference auto-injection was blocked for "${filename}" because the stylesheet contains the text "@reference" but does not contain a real @reference directive.\n\nThis is usually caused by a CSS comment such as "/* ... @reference ... */".\n\nFix one of:\n - Reword the comment so it does not contain "@reference"\n - Add a real @reference "${rootStylesheet}"; directive\n`);
92
+ }
93
+ function isTailwindReferenceError(error) {
94
+ return error instanceof TailwindReferenceError;
95
+ }
96
+ //#endregion
97
+ export { inspectCssTailwindDirectives, isTailwindReferenceError, throwTailwindReferenceTextError };
98
+
99
+ //# sourceMappingURL=tailwind-reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-reference.js","names":[],"sources":["../../../../src/lib/utils/tailwind-reference.ts"],"sourcesContent":["const ANGULAR_TAILWIND_PREFIX = '[@analogjs/vite-plugin-angular]';\nconst CSS_REFERENCE_DIRECTIVE_REGEX = /(^|[;}\\n\\r])\\s*@reference\\b/m;\nconst CSS_TAILWIND_IMPORT_REGEX =\n /(^|[;}\\n\\r])\\s*@import\\s+[\"']tailwindcss[\"']/m;\n\nexport interface CssTailwindDirectiveState {\n commentlessCode: string;\n hasReferenceDirective: boolean;\n hasReferenceText: boolean;\n hasTailwindImportDirective: boolean;\n}\n\nexport class TailwindReferenceError extends Error {\n readonly name = 'TailwindReferenceError';\n}\n\n// Match real CSS directives, not prose inside block comments. The scanner keeps\n// quoted CSS content intact so `/* ... */` sequences inside strings do not get\n// mistaken for real comments.\nfunction stripCssBlockComments(code: string): string {\n let result = '';\n let quote: '\"' | \"'\" | '`' | null = null;\n\n for (let index = 0; index < code.length; index++) {\n const character = code[index];\n const nextCharacter = code[index + 1];\n\n if (quote) {\n if (character === '\\\\' && nextCharacter) {\n result += character;\n result += nextCharacter;\n index++;\n continue;\n }\n if (character === quote) {\n quote = null;\n }\n result += character;\n continue;\n }\n\n if (character === '\"' || character === \"'\" || character === '`') {\n quote = character;\n result += character;\n continue;\n }\n\n if (character === '/' && nextCharacter === '*') {\n result += ' ';\n index += 2;\n\n while (index < code.length) {\n const commentCharacter = code[index];\n const commentNextCharacter = code[index + 1];\n\n if (commentCharacter === '*' && commentNextCharacter === '/') {\n result += ' ';\n index++;\n break;\n }\n\n result +=\n commentCharacter === '\\n' || commentCharacter === '\\r'\n ? commentCharacter\n : ' ';\n index++;\n }\n continue;\n }\n\n result += character;\n }\n\n return result;\n}\n\nfunction hasReferenceTextInComments(code: string): boolean {\n let quote: '\"' | \"'\" | '`' | null = null;\n\n for (let index = 0; index < code.length; index++) {\n const character = code[index];\n const nextCharacter = code[index + 1];\n\n if (quote) {\n if (character === '\\\\' && nextCharacter) {\n index++;\n continue;\n }\n if (character === quote) {\n quote = null;\n }\n continue;\n }\n\n if (character === '\"' || character === \"'\" || character === '`') {\n quote = character;\n continue;\n }\n\n if (character === '/' && nextCharacter === '*') {\n const commentStart = index + 2;\n index += 2;\n\n while (index < code.length) {\n const commentCharacter = code[index];\n const commentNextCharacter = code[index + 1];\n\n if (commentCharacter === '*' && commentNextCharacter === '/') {\n break;\n }\n index++;\n }\n\n if (code.slice(commentStart, index).includes('@reference')) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function inspectCssTailwindDirectives(\n code: string,\n): CssTailwindDirectiveState {\n const commentlessCode = stripCssBlockComments(code);\n\n return {\n commentlessCode,\n hasReferenceDirective: CSS_REFERENCE_DIRECTIVE_REGEX.test(commentlessCode),\n hasReferenceText: hasReferenceTextInComments(code),\n hasTailwindImportDirective: CSS_TAILWIND_IMPORT_REGEX.test(commentlessCode),\n };\n}\n\nexport function throwTailwindReferenceTextError(\n filename: string,\n rootStylesheet: string,\n): never {\n throw new TailwindReferenceError(\n `${ANGULAR_TAILWIND_PREFIX} Tailwind @reference auto-injection was ` +\n `blocked for \"${filename}\" because the stylesheet contains the ` +\n `text \"@reference\" but does not contain a real @reference ` +\n `directive.\\n\\n` +\n `This is usually caused by a CSS comment such as ` +\n `\"/* ... @reference ... */\".\\n\\n` +\n `Fix one of:\\n` +\n ` - Reword the comment so it does not contain \"@reference\"\\n` +\n ` - Add a real @reference \"${rootStylesheet}\"; directive\\n`,\n );\n}\n\nexport function isTailwindReferenceError(\n error: unknown,\n): error is TailwindReferenceError {\n return error instanceof TailwindReferenceError;\n}\n"],"mappings":";AAAA,IAAM,0BAA0B;AAChC,IAAM,gCAAgC;AACtC,IAAM,4BACJ;AASF,IAAa,yBAAb,cAA4C,MAAM;CAChD,OAAgB;;AAMlB,SAAS,sBAAsB,MAAsB;CACnD,IAAI,SAAS;CACb,IAAI,QAAgC;AAEpC,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,YAAY,KAAK;EACvB,MAAM,gBAAgB,KAAK,QAAQ;AAEnC,MAAI,OAAO;AACT,OAAI,cAAc,QAAQ,eAAe;AACvC,cAAU;AACV,cAAU;AACV;AACA;;AAEF,OAAI,cAAc,MAChB,SAAQ;AAEV,aAAU;AACV;;AAGF,MAAI,cAAc,QAAO,cAAc,OAAO,cAAc,KAAK;AAC/D,WAAQ;AACR,aAAU;AACV;;AAGF,MAAI,cAAc,OAAO,kBAAkB,KAAK;AAC9C,aAAU;AACV,YAAS;AAET,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,mBAAmB,KAAK;IAC9B,MAAM,uBAAuB,KAAK,QAAQ;AAE1C,QAAI,qBAAqB,OAAO,yBAAyB,KAAK;AAC5D,eAAU;AACV;AACA;;AAGF,cACE,qBAAqB,QAAQ,qBAAqB,OAC9C,mBACA;AACN;;AAEF;;AAGF,YAAU;;AAGZ,QAAO;;AAGT,SAAS,2BAA2B,MAAuB;CACzD,IAAI,QAAgC;AAEpC,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,YAAY,KAAK;EACvB,MAAM,gBAAgB,KAAK,QAAQ;AAEnC,MAAI,OAAO;AACT,OAAI,cAAc,QAAQ,eAAe;AACvC;AACA;;AAEF,OAAI,cAAc,MAChB,SAAQ;AAEV;;AAGF,MAAI,cAAc,QAAO,cAAc,OAAO,cAAc,KAAK;AAC/D,WAAQ;AACR;;AAGF,MAAI,cAAc,OAAO,kBAAkB,KAAK;GAC9C,MAAM,eAAe,QAAQ;AAC7B,YAAS;AAET,UAAO,QAAQ,KAAK,QAAQ;IAC1B,MAAM,mBAAmB,KAAK;IAC9B,MAAM,uBAAuB,KAAK,QAAQ;AAE1C,QAAI,qBAAqB,OAAO,yBAAyB,IACvD;AAEF;;AAGF,OAAI,KAAK,MAAM,cAAc,MAAM,CAAC,SAAS,aAAa,CACxD,QAAO;;;AAKb,QAAO;;AAGT,SAAgB,6BACd,MAC2B;CAC3B,MAAM,kBAAkB,sBAAsB,KAAK;AAEnD,QAAO;EACL;EACA,uBAAuB,8BAA8B,KAAK,gBAAgB;EAC1E,kBAAkB,2BAA2B,KAAK;EAClD,4BAA4B,0BAA0B,KAAK,gBAAgB;EAC5E;;AAGH,SAAgB,gCACd,UACA,gBACO;AACP,OAAM,IAAI,uBACR,GAAG,wBAAwB,uDACT,SAAS,kSAOK,eAAe,gBAChD;;AAGH,SAAgB,yBACd,OACiC;AACjC,QAAO,iBAAiB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The `{ get, put }` shape `@angular/build`'s `JavaScriptTransformer`
3
+ * accepts as its third constructor argument. Keys are SHA-256 digests the
4
+ * transformer derives from the file bytes plus every option that affects
5
+ * output, so entries are immutable and never need invalidation — but the
6
+ * digest does NOT cover the linker version, so stores must be namespaced
7
+ * by Angular version (see {@link resolveTransformCacheDir}).
8
+ */
9
+ export interface TransformCacheStore {
10
+ get(key: string): Promise<Uint8Array | undefined> | Uint8Array | undefined;
11
+ put(key: string, value: Uint8Array): Promise<void> | void;
12
+ }
13
+ interface TransformCacheStats {
14
+ hits: number;
15
+ misses: number;
16
+ writes: number;
17
+ /** Approximate total ms spent in the linker worker for cache misses. */
18
+ workerMs: number;
19
+ }
20
+ /**
21
+ * Disk-backed content-addressed store for linked/transformed dependency
22
+ * output. Entries are written atomically (temp + rename) so concurrent
23
+ * dev servers can share a directory; all failures degrade to a miss.
24
+ */
25
+ export declare function createPersistentTransformCache(baseDir: string): TransformCacheStore & {
26
+ stats: TransformCacheStats;
27
+ };
28
+ /**
29
+ * Layer an unbounded in-memory map over a persistent store so repeat
30
+ * transforms in the same session never touch the disk.
31
+ */
32
+ export declare function withMemoryLayer(store: TransformCacheStore): TransformCacheStore;
33
+ /**
34
+ * Resolve the shared on-disk cache directory: `node_modules/.cache` at the
35
+ * nearest `node_modules` above `startDir` — the conventional tool-cache
36
+ * location, so installs and `node_modules` cleans evict it without a
37
+ * separate eviction pass. Namespaced by the installed Angular version
38
+ * because the transformer's cache key does not cover the linker version.
39
+ * Returns `null` (caching disabled) when no `node_modules` exists or the
40
+ * `ANALOG_TRANSFORM_CACHE=0` kill switch is set.
41
+ */
42
+ export declare function resolveTransformCacheDir(startDir: string): string | null;
43
+ export {};