@analogjs/vite-plugin-angular 3.0.0-beta.6 → 3.0.0-beta.60

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 (161) hide show
  1. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +3 -3
  2. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
  3. package/ngp/LICENSE +21 -0
  4. package/ngp/api.mjs +46806 -0
  5. package/ngp/build.json +4 -0
  6. package/ngp/ng_analyze.cjs +601 -0
  7. package/ngp/ng_analyze_bg.wasm +0 -0
  8. package/package.json +5 -2
  9. package/src/index.d.ts +2 -0
  10. package/src/index.js +4 -3
  11. package/src/index.js.map +1 -1
  12. package/src/lib/analog-plugin-interop.js +2 -3
  13. package/src/lib/angular-build-context.d.ts +215 -0
  14. package/src/lib/angular-build-context.js +360 -0
  15. package/src/lib/angular-build-context.js.map +1 -0
  16. package/src/lib/angular-build-optimizer-plugin.d.ts +6 -4
  17. package/src/lib/angular-build-optimizer-plugin.js +25 -11
  18. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  19. package/src/lib/angular-jit-plugin.d.ts +5 -3
  20. package/src/lib/angular-jit-plugin.js +16 -9
  21. package/src/lib/angular-jit-plugin.js.map +1 -1
  22. package/src/lib/angular-vite-plugin.d.ts +6 -109
  23. package/src/lib/angular-vite-plugin.js +9 -1251
  24. package/src/lib/angular-vite-plugin.js.map +1 -1
  25. package/src/lib/angular-vitest-plugin.d.ts +3 -2
  26. package/src/lib/angular-vitest-plugin.js +7 -5
  27. package/src/lib/angular-vitest-plugin.js.map +1 -1
  28. package/src/lib/companion-plugins.d.ts +7 -0
  29. package/src/lib/companion-plugins.js +37 -0
  30. package/src/lib/companion-plugins.js.map +1 -0
  31. package/src/lib/compilation-api/compilation-api-plugin.d.ts +11 -2
  32. package/src/lib/compilation-api/compilation-api-plugin.js +156 -285
  33. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
  34. package/src/lib/compilation-api/index.js +1 -2
  35. package/src/lib/compiler/angular-version.js +0 -1
  36. package/src/lib/compiler/class-field-lowering.js +1 -2
  37. package/src/lib/compiler/compile.d.ts +1 -1
  38. package/src/lib/compiler/compile.js +224 -151
  39. package/src/lib/compiler/compile.js.map +1 -1
  40. package/src/lib/compiler/constants.js +1 -2
  41. package/src/lib/compiler/debug.js +1 -2
  42. package/src/lib/compiler/defer.d.ts +2 -3
  43. package/src/lib/compiler/defer.js +13 -16
  44. package/src/lib/compiler/defer.js.map +1 -1
  45. package/src/lib/compiler/dts-reader.d.ts +6 -1
  46. package/src/lib/compiler/dts-reader.js +20 -12
  47. package/src/lib/compiler/dts-reader.js.map +1 -1
  48. package/src/lib/compiler/hmr.d.ts +4 -0
  49. package/src/lib/compiler/hmr.js +8 -4
  50. package/src/lib/compiler/hmr.js.map +1 -1
  51. package/src/lib/compiler/index.d.ts +2 -2
  52. package/src/lib/compiler/index.js +6 -6
  53. package/src/lib/compiler/jit-metadata.js +1 -2
  54. package/src/lib/compiler/jit-transform.js +37 -15
  55. package/src/lib/compiler/jit-transform.js.map +1 -1
  56. package/src/lib/compiler/js-emitter.d.ts +0 -3
  57. package/src/lib/compiler/js-emitter.js +4 -23
  58. package/src/lib/compiler/js-emitter.js.map +1 -1
  59. package/src/lib/compiler/metadata.js +2 -3
  60. package/src/lib/compiler/registry.d.ts +7 -1
  61. package/src/lib/compiler/registry.js +24 -5
  62. package/src/lib/compiler/registry.js.map +1 -1
  63. package/src/lib/compiler/resource-inliner.d.ts +8 -9
  64. package/src/lib/compiler/resource-inliner.js +11 -20
  65. package/src/lib/compiler/resource-inliner.js.map +1 -1
  66. package/src/lib/compiler/style-ast.d.ts +22 -1
  67. package/src/lib/compiler/style-ast.js +37 -20
  68. package/src/lib/compiler/style-ast.js.map +1 -1
  69. package/src/lib/compiler/type-elision.d.ts +4 -3
  70. package/src/lib/compiler/type-elision.js +11 -13
  71. package/src/lib/compiler/type-elision.js.map +1 -1
  72. package/src/lib/compiler/utils.d.ts +9 -7
  73. package/src/lib/compiler/utils.js +50 -11
  74. package/src/lib/compiler/utils.js.map +1 -1
  75. package/src/lib/compiler-plugin.js +1 -2
  76. package/src/lib/component-resolvers.js +1 -2
  77. package/src/lib/component-scanner.d.ts +74 -0
  78. package/src/lib/component-scanner.js +177 -0
  79. package/src/lib/component-scanner.js.map +1 -0
  80. package/src/lib/component-styles-plugin.d.ts +52 -0
  81. package/src/lib/component-styles-plugin.js +352 -0
  82. package/src/lib/component-styles-plugin.js.map +1 -0
  83. package/src/lib/compose-angular-plugins.d.ts +12 -0
  84. package/src/lib/compose-angular-plugins.js +30 -0
  85. package/src/lib/compose-angular-plugins.js.map +1 -0
  86. package/src/lib/dev-server-mode-plugin.d.ts +7 -0
  87. package/src/lib/dev-server-mode-plugin.js +22 -0
  88. package/src/lib/dev-server-mode-plugin.js.map +1 -0
  89. package/src/lib/encapsulation-plugin.js +1 -2
  90. package/src/lib/fast-compile-api.d.ts +62 -0
  91. package/src/lib/fast-compile-api.js +11 -0
  92. package/src/lib/fast-compile-api.js.map +1 -0
  93. package/src/lib/fast-compile-plugin.d.ts +6 -1
  94. package/src/lib/fast-compile-plugin.js +169 -110
  95. package/src/lib/fast-compile-plugin.js.map +1 -1
  96. package/src/lib/host.d.ts +3 -0
  97. package/src/lib/host.js +5 -4
  98. package/src/lib/host.js.map +1 -1
  99. package/src/lib/hot-update-batch.js +1 -2
  100. package/src/lib/live-reload-plugin.d.ts +6 -3
  101. package/src/lib/live-reload-plugin.js +14 -8
  102. package/src/lib/live-reload-plugin.js.map +1 -1
  103. package/src/lib/ngp-compile-api.d.ts +55 -0
  104. package/src/lib/ngp-compile-api.js +11 -0
  105. package/src/lib/ngp-compile-api.js.map +1 -0
  106. package/src/lib/ngp-compile-plugin.d.ts +4 -0
  107. package/src/lib/ngp-compile-plugin.js +672 -0
  108. package/src/lib/ngp-compile-plugin.js.map +1 -0
  109. package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
  110. package/src/lib/ngtsc-compile-plugin.js +776 -0
  111. package/src/lib/ngtsc-compile-plugin.js.map +1 -0
  112. package/src/lib/nx-folder-plugin.d.ts +6 -5
  113. package/src/lib/nx-folder-plugin.js +13 -9
  114. package/src/lib/nx-folder-plugin.js.map +1 -1
  115. package/src/lib/plugins/file-replacements.plugin.d.ts +6 -0
  116. package/src/lib/plugins/file-replacements.plugin.js +2 -2
  117. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  118. package/src/lib/router-plugin.d.ts +5 -1
  119. package/src/lib/router-plugin.js +14 -6
  120. package/src/lib/router-plugin.js.map +1 -1
  121. package/src/lib/style-preprocessor.js +1 -2
  122. package/src/lib/stylesheet-registry.js +1 -2
  123. package/src/lib/stylesheet-registry.js.map +1 -1
  124. package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -3
  125. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  126. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +1 -2
  127. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  128. package/src/lib/utils/compilation-shared.js +3 -4
  129. package/src/lib/utils/css-extension-resolver.js +1 -2
  130. package/src/lib/utils/css-preprocessor-workers.js +1 -2
  131. package/src/lib/utils/debug-harness.js +1 -2
  132. package/src/lib/utils/debug-log-file.js +1 -2
  133. package/src/lib/utils/debug.js +1 -2
  134. package/src/lib/utils/devkit.js +2 -3
  135. package/src/lib/utils/hmr-component-updates.d.ts +7 -0
  136. package/src/lib/utils/hmr-component-updates.js +86 -0
  137. package/src/lib/utils/hmr-component-updates.js.map +1 -0
  138. package/src/lib/utils/jit-inline-styles.js +1 -2
  139. package/src/lib/utils/lsp-type-checker.d.ts +75 -0
  140. package/src/lib/utils/lsp-type-checker.js +532 -0
  141. package/src/lib/utils/lsp-type-checker.js.map +1 -0
  142. package/src/lib/utils/ngp-host-fs.d.ts +43 -0
  143. package/src/lib/utils/ngp-host-fs.js +128 -0
  144. package/src/lib/utils/ngp-host-fs.js.map +1 -0
  145. package/src/lib/utils/plugin-config.d.ts +15 -8
  146. package/src/lib/utils/plugin-config.js +19 -7
  147. package/src/lib/utils/plugin-config.js.map +1 -1
  148. package/src/lib/utils/rolldown.js +1 -2
  149. package/src/lib/utils/safe-module-paths.js +1 -2
  150. package/src/lib/utils/stylesheet-warning.d.ts +2 -0
  151. package/src/lib/utils/stylesheet-warning.js +10 -0
  152. package/src/lib/utils/stylesheet-warning.js.map +1 -0
  153. package/src/lib/utils/transform-cache.js +1 -2
  154. package/src/lib/utils/transform-cache.js.map +1 -1
  155. package/src/lib/utils/tsconfig-resolver.js +2 -3
  156. package/src/lib/utils/virtual-ids.js +1 -2
  157. package/src/lib/utils/virtual-resources.js +1 -2
  158. package/src/lib/utils/virtual-resources.js.map +1 -1
  159. package/src/lib/virtual-modules-plugin.d.ts +11 -3
  160. package/src/lib/virtual-modules-plugin.js +70 -15
  161. package/src/lib/virtual-modules-plugin.js.map +1 -1
@@ -0,0 +1,128 @@
1
+ import * as fs from "node:fs";
2
+ import { basename, dirname, join, posix } from "node:path";
3
+ import { normalizePath } from "vite";
4
+ // packages/vite-plugin-angular/src/lib/utils/ngp-host-fs.ts
5
+ var FILE = {
6
+ isFile: true,
7
+ isDir: false,
8
+ isSymlink: false
9
+ };
10
+ var NOT_FOUND_CODES = /* @__PURE__ */ new Set([
11
+ "ENOENT",
12
+ "ENOTDIR",
13
+ "ENAMETOOLONG",
14
+ "EINVAL"
15
+ ]);
16
+ function orNull(read) {
17
+ try {
18
+ return read();
19
+ } catch (error) {
20
+ if (NOT_FOUND_CODES.has(error.code ?? "")) return null;
21
+ throw error;
22
+ }
23
+ }
24
+ var canonicalDirs = /* @__PURE__ */ new Map();
25
+ /**
26
+ * `path`, normalized, with the symlinks of its directory resolved. Lowered
27
+ * modules are keyed by these paths, whichever path a file is reached by.
28
+ */
29
+ function canonicalPath(path) {
30
+ const normalized = normalizePath(path);
31
+ const dir = posix.dirname(normalized);
32
+ let real = canonicalDirs.get(dir);
33
+ if (real === void 0) {
34
+ real = orNull(() => normalizePath(fs.realpathSync(dir))) ?? dir;
35
+ canonicalDirs.set(dir, real);
36
+ }
37
+ return `${real}/${posix.basename(normalized)}`;
38
+ }
39
+ function toStat(stats) {
40
+ return {
41
+ isFile: stats.isFile(),
42
+ isDir: stats.isDirectory(),
43
+ isSymlink: stats.isSymbolicLink()
44
+ };
45
+ }
46
+ var WINDOWS_DRIVE_RE = /^[A-Za-z]:(?:\/|$)/;
47
+ var WASM_WINDOWS_DRIVE_RE = /^\/([A-Za-z]:)(\/|$)/;
48
+ /**
49
+ * Converts a host path to the POSIX-absolute form NGP's WebAssembly backend
50
+ * expects (`D:\a\b` → `/D:/a/b`). POSIX and relative paths are unchanged.
51
+ */
52
+ function toWasmPath(path) {
53
+ const normalized = normalizePath(path);
54
+ return WINDOWS_DRIVE_RE.test(normalized) ? `/${normalized}` : normalized;
55
+ }
56
+ /**
57
+ * Converts a path returned by NGP's WebAssembly backend back to a normalized
58
+ * host path (`/D:/a/b` → `D:/a/b`).
59
+ */
60
+ function fromWasmPath(path) {
61
+ return normalizePath(path).replace(WASM_WINDOWS_DRIVE_RE, (_, drive, sep) => `${drive}${sep || "/"}`);
62
+ }
63
+ /**
64
+ * The disk, with each module of a source format served as a TypeScript file
65
+ * named after it (`x.tsrx` as `x.tsrx.ts`) and the module itself hidden, so an
66
+ * import of `./x.tsrx` resolves to its TypeScript. Also translates Windows
67
+ * drive paths at the WebAssembly boundary.
68
+ *
69
+ * @param programCode The TypeScript of a module's program file, by the file's
70
+ * normalized, canonical path.
71
+ */
72
+ function createNgpHostFs(programCode) {
73
+ const programFile = (path) => programCode?.(canonicalPath(path));
74
+ const isHidden = (path) => programCode?.(`${canonicalPath(path)}.ts`) !== void 0;
75
+ const encoder = new TextEncoder();
76
+ return {
77
+ read(path) {
78
+ const hostPath = fromWasmPath(path);
79
+ const code = programFile(hostPath);
80
+ if (code !== void 0) return encoder.encode(code);
81
+ if (isHidden(hostPath)) return null;
82
+ const buffer = orNull(() => fs.readFileSync(hostPath));
83
+ return buffer && new Uint8Array(buffer);
84
+ },
85
+ metadata(path) {
86
+ const hostPath = fromWasmPath(path);
87
+ if (programFile(hostPath) !== void 0) return FILE;
88
+ if (isHidden(hostPath)) return null;
89
+ const stats = orNull(() => fs.statSync(hostPath));
90
+ return stats && toStat(stats);
91
+ },
92
+ symlinkMetadata(path) {
93
+ const hostPath = fromWasmPath(path);
94
+ if (programFile(hostPath) !== void 0) return FILE;
95
+ if (isHidden(hostPath)) return null;
96
+ const stats = orNull(() => fs.lstatSync(hostPath));
97
+ return stats && toStat(stats);
98
+ },
99
+ readLink(path) {
100
+ const target = orNull(() => fs.readlinkSync(fromWasmPath(path), "utf-8"));
101
+ return target !== null ? toWasmPath(target) : null;
102
+ },
103
+ canonicalize(path) {
104
+ const hostPath = fromWasmPath(path);
105
+ if (programFile(hostPath) !== void 0) {
106
+ const dir = orNull(() => fs.realpathSync(dirname(hostPath)));
107
+ return dir && toWasmPath(join(dir, basename(hostPath)));
108
+ }
109
+ if (isHidden(hostPath)) return null;
110
+ const real = orNull(() => fs.realpathSync(hostPath));
111
+ return real && toWasmPath(real);
112
+ },
113
+ readDir(path) {
114
+ const hostPath = fromWasmPath(path);
115
+ const entries = orNull(() => fs.readdirSync(hostPath, { withFileTypes: true }));
116
+ return entries && entries.map((entry) => isHidden(join(hostPath, entry.name)) ? {
117
+ ...FILE,
118
+ name: `${entry.name}.ts`
119
+ } : {
120
+ ...toStat(entry),
121
+ name: entry.name
122
+ });
123
+ }
124
+ };
125
+ }
126
+ export { canonicalPath, createNgpHostFs, fromWasmPath, toWasmPath };
127
+
128
+ //# sourceMappingURL=ngp-host-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngp-host-fs.js","names":[],"sources":["../../../../src/lib/utils/ngp-host-fs.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport { basename, dirname, join, posix } from 'node:path';\nimport { normalizePath } from 'vite';\n\ninterface HostStat {\n isFile: boolean;\n isDir: boolean;\n isSymlink: boolean;\n}\n\ninterface HostDirEntry extends HostStat {\n name: string;\n}\n\n/** The file system NGP's WebAssembly backend reads through (`hostFs`). */\nexport interface NgpHostFs {\n read(path: string): Uint8Array | null;\n metadata(path: string): HostStat | null;\n symlinkMetadata(path: string): HostStat | null;\n readLink(path: string): string | null;\n canonicalize(path: string): string | null;\n readDir(path: string): HostDirEntry[] | null;\n}\n\nconst FILE: HostStat = { isFile: true, isDir: false, isSymlink: false };\n\n// The errors NGP's own host treats as a missing file\nconst NOT_FOUND_CODES = new Set([\n 'ENOENT',\n 'ENOTDIR',\n 'ENAMETOOLONG',\n 'EINVAL',\n]);\n\nfunction orNull<T>(read: () => T): T | null {\n try {\n return read();\n } catch (error) {\n if (NOT_FOUND_CODES.has((error as NodeJS.ErrnoException).code ?? '')) {\n return null;\n }\n throw error;\n }\n}\n\nconst canonicalDirs = new Map<string, string>();\n\n/**\n * `path`, normalized, with the symlinks of its directory resolved. Lowered\n * modules are keyed by these paths, whichever path a file is reached by.\n */\nexport function canonicalPath(path: string): string {\n const normalized = normalizePath(path);\n const dir = posix.dirname(normalized);\n let real = canonicalDirs.get(dir);\n if (real === undefined) {\n real = orNull(() => normalizePath(fs.realpathSync(dir))) ?? dir;\n canonicalDirs.set(dir, real);\n }\n return `${real}/${posix.basename(normalized)}`;\n}\n\nfunction toStat(\n stats: Pick<fs.Stats, 'isFile' | 'isDirectory' | 'isSymbolicLink'>,\n): HostStat {\n return {\n isFile: stats.isFile(),\n isDir: stats.isDirectory(),\n isSymlink: stats.isSymbolicLink(),\n };\n}\n\nconst WINDOWS_DRIVE_RE = /^[A-Za-z]:(?:\\/|$)/;\nconst WASM_WINDOWS_DRIVE_RE = /^\\/([A-Za-z]:)(\\/|$)/;\n\n/**\n * Converts a host path to the POSIX-absolute form NGP's WebAssembly backend\n * expects (`D:\\a\\b` → `/D:/a/b`). POSIX and relative paths are unchanged.\n */\nexport function toWasmPath(path: string): string {\n const normalized = normalizePath(path);\n return WINDOWS_DRIVE_RE.test(normalized) ? `/${normalized}` : normalized;\n}\n\n/**\n * Converts a path returned by NGP's WebAssembly backend back to a normalized\n * host path (`/D:/a/b` → `D:/a/b`).\n */\nexport function fromWasmPath(path: string): string {\n const normalized = normalizePath(path);\n return normalized.replace(\n WASM_WINDOWS_DRIVE_RE,\n (_, drive: string, sep: string) => `${drive}${sep || '/'}`,\n );\n}\n\n/**\n * The disk, with each module of a source format served as a TypeScript file\n * named after it (`x.tsrx` as `x.tsrx.ts`) and the module itself hidden, so an\n * import of `./x.tsrx` resolves to its TypeScript. Also translates Windows\n * drive paths at the WebAssembly boundary.\n *\n * @param programCode The TypeScript of a module's program file, by the file's\n * normalized, canonical path.\n */\nexport function createNgpHostFs(\n programCode?: (path: string) => string | undefined,\n): NgpHostFs {\n const programFile = (path: string) => programCode?.(canonicalPath(path));\n const isHidden = (path: string) =>\n programCode?.(`${canonicalPath(path)}.ts`) !== undefined;\n const encoder = new TextEncoder();\n\n return {\n read(path) {\n const hostPath = fromWasmPath(path);\n const code = programFile(hostPath);\n if (code !== undefined) return encoder.encode(code);\n if (isHidden(hostPath)) return null;\n const buffer = orNull(() => fs.readFileSync(hostPath));\n return buffer && new Uint8Array(buffer);\n },\n metadata(path) {\n const hostPath = fromWasmPath(path);\n if (programFile(hostPath) !== undefined) return FILE;\n if (isHidden(hostPath)) return null;\n const stats = orNull(() => fs.statSync(hostPath));\n return stats && toStat(stats);\n },\n symlinkMetadata(path) {\n const hostPath = fromWasmPath(path);\n if (programFile(hostPath) !== undefined) return FILE;\n if (isHidden(hostPath)) return null;\n const stats = orNull(() => fs.lstatSync(hostPath));\n return stats && toStat(stats);\n },\n readLink(path) {\n const target = orNull(() => fs.readlinkSync(fromWasmPath(path), 'utf-8'));\n return target !== null ? toWasmPath(target) : null;\n },\n canonicalize(path) {\n const hostPath = fromWasmPath(path);\n if (programFile(hostPath) !== undefined) {\n const dir = orNull(() => fs.realpathSync(dirname(hostPath)));\n return dir && toWasmPath(join(dir, basename(hostPath)));\n }\n if (isHidden(hostPath)) return null;\n const real = orNull(() => fs.realpathSync(hostPath));\n return real && toWasmPath(real);\n },\n readDir(path) {\n const hostPath = fromWasmPath(path);\n const entries = orNull(() =>\n fs.readdirSync(hostPath, { withFileTypes: true }),\n );\n return (\n entries &&\n entries.map((entry) =>\n isHidden(join(hostPath, entry.name))\n ? { ...FILE, name: `${entry.name}.ts` }\n : { ...toStat(entry), name: entry.name },\n )\n );\n },\n };\n}\n"],"mappings":";;;;AAwBA,IAAM,OAAiB;CAAE,QAAQ;CAAM,OAAO;CAAO,WAAW;AAAM;AAGtE,IAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,OAAU,MAAyB;CAC1C,IAAI;EACF,OAAO,KAAK;CACd,SAAS,OAAO;EACd,IAAI,gBAAgB,IAAK,MAAgC,QAAQ,EAAE,GACjE,OAAO;EAET,MAAM;CACR;AACF;AAEA,IAAM,gCAAgB,IAAI,IAAoB;;;;;AAM9C,SAAgB,cAAc,MAAsB;CAClD,MAAM,aAAa,cAAc,IAAI;CACrC,MAAM,MAAM,MAAM,QAAQ,UAAU;CACpC,IAAI,OAAO,cAAc,IAAI,GAAG;CAChC,IAAI,SAAS,KAAA,GAAW;EACtB,OAAO,aAAa,cAAc,GAAG,aAAa,GAAG,CAAC,CAAC,KAAK;EAC5D,cAAc,IAAI,KAAK,IAAI;CAC7B;CACA,OAAO,GAAG,KAAK,GAAG,MAAM,SAAS,UAAU;AAC7C;AAEA,SAAS,OACP,OACU;CACV,OAAO;EACL,QAAQ,MAAM,OAAO;EACrB,OAAO,MAAM,YAAY;EACzB,WAAW,MAAM,eAAe;CAClC;AACF;AAEA,IAAM,mBAAmB;AACzB,IAAM,wBAAwB;;;;;AAM9B,SAAgB,WAAW,MAAsB;CAC/C,MAAM,aAAa,cAAc,IAAI;CACrC,OAAO,iBAAiB,KAAK,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,aAAa,IAAI;GAClC,IAAI,YAAY,QAAQ,MAAM,KAAA,GAAW;IACvC,MAAM,MAAM,aAAa,GAAG,aAAa,QAAQ,QAAQ,CAAC,CAAC;IAC3D,OAAO,OAAO,WAAW,KAAK,KAAK,SAAS,QAAQ,CAAC,CAAC;GACxD;GACA,IAAI,SAAS,QAAQ,GAAG,OAAO;GAC/B,MAAM,OAAO,aAAa,GAAG,aAAa,QAAQ,CAAC;GACnD,OAAO,QAAQ,WAAW,IAAI;EAChC;EACA,QAAQ,MAAM;GACZ,MAAM,WAAW,aAAa,IAAI;GAClC,MAAM,UAAU,aACd,GAAG,YAAY,UAAU,EAAE,eAAe,KAAK,CAAC,CAClD;GACA,OACE,WACA,QAAQ,KAAK,UACX,SAAS,KAAK,UAAU,MAAM,IAAI,CAAC,IAC/B;IAAE,GAAG;IAAM,MAAM,GAAG,MAAM,KAAK;GAAK,IACpC;IAAE,GAAG,OAAO,KAAK;IAAG,MAAM,MAAM;GAAK,CAC3C;EAEJ;CACF;AACF"}
@@ -1,3 +1,4 @@
1
+ import * as vite from "vite";
1
2
  /**
2
3
  * TypeScript file extension regex
3
4
  * Match .ts / .cts / .mts extensions with an optional ?query suffix.
@@ -10,8 +11,8 @@
10
11
  * zero characters, and any non-`x` letter was admitted — so `.tsrx`
11
12
  * and similar extensions matched by accident.
12
13
  */
13
- export declare const TS_EXT_REGEX: unknown;
14
- export declare const EXCLUDED_TS_EXT_REGEX: unknown;
14
+ export declare const TS_EXT_REGEX: RegExp;
15
+ export declare const EXCLUDED_TS_EXT_REGEX: RegExp;
15
16
  /**
16
17
  * Resolves whether Angular should be compiled for production. An explicit
17
18
  * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by
@@ -19,13 +20,22 @@ export declare const EXCLUDED_TS_EXT_REGEX: unknown;
19
20
  * development compilation. See #2458 and #2462.
20
21
  */
21
22
  export declare function isProdMode(mode: string | undefined): boolean;
23
+ /**
24
+ * Whether a Vite environment runs on the server. `configEnvironment` sees the
25
+ * environment's options before Vite resolves them, so an unset `consumer`
26
+ * falls back to Vite's own default: every environment except `client` is a
27
+ * server environment.
28
+ */
29
+ export declare function isServerEnvironment(name: string, config: {
30
+ consumer?: string;
31
+ }): boolean;
22
32
  export interface TsConfigResolutionContext {
23
33
  root: string;
24
34
  isProd: boolean;
25
35
  isLib: boolean;
26
36
  }
27
- export declare function getTsConfigPath(root: string, tsconfig: string, isProd: boolean, isTest: boolean, isLib: boolean, workspaceRoot?: string);
28
- export declare function createTsConfigGetter(tsconfigOrGetter?: string | (() => string));
37
+ export declare function getTsConfigPath(root: string, tsconfig: string, isProd: boolean, isTest: boolean, isLib: boolean, workspaceRoot?: string): string;
38
+ export declare function createTsConfigGetter(tsconfigOrGetter?: string | (() => string)): () => string;
29
39
  export interface DepOptimizerOptions {
30
40
  tsconfig: string;
31
41
  isProd: boolean;
@@ -35,8 +45,5 @@ export interface DepOptimizerOptions {
35
45
  isAstroIntegration: boolean;
36
46
  }
37
47
  export declare function createDepOptimizerConfig(opts: DepOptimizerOptions): {
38
- optimizeDeps: {
39
- include: unknown;
40
- exclude: unknown;
41
- };
48
+ optimizeDeps: vite.DepOptimizationOptions;
42
49
  };
@@ -1,9 +1,9 @@
1
1
  import { createCompilerPlugin, createRolldownCompilerPlugin } from "../compiler-plugin.js";
2
+ import { isRolldown } from "./rolldown.js";
2
3
  import { createPersistentTransformCache, resolveTransformCacheDir } from "./transform-cache.js";
3
4
  import { existsSync } from "node:fs";
4
5
  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
6
+ // packages/vite-plugin-angular/src/lib/utils/plugin-config.ts
7
7
  /**
8
8
  * TypeScript file extension regex
9
9
  * Match .ts / .cts / .mts extensions with an optional ?query suffix.
@@ -28,6 +28,15 @@ function isProdMode(mode) {
28
28
  if (mode === "development") return false;
29
29
  return mode === "production" || process.env.NODE_ENV === "production";
30
30
  }
31
+ /**
32
+ * Whether a Vite environment runs on the server. `configEnvironment` sees the
33
+ * environment's options before Vite resolves them, so an unset `consumer`
34
+ * falls back to Vite's own default: every environment except `client` is a
35
+ * server environment.
36
+ */
37
+ function isServerEnvironment(name, config) {
38
+ return (config.consumer ?? (name === "client" ? "client" : "server")) === "server";
39
+ }
31
40
  function getTsConfigPath(root, tsconfig, isProd, isTest, isLib, workspaceRoot) {
32
41
  if (tsconfig && isAbsolute(tsconfig)) {
33
42
  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.`);
@@ -51,7 +60,7 @@ function createTsConfigGetter(tsconfigOrGetter) {
51
60
  }
52
61
  function createDepOptimizerConfig(opts) {
53
62
  const defineOptions = {
54
- ngJitMode: "false",
63
+ ...opts.jit ? {} : { ngJitMode: "false" },
55
64
  ngI18nClosureMode: "false",
56
65
  ...opts.watchMode ? {} : { ngDevMode: "false" }
57
66
  };
@@ -75,12 +84,15 @@ function createDepOptimizerConfig(opts) {
75
84
  define: defineOptions
76
85
  };
77
86
  return { optimizeDeps: {
78
- include: ["rxjs/operators", "rxjs"],
87
+ include: [
88
+ "rxjs/operators",
89
+ "rxjs",
90
+ "tslib"
91
+ ],
79
92
  exclude: ["@angular/platform-server"],
80
- ...vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }
93
+ ...isRolldown() ? { rolldownOptions } : { esbuildOptions }
81
94
  } };
82
95
  }
83
- //#endregion
84
- export { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath, isProdMode };
96
+ export { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX, createDepOptimizerConfig, createTsConfigGetter, getTsConfigPath, isProdMode, isServerEnvironment };
85
97
 
86
98
  //# sourceMappingURL=plugin-config.js.map
@@ -1 +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// Spec files stay included — a newly added spec must join the program's\n// root names in Vitest watch mode.\nexport const EXCLUDED_TS_EXT_REGEX = /\\.d\\.[cm]?ts$/;\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;AAI5B,IAAa,wBAAwB;;;;;;;AAQrC,SAAgB,WAAW,MAAmC;CAC5D,IAAI,SAAS,eACX,OAAO;CAGT,OAAO,SAAS,gBAAA,QAAA,IAAA,aAA4C;AAC9D;AAQA,SAAgB,gBACd,MACA,UACA,QACA,QACA,OACA,eACA;CACA,IAAI,YAAY,WAAW,QAAQ,GAAG;EACpC,IAAI,CAAC,WAAW,QAAQ,GACtB,QAAQ,MACN,kEAAkE,SAAS,uGAC7E;EAGF,OAAO;CACT;CAEA,IAAI,mBAAmB;CAEvB,IAAI,OACF,mBAAmB,SACf,6BACA;CAGN,IAAI,QACF,mBAAmB;CAGrB,IAAI,UACF,mBAAmB;CAGrB,MAAM,eAAe,QAAQ,MAAM,gBAAgB;CAEnD,IAAI,WAAW,YAAY,GACzB,OAAO;CAOT,MAAM,gBAAgB,gBAClB,QAAQ,eAAe,gBAAgB,IACvC,KAAA;CAEJ,IAAI,iBAAiB,WAAW,aAAa,GAC3C,OAAO;CAGT,MAAM,iBACJ,iBAAiB,kBAAkB,eAC/B,GAAG,aAAa,MAAM,kBACtB;CAEN,QAAQ,MACN,kEAAkE,eAAe,uGACnF;CAEA,OAAO;AACT;AAEA,SAAgB,qBACd,kBACA;CACA,IAAI,OAAO,qBAAqB,YAC9B,OAAO;CAGT,aAAa,oBAAoB;AACnC;AAWA,SAAgB,yBAAyB,MAA2B;CAClE,MAAM,gBAAgB;EACpB,WAAW;EACX,mBAAmB;EACnB,GAAI,KAAK,YAAY,CAAC,IAAI,EAAE,WAAW,QAAQ;CACjD;CAKA,MAAM,oBAAoB,yBAAyB,QAAQ,KAAK,QAAQ,CAAC;CACzE,MAAM,iBAAiB,oBACnB,+BAA+B,iBAAiB,IAChD,KAAA;CAEJ,MAAM,kBAAkE,EACtE,SAAS,CACP,6BACE;EACE,UAAU,KAAK;EACf,WAAW,CAAC,KAAK;EACjB,uBAAuB,KAAK;EAC5B,KAAK,KAAK;EACV,aAAa,KAAK;CACpB,GACA,KAAK,QACL,CAAC,KAAK,oBACN,cACF,CACF,EACF;CAEA,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;EACpB,GACA,KAAK,QACL,CAAC,KAAK,oBACN,cACF,CACF;EACA,QAAQ;CACV;CAMA,OAAO,EACL,cAAc;EACZ,SAAS,CAAC,kBAAkB,MAAM;EAClC,SAAS,CAAC,0BAA0B;EACpC,GAAI,KAAK,kBAAkB,EAAE,gBAAgB,IAAI,EAAE,eAAe;CACpE,EACF;AACF"}
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 { isRolldown } from './rolldown.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: RegExp = /\\.[cm]?ts(?![a-z])/;\n\n// Spec files stay included — a newly added spec must join the program's\n// root names in Vitest watch mode.\nexport const EXCLUDED_TS_EXT_REGEX: RegExp = /\\.d\\.[cm]?ts$/;\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\n/**\n * Whether a Vite environment runs on the server. `configEnvironment` sees the\n * environment's options before Vite resolves them, so an unset `consumer`\n * falls back to Vite's own default: every environment except `client` is a\n * server environment.\n */\nexport function isServerEnvironment(\n name: string,\n config: { consumer?: string },\n): boolean {\n return (\n (config.consumer ?? (name === 'client' ? 'client' : 'server')) === 'server'\n );\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): string {\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): () => string {\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 optimizeDeps: vite.DepOptimizationOptions;\n} {\n const defineOptions = {\n ...(opts.jit ? {} : { 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', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(isRolldown() ? { rolldownOptions } : { esbuildOptions }),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAa,eAAuB;AAIpC,IAAa,wBAAgC;;;;;;;AAQ7C,SAAgB,WAAW,MAAmC;CAC5D,IAAI,SAAS,eACX,OAAO;CAGT,OAAO,SAAS,gBAAA,QAAA,IAAA,aAA4C;AAC9D;;;;;;;AAQA,SAAgB,oBACd,MACA,QACS;CACT,QACG,OAAO,aAAa,SAAS,WAAW,WAAW,eAAe;AAEvE;AAQA,SAAgB,gBACd,MACA,UACA,QACA,QACA,OACA,eACQ;CAC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AAK,KAAK;GACV,aAAa,KAAK;EACpB,GACA,KAAK,QACL,CAAC,KAAK,oBACN,cACF,CACF;EACA,QAAQ;CACV;CAMA,OAAO,EACL,cAAc;EACZ,SAAS;GAAC;GAAkB;GAAQ;EAAO;EAC3C,SAAS,CAAC,0BAA0B;EACpC,GAAI,WAAW,IAAI,EAAE,gBAAgB,IAAI,EAAE,eAAe;CAC5D,EACF;AACF"}
@@ -1,12 +1,11 @@
1
1
  import * as vite from "vite";
2
- //#region packages/vite-plugin-angular/src/lib/utils/rolldown.ts
2
+ // packages/vite-plugin-angular/src/lib/utils/rolldown.ts
3
3
  function isRolldown() {
4
4
  return !!vite.rolldownVersion;
5
5
  }
6
6
  function getJsTransformConfigKey() {
7
7
  return isRolldown() ? "oxc" : "esbuild";
8
8
  }
9
- //#endregion
10
9
  export { getJsTransformConfigKey, isRolldown };
11
10
 
12
11
  //# sourceMappingURL=rolldown.js.map
@@ -1,5 +1,5 @@
1
1
  import { normalizePath } from "vite";
2
- //#region packages/vite-plugin-angular/src/lib/utils/safe-module-paths.ts
2
+ // packages/vite-plugin-angular/src/lib/utils/safe-module-paths.ts
3
3
  /**
4
4
  * Mark a style file path as safe in Vite's `safeModulePaths` set so the
5
5
  * `?inline` import passes the Denied ID security check without needing
@@ -23,7 +23,6 @@ function markStylePathSafe(config, absPath) {
23
23
  safeModulePaths.add(normalized + "?inline");
24
24
  }
25
25
  }
26
- //#endregion
27
26
  export { markStylePathSafe };
28
27
 
29
28
  //# sourceMappingURL=safe-module-paths.js.map
@@ -0,0 +1,2 @@
1
+ import type { Logger } from "vite";
2
+ export declare function reportStylesheetError(logger: Logger | undefined, filename: string, error: unknown, isBuild: boolean): void;
@@ -0,0 +1,10 @@
1
+ // packages/vite-plugin-angular/src/lib/utils/stylesheet-warning.ts
2
+ function reportStylesheetError(logger, filename, error, isBuild) {
3
+ const message = `[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}`;
4
+ const detail = error instanceof Error ? error.message : String(error);
5
+ if (isBuild) throw new Error(`${message}. ${detail}`, { cause: error });
6
+ logger?.warn(`${message}; it was left unprocessed. ${detail}`, { timestamp: true });
7
+ }
8
+ export { reportStylesheetError };
9
+
10
+ //# sourceMappingURL=stylesheet-warning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stylesheet-warning.js","names":[],"sources":["../../../../src/lib/utils/stylesheet-warning.ts"],"sourcesContent":["import type { Logger } from 'vite';\n\nexport function reportStylesheetError(\n logger: Logger | undefined,\n filename: string,\n error: unknown,\n isBuild: boolean,\n): void {\n const message = `[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}`;\n const detail = error instanceof Error ? error.message : String(error);\n if (isBuild) {\n throw new Error(`${message}. ${detail}`, { cause: error });\n }\n logger?.warn(`${message}; it was left unprocessed. ${detail}`, {\n timestamp: true,\n });\n}\n"],"mappings":";AAEA,SAAgB,sBACd,QACA,UACA,OACA,SACM;CACN,MAAM,UAAU,gEAAgE;CAChF,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACpE,IAAI,SACF,MAAM,IAAI,MAAM,GAAG,QAAQ,IAAI,UAAU,EAAE,OAAO,MAAM,CAAC;CAE3D,QAAQ,KAAK,GAAG,QAAQ,6BAA6B,UAAU,EAC7D,WAAW,KACb,CAAC;AACH"}
@@ -3,7 +3,7 @@ import * as fs from "node:fs";
3
3
  import * as path$1 from "node:path";
4
4
  import { createDebug } from "obug";
5
5
  import { VERSION } from "@angular/compiler";
6
- //#region packages/vite-plugin-angular/src/lib/utils/transform-cache.ts
6
+ // packages/vite-plugin-angular/src/lib/utils/transform-cache.ts
7
7
  var debugCache = createDebug("analog-transform-cache");
8
8
  /**
9
9
  * Disk-backed content-addressed store for linked/transformed dependency
@@ -91,7 +91,6 @@ function resolveTransformCacheDir(startDir) {
91
91
  dir = parent;
92
92
  }
93
93
  }
94
- //#endregion
95
94
  export { createPersistentTransformCache, resolveTransformCacheDir, withMemoryLayer };
96
95
 
97
96
  //# sourceMappingURL=transform-cache.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform-cache.js","names":[],"sources":["../../../../src/lib/utils/transform-cache.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\nimport { VERSION } from '@angular/compiler';\nimport { createDebug } from 'obug';\n\nconst debugCache = createDebug('analog-transform-cache');\n\n/**\n * The `{ get, put }` shape `@angular/build`'s `JavaScriptTransformer`\n * accepts. Keys are content hashes the\n * transformer derives from the file bytes plus every option that affects\n * output, so entries are immutable and never need invalidation — but the\n * digest does NOT cover the linker version, so stores must be namespaced\n * by Angular version (see {@link resolveTransformCacheDir}).\n */\nexport interface TransformCacheStore {\n get(key: string): Promise<Uint8Array | undefined> | Uint8Array | undefined;\n put(key: string, value: Uint8Array): Promise<void> | void;\n}\n\ninterface TransformCacheStats {\n hits: number;\n misses: number;\n writes: number;\n /** Approximate total ms spent in the linker worker for cache misses. */\n workerMs: number;\n}\n\n/**\n * Disk-backed content-addressed store for linked/transformed dependency\n * output. Entries are written atomically (temp + rename) so concurrent\n * dev servers can share a directory; all failures degrade to a miss.\n */\nexport function createPersistentTransformCache(\n baseDir: string,\n): TransformCacheStore & { stats: TransformCacheStats } {\n const stats: TransformCacheStats = {\n hits: 0,\n misses: 0,\n writes: 0,\n workerMs: 0,\n };\n // Miss timestamps by key: with the transformer's serialized worker, the\n // gap between a missed get and its put approximates linker time per file.\n const missedAt = new Map<string, number>();\n\n const entryPath = (key: string) => path.join(baseDir, key.slice(0, 2), key);\n\n return {\n stats,\n async get(key: string): Promise<Uint8Array | undefined> {\n try {\n const value = await fs.promises.readFile(entryPath(key));\n stats.hits++;\n debugCache('hit %s (hits=%d misses=%d)', key, stats.hits, stats.misses);\n return value;\n } catch {\n stats.misses++;\n missedAt.set(key, performance.now());\n debugCache(\n 'miss %s (hits=%d misses=%d)',\n key,\n stats.hits,\n stats.misses,\n );\n return undefined;\n }\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n const startedAt = missedAt.get(key);\n if (startedAt !== undefined) {\n missedAt.delete(key);\n stats.workerMs += performance.now() - startedAt;\n }\n try {\n const file = entryPath(key);\n await fs.promises.mkdir(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;\n await fs.promises.writeFile(tmp, value);\n await fs.promises.rename(tmp, file);\n stats.writes++;\n debugCache(\n 'put %s (writes=%d workerMs=%d)',\n key,\n stats.writes,\n Math.round(stats.workerMs),\n );\n } catch (e) {\n debugCache('put failed %s: %s', key, (e as Error)?.message);\n }\n },\n };\n}\n\n/**\n * Layer an unbounded in-memory map over a persistent store so repeat\n * transforms in the same session never touch the disk.\n */\nexport function withMemoryLayer(\n store: TransformCacheStore,\n): TransformCacheStore {\n const memory = new Map<string, Uint8Array>();\n return {\n async get(key: string): Promise<Uint8Array | undefined> {\n const cached = memory.get(key) ?? (await store.get(key));\n if (cached) memory.set(key, cached);\n return cached;\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n memory.set(key, value);\n await store.put(key, value);\n },\n };\n}\n\n/**\n * Resolve the shared on-disk cache directory: `node_modules/.cache` at the\n * nearest `node_modules` above `startDir` — the conventional tool-cache\n * location, so installs and `node_modules` cleans evict it without a\n * separate eviction pass. Namespaced by the installed Angular version\n * because the transformer's cache key does not cover the linker version.\n * Returns `null` (caching disabled) when no `node_modules` exists or the\n * `ANALOG_TRANSFORM_CACHE=0` kill switch is set.\n */\nexport function resolveTransformCacheDir(startDir: string): string | null {\n if (process.env['ANALOG_TRANSFORM_CACHE'] === '0') return null;\n let dir = path.resolve(startDir);\n for (;;) {\n if (fs.existsSync(path.join(dir, 'node_modules'))) {\n return path.join(\n dir,\n 'node_modules',\n '.cache',\n 'analog',\n 'transform-cache',\n VERSION.full,\n );\n }\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,YAAY,wBAAwB;;;;;;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I,KAA8C;GACtD,MAAM,SAAS,OAAO,IAAI,GAAG,KAAM,MAAM,MAAM,IAAI,GAAG;GACtD,IAAI,QAAQ,OAAO,IAAI,KAAK,MAAM;GAClC,OAAO;EACT;EACA,MAAM,IAAI,KAAa,OAAkC;GACvD,OAAO,IAAI,KAAK,KAAK;GACrB,MAAM,MAAM,IAAI,KAAK,KAAK;EAC5B;CACF;AACF;;;;;;;;;;AAWA,SAAgB,yBAAyB,UAAiC;CACxE,IAAI,QAAQ,IAAI,8BAA8B,KAAK,OAAO;CAC1D,IAAI,MAAM,OAAK,QAAQ,QAAQ;CAC/B,SAAS;EACP,IAAI,GAAG,WAAW,OAAK,KAAK,KAAK,cAAc,CAAC,GAC9C,OAAO,OAAK,KACV,KACA,gBACA,UACA,UACA,mBACA,QAAQ,IACV;EAEF,MAAM,SAAS,OAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"transform-cache.js","names":["path"],"sources":["../../../../src/lib/utils/transform-cache.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\nimport { VERSION } from '@angular/compiler';\nimport { createDebug } from 'obug';\n\nconst debugCache = createDebug('analog-transform-cache');\n\n/**\n * The `{ get, put }` shape `@angular/build`'s `JavaScriptTransformer`\n * accepts. Keys are content hashes the\n * transformer derives from the file bytes plus every option that affects\n * output, so entries are immutable and never need invalidation — but the\n * digest does NOT cover the linker version, so stores must be namespaced\n * by Angular version (see {@link resolveTransformCacheDir}).\n */\nexport interface TransformCacheStore {\n get(key: string): Promise<Uint8Array | undefined> | Uint8Array | undefined;\n put(key: string, value: Uint8Array): Promise<void> | void;\n}\n\ninterface TransformCacheStats {\n hits: number;\n misses: number;\n writes: number;\n /** Approximate total ms spent in the linker worker for cache misses. */\n workerMs: number;\n}\n\n/**\n * Disk-backed content-addressed store for linked/transformed dependency\n * output. Entries are written atomically (temp + rename) so concurrent\n * dev servers can share a directory; all failures degrade to a miss.\n */\nexport function createPersistentTransformCache(\n baseDir: string,\n): TransformCacheStore & { stats: TransformCacheStats } {\n const stats: TransformCacheStats = {\n hits: 0,\n misses: 0,\n writes: 0,\n workerMs: 0,\n };\n // Miss timestamps by key: with the transformer's serialized worker, the\n // gap between a missed get and its put approximates linker time per file.\n const missedAt = new Map<string, number>();\n\n const entryPath = (key: string) => path.join(baseDir, key.slice(0, 2), key);\n\n return {\n stats,\n async get(key: string): Promise<Uint8Array | undefined> {\n try {\n const value = await fs.promises.readFile(entryPath(key));\n stats.hits++;\n debugCache('hit %s (hits=%d misses=%d)', key, stats.hits, stats.misses);\n return value;\n } catch {\n stats.misses++;\n missedAt.set(key, performance.now());\n debugCache(\n 'miss %s (hits=%d misses=%d)',\n key,\n stats.hits,\n stats.misses,\n );\n return undefined;\n }\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n const startedAt = missedAt.get(key);\n if (startedAt !== undefined) {\n missedAt.delete(key);\n stats.workerMs += performance.now() - startedAt;\n }\n try {\n const file = entryPath(key);\n await fs.promises.mkdir(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;\n await fs.promises.writeFile(tmp, value);\n await fs.promises.rename(tmp, file);\n stats.writes++;\n debugCache(\n 'put %s (writes=%d workerMs=%d)',\n key,\n stats.writes,\n Math.round(stats.workerMs),\n );\n } catch (e) {\n debugCache('put failed %s: %s', key, (e as Error)?.message);\n }\n },\n };\n}\n\n/**\n * Layer an unbounded in-memory map over a persistent store so repeat\n * transforms in the same session never touch the disk.\n */\nexport function withMemoryLayer(\n store: TransformCacheStore,\n): TransformCacheStore {\n const memory = new Map<string, Uint8Array>();\n return {\n async get(key: string): Promise<Uint8Array | undefined> {\n const cached = memory.get(key) ?? (await store.get(key));\n if (cached) memory.set(key, cached);\n return cached;\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n memory.set(key, value);\n await store.put(key, value);\n },\n };\n}\n\n/**\n * Resolve the shared on-disk cache directory: `node_modules/.cache` at the\n * nearest `node_modules` above `startDir` — the conventional tool-cache\n * location, so installs and `node_modules` cleans evict it without a\n * separate eviction pass. Namespaced by the installed Angular version\n * because the transformer's cache key does not cover the linker version.\n * Returns `null` (caching disabled) when no `node_modules` exists or the\n * `ANALOG_TRANSFORM_CACHE=0` kill switch is set.\n */\nexport function resolveTransformCacheDir(startDir: string): string | null {\n if (process.env['ANALOG_TRANSFORM_CACHE'] === '0') return null;\n let dir = path.resolve(startDir);\n for (;;) {\n if (fs.existsSync(path.join(dir, 'node_modules'))) {\n return path.join(\n dir,\n 'node_modules',\n '.cache',\n 'analog',\n 'transform-cache',\n VERSION.full,\n );\n }\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,YAAY,wBAAwB;;;;;;AA4BvD,SAAgB,+BACd,SACsD;CACtD,MAAM,QAA6B;EACjC,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,UAAU;CACZ;CAGA,MAAM,2BAAW,IAAI,IAAoB;CAEzC,MAAM,aAAa,QAAgBA,OAAK,KAAK,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,GAAG;CAE1E,OAAO;EACL;EACA,MAAM,IAAI,KAA8C;GACtD,IAAI;IACF,MAAM,QAAQ,MAAM,GAAG,SAAS,SAAS,UAAU,GAAG,CAAC;IACvD,MAAM;IACN,WAAW,8BAA8B,KAAK,MAAM,MAAM,MAAM,MAAM;IACtE,OAAO;GACT,QAAQ;IACN,MAAM;IACN,SAAS,IAAI,KAAK,YAAY,IAAI,CAAC;IACnC,WACE,+BACA,KACA,MAAM,MACN,MAAM,MACR;IACA;GACF;EACF;EACA,MAAM,IAAI,KAAa,OAAkC;GACvD,MAAM,YAAY,SAAS,IAAI,GAAG;GAClC,IAAI,cAAc,KAAA,GAAW;IAC3B,SAAS,OAAO,GAAG;IACnB,MAAM,YAAY,YAAY,IAA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Sync } from "node:fs";
3
- import { dirname, isAbsolute, join, resolve } from "node:path";
4
3
  import { createRequire } from "node:module";
4
+ import { dirname, isAbsolute, join, resolve } from "node:path";
5
5
  import { normalizePath } from "vite";
6
6
  import * as compilerCli from "@angular/compiler-cli";
7
7
  import { globSync } from "tinyglobby";
8
- //#region packages/vite-plugin-angular/src/lib/utils/tsconfig-resolver.ts
8
+ // packages/vite-plugin-angular/src/lib/utils/tsconfig-resolver.ts
9
9
  /**
10
10
  * Shared tsconfig resolution logic used by both the ngtsc and compilation-api
11
11
  * compilation plugins. Encapsulates the caching, include-glob discovery,
@@ -200,7 +200,6 @@ function collectTsconfigPathRoots(resolvedTsConfigPath, options, rawTsconfig) {
200
200
  }
201
201
  return [...discoveredRoots];
202
202
  }
203
- //#endregion
204
203
  export { TsconfigResolver, normalizeIncludeGlob };
205
204
 
206
205
  //# sourceMappingURL=tsconfig-resolver.js.map
@@ -1,4 +1,4 @@
1
- //#region packages/vite-plugin-angular/src/lib/utils/virtual-ids.ts
1
+ // packages/vite-plugin-angular/src/lib/utils/virtual-ids.ts
2
2
  var VIRTUAL_RAW_PREFIX = "virtual:@analogjs/vite-plugin-angular:raw:";
3
3
  function encode(absPath) {
4
4
  return Buffer.from(absPath, "utf-8").toString("base64url");
@@ -17,7 +17,6 @@ function fromVirtualRawId(id) {
17
17
  if (!normalizedId.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) throw new Error(`Invalid virtual raw id: ${id}`);
18
18
  return decode(normalizedId.slice(42));
19
19
  }
20
- //#endregion
21
20
  export { VIRTUAL_RAW_PREFIX, fromVirtualRawId, isVirtualRawId, toVirtualRawId };
22
21
 
23
22
  //# sourceMappingURL=virtual-ids.js.map
@@ -2,7 +2,7 @@ import { fromVirtualRawId, isVirtualRawId, toVirtualRawId } from "./virtual-ids.
2
2
  import { promises } from "node:fs";
3
3
  import { dirname, isAbsolute, resolve } from "node:path";
4
4
  import { normalizePath } from "vite";
5
- //#region packages/vite-plugin-angular/src/lib/utils/virtual-resources.ts
5
+ // packages/vite-plugin-angular/src/lib/utils/virtual-resources.ts
6
6
  function resolveImportPath(id, importer) {
7
7
  const filePath = id.split("?")[0];
8
8
  return isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
@@ -32,7 +32,6 @@ async function loadVirtualRawModule(ctx, id) {
32
32
  const content = await promises.readFile(filePath, "utf-8");
33
33
  return `export default ${JSON.stringify(content)}`;
34
34
  }
35
- //#endregion
36
35
  export { loadVirtualRawModule, rewriteHtmlRawImport };
37
36
 
38
37
  //# sourceMappingURL=virtual-resources.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-resources.js","names":[],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates)\n// through virtual module ids. Both angular-vite-plugin and fast-compile-plugin\n// use these so the rewriting + loading behavior stays in sync between them.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport {\n fromVirtualRawId,\n isVirtualRawId,\n toVirtualRawId,\n} from './virtual-ids.js';\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n"],"mappings":";;;;;AAsBA,SAAS,kBACP,IACA,UACoB;CACpB,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;CAC/B,OAAO,WAAW,QAAQ,IACtB,cAAc,QAAQ,IACtB,WACE,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC,IAClD,KAAA;AACR;;;;;;;;;AAUA,SAAgB,qBACd,IACA,UACoB;CACpB,IAAI,CAAC,GAAG,SAAS,WAAW,GAAG,OAAO,KAAA;CACtC,MAAM,WAAW,kBAAkB,IAAI,QAAQ;CAC/C,OAAO,WAAW,eAAe,QAAQ,IAAI,KAAA;AAC/C;;;;;;AAOA,eAAsB,qBACpB,KACA,IAC6B;CAC7B,IAAI,CAAC,eAAe,EAAE,GAAG,OAAO,KAAA;CAChC,MAAM,WAAW,iBAAiB,EAAE;CACpC,IAAI,aAAa,QAAQ;CACzB,MAAM,UAAU,MAAM,SAAW,SAAS,UAAU,OAAO;CAC3D,OAAO,kBAAkB,KAAK,UAAU,OAAO;AACjD"}
1
+ {"version":3,"file":"virtual-resources.js","names":["fsPromises"],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates)\n// through virtual module ids. Both angular-vite-plugin and fast-compile-plugin\n// use these so the rewriting + loading behavior stays in sync between them.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport {\n fromVirtualRawId,\n isVirtualRawId,\n toVirtualRawId,\n} from './virtual-ids.js';\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n"],"mappings":";;;;;AAsBA,SAAS,kBACP,IACA,UACoB;CACpB,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;CAC/B,OAAO,WAAW,QAAQ,IACtB,cAAc,QAAQ,IACtB,WACE,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC,IAClD,KAAA;AACR;;;;;;;;;AAUA,SAAgB,qBACd,IACA,UACoB;CACpB,IAAI,CAAC,GAAG,SAAS,WAAW,GAAG,OAAO,KAAA;CACtC,MAAM,WAAW,kBAAkB,IAAI,QAAQ;CAC/C,OAAO,WAAW,eAAe,QAAQ,IAAI,KAAA;AAC/C;;;;;;AAOA,eAAsB,qBACpB,KACA,IAC6B;CAC7B,IAAI,CAAC,eAAe,EAAE,GAAG,OAAO,KAAA;CAChC,MAAM,WAAW,iBAAiB,EAAE;CACpC,IAAI,aAAa,QAAQ;CACzB,MAAM,UAAU,MAAMA,SAAW,SAAS,UAAU,OAAO;CAC3D,OAAO,kBAAkB,KAAK,UAAU,OAAO;AACjD"}
@@ -1,5 +1,13 @@
1
- import { Plugin } from "vite";
1
+ import { type Plugin, type ResolvedConfig } from "vite";
2
+ import { type AngularBuildContext } from "./angular-build-context.js";
2
3
  export interface VirtualModulesPluginOptions {
3
- jit: boolean;
4
+ jit?: boolean;
4
5
  }
5
- export declare function virtualModulesPlugin(pluginOptions: VirtualModulesPluginOptions): Plugin;
6
+ export declare function resolveAngularVirtualId(id: string, importer: string | undefined, options: {
7
+ jit: boolean;
8
+ resolvedConfig?: ResolvedConfig;
9
+ }): string | undefined;
10
+ export declare function loadAngularVirtualModule(pluginCtx: {
11
+ addWatchFile(path: string): void;
12
+ }, id: string, resolvedConfig?: ResolvedConfig): Promise<string | undefined>;
13
+ export declare function virtualModulesPlugin(ctxOrOptions?: AngularBuildContext | VirtualModulesPluginOptions): Plugin;
@@ -1,26 +1,81 @@
1
+ import { isAngularBuildContext } from "./angular-build-context.js";
2
+ import { markStylePathSafe } from "./utils/safe-module-paths.js";
1
3
  import { toVirtualRawId } from "./utils/virtual-ids.js";
2
- import { dirname, isAbsolute, resolve } from "node:path";
4
+ import { loadVirtualRawModule, rewriteHtmlRawImport } from "./utils/virtual-resources.js";
5
+ import { statSync } from "node:fs";
6
+ import { dirname, isAbsolute, join, resolve } from "node:path";
3
7
  import { normalizePath } from "vite";
4
- //#region packages/vite-plugin-angular/src/lib/virtual-modules-plugin.ts
5
- function virtualModulesPlugin(pluginOptions) {
8
+ // packages/vite-plugin-angular/src/lib/virtual-modules-plugin.ts
9
+ var FS_PREFIX = "/@fs/";
10
+ function isDirectory(path) {
11
+ return statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;
12
+ }
13
+ /**
14
+ * The file a URL that Vite wrote into a module's code points at. Vitest
15
+ * resolves the imports of a module restored from `fsModuleCache` by these
16
+ * URLs, so they must resolve to the same file as the original import.
17
+ * `/@fs/<path>` is that path. A root-relative URL (`/src/app/a.css`) is the
18
+ * file under the Vite root when there is one; otherwise the caller reads it
19
+ * as the path given, which is the order Vite tries the two in. A URL that
20
+ * already starts with the root's path is root-relative only when the root
21
+ * holds a directory at its own path (`/app/app`), as in Vite's resolver.
22
+ */
23
+ function resolveViteUrl(url, root) {
24
+ if (url.startsWith(FS_PREFIX)) {
25
+ const fsPath = url.slice(5);
26
+ return /^[A-Z]:/i.test(fsPath) ? fsPath : `/${fsPath}`;
27
+ }
28
+ if (!root || !url.startsWith("/")) return;
29
+ if (url.startsWith(`${root}/`) && !isDirectory(join(root, root))) return;
30
+ const filePath = join(root, url);
31
+ return statSync(filePath, { throwIfNoEntry: false })?.isFile() ? filePath : void 0;
32
+ }
33
+ function resolveAngularVirtualId(id, importer, options) {
34
+ if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
35
+ if (options.jit && id.startsWith("angular:jit:")) {
36
+ const filePath = normalizePath(resolve(dirname(importer), id.split(";")[1]));
37
+ if (id.includes(":style")) {
38
+ markStylePathSafe(options.resolvedConfig, filePath);
39
+ return filePath + "?inline";
40
+ }
41
+ return toVirtualRawId(filePath);
42
+ }
43
+ const rawRewrite = rewriteHtmlRawImport(id, importer);
44
+ if (rawRewrite) return rawRewrite;
45
+ if (/\.(css|scss|sass|less)\?inline$/.test(id) && importer) {
46
+ const filePath = id.split("?")[0];
47
+ const resolved = normalizePath(resolveViteUrl(filePath, options.resolvedConfig?.root) ?? (isAbsolute(filePath) ? filePath : resolve(dirname(importer), filePath)));
48
+ markStylePathSafe(options.resolvedConfig, resolved);
49
+ return resolved + "?inline";
50
+ }
51
+ }
52
+ async function loadAngularVirtualModule(pluginCtx, id, resolvedConfig) {
53
+ const rawModule = await loadVirtualRawModule(pluginCtx, id);
54
+ if (rawModule !== void 0) return rawModule;
55
+ if (/\.(css|scss|sass|less)\?inline$/.test(id)) markStylePathSafe(resolvedConfig, id.split("?")[0]);
56
+ }
57
+ function virtualModulesPlugin(ctxOrOptions) {
58
+ const sharedCtx = isAngularBuildContext(ctxOrOptions) ? ctxOrOptions : void 0;
59
+ const standaloneJit = isAngularBuildContext(ctxOrOptions) ? ctxOrOptions.options.jit : ctxOrOptions?.jit ?? false;
60
+ let localConfig;
6
61
  return {
7
62
  name: "@analogjs/vite-plugin-angular:virtual-modules",
8
63
  enforce: "pre",
64
+ configResolved(config) {
65
+ localConfig = config;
66
+ sharedCtx?.setResolvedConfig(config);
67
+ },
9
68
  resolveId(id, importer) {
10
- if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
11
- if (pluginOptions.jit && id.startsWith("angular:jit:")) {
12
- const filePath = normalizePath(resolve(dirname(importer), id.split(";")[1]));
13
- return toVirtualRawId(filePath);
14
- }
15
- if (id.includes(".html?raw")) {
16
- const filePath = id.split("?")[0];
17
- const resolved = isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
18
- if (resolved) return toVirtualRawId(resolved);
19
- }
69
+ return resolveAngularVirtualId(id, importer, {
70
+ jit: sharedCtx ? sharedCtx.options.jit : standaloneJit,
71
+ resolvedConfig: sharedCtx?.resolvedConfig ?? localConfig
72
+ });
73
+ },
74
+ async load(id) {
75
+ return loadAngularVirtualModule(this, id, sharedCtx?.resolvedConfig ?? localConfig);
20
76
  }
21
77
  };
22
78
  }
23
- //#endregion
24
- export { virtualModulesPlugin };
79
+ export { loadAngularVirtualModule, resolveAngularVirtualId, virtualModulesPlugin };
25
80
 
26
81
  //# sourceMappingURL=virtual-modules-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAQA,SAAgB,qBACd,eACQ;CACR,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,IAAI,UAAU;GACtB,IAAI,GAAG,WAAA,4CAA6B,GAClC,OAAO,KAAK;GAGd,IAAI,cAAc,OAAO,GAAG,WAAW,cAAc,GAAG;IACtD,MAAM,WAAW,cACf,QAAQ,QAAQ,QAAkB,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CACvD;IACA,OAAO,eAAe,QAAQ;GAChC;GAGA,IAAI,GAAG,SAAS,WAAW,GAAG;IAC5B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;IAC/B,MAAM,WAAW,WAAW,QAAQ,IAChC,cAAc,QAAQ,IACtB,WACE,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC,IAClD,KAAA;IACN,IAAI,UACF,OAAO,eAAe,QAAQ;GAElC;EAGF;CACF;AACF"}
1
+ {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { normalizePath, type Plugin, type ResolvedConfig } from 'vite';\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { markStylePathSafe } from './utils/safe-module-paths.js';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\nimport {\n loadVirtualRawModule,\n rewriteHtmlRawImport,\n} from './utils/virtual-resources.js';\n\nexport interface VirtualModulesPluginOptions {\n jit?: boolean;\n}\n\nconst FS_PREFIX = '/@fs/';\n\nfunction isDirectory(path: string): boolean {\n return statSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;\n}\n\n/**\n * The file a URL that Vite wrote into a module's code points at. Vitest\n * resolves the imports of a module restored from `fsModuleCache` by these\n * URLs, so they must resolve to the same file as the original import.\n * `/@fs/<path>` is that path. A root-relative URL (`/src/app/a.css`) is the\n * file under the Vite root when there is one; otherwise the caller reads it\n * as the path given, which is the order Vite tries the two in. A URL that\n * already starts with the root's path is root-relative only when the root\n * holds a directory at its own path (`/app/app`), as in Vite's resolver.\n */\nfunction resolveViteUrl(\n url: string,\n root: string | undefined,\n): string | undefined {\n if (url.startsWith(FS_PREFIX)) {\n const fsPath = url.slice(FS_PREFIX.length);\n // `/@fs/C:/a.css` on Windows, `/@fs/home/a.css` elsewhere.\n return /^[A-Z]:/i.test(fsPath) ? fsPath : `/${fsPath}`;\n }\n if (!root || !url.startsWith('/')) {\n return undefined;\n }\n if (url.startsWith(`${root}/`) && !isDirectory(join(root, root))) {\n return undefined;\n }\n const filePath = join(root, url);\n return statSync(filePath, { throwIfNoEntry: false })?.isFile()\n ? filePath\n : undefined;\n}\n\nexport function resolveAngularVirtualId(\n id: string,\n importer: string | undefined,\n options: {\n jit: boolean;\n resolvedConfig?: ResolvedConfig;\n },\n): string | undefined {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (options.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n if (id.includes(':style')) {\n markStylePathSafe(options.resolvedConfig, filePath);\n return filePath + '?inline';\n }\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n const rawRewrite = rewriteHtmlRawImport(id, importer);\n if (rawRewrite) {\n return rawRewrite;\n }\n\n // User `.scss?inline` / `.css?inline` imports: resolve and mark\n // safe so Vite's native CSS pipeline handles them.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id) && importer) {\n const filePath = id.split('?')[0];\n const resolved = normalizePath(\n resolveViteUrl(filePath, options.resolvedConfig?.root) ??\n (isAbsolute(filePath)\n ? filePath\n : resolve(dirname(importer), filePath)),\n );\n markStylePathSafe(options.resolvedConfig, resolved);\n return resolved + '?inline';\n }\n\n return undefined;\n}\n\nexport async function loadAngularVirtualModule(\n pluginCtx: { addWatchFile(path: string): void },\n id: string,\n resolvedConfig?: ResolvedConfig,\n): Promise<string | undefined> {\n const rawModule = await loadVirtualRawModule(pluginCtx, id);\n if (rawModule !== undefined) {\n return rawModule;\n }\n\n // Vitest fallback: the module-runner can skip resolveId, so the bare\n // ?inline query reaches load. Mark safe and let Vite handle it.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id)) {\n markStylePathSafe(resolvedConfig, id.split('?')[0]);\n }\n\n return undefined;\n}\n\nexport function virtualModulesPlugin(\n ctxOrOptions?: AngularBuildContext | VirtualModulesPluginOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions\n : undefined;\n const standaloneJit = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.jit\n : (ctxOrOptions?.jit ?? false);\n let localConfig: ResolvedConfig | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n configResolved(config) {\n localConfig = config;\n sharedCtx?.setResolvedConfig(config);\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: sharedCtx ? sharedCtx.options.jit : standaloneJit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? localConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? localConfig,\n );\n },\n };\n}\n"],"mappings":";;;;;;;;AAkBA,IAAM,YAAY;AAElB,SAAS,YAAY,MAAuB;CAC1C,OAAO,SAAS,MAAM,EAAE,gBAAgB,MAAM,CAAC,CAAC,EAAE,YAAY,KAAK;AACrE;;;;;;;;;;;AAYA,SAAS,eACP,KACA,MACoB;CACpB,IAAI,IAAI,WAAW,SAAS,GAAG;EAC7B,MAAM,SAAS,IAAI,MAAM,CAAgB;EAEzC,OAAO,WAAW,KAAK,MAAM,IAAI,SAAS,IAAI;CAChD;CACA,IAAI,CAAC,QAAQ,CAAC,IAAI,WAAW,GAAG,GAC9B;CAEF,IAAI,IAAI,WAAW,GAAG,KAAK,EAAE,KAAK,CAAC,YAAY,KAAK,MAAM,IAAI,CAAC,GAC7D;CAEF,MAAM,WAAW,KAAK,MAAM,GAAG;CAC/B,OAAO,SAAS,UAAU,EAAE,gBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,IACzD,WACA,KAAA;AACN;AAEA,SAAgB,wBACd,IACA,UACA,SAIoB;CACpB,IAAI,GAAG,WAAA,4CAA6B,GAClC,OAAO,KAAK;CAGd,IAAI,QAAQ,OAAO,GAAG,WAAW,cAAc,GAAG;EAChD,MAAM,WAAW,cACf,QAAQ,QAAQ,QAAkB,GAAG,GAAG,MAAM,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