@analogjs/vite-plugin-angular 3.0.0-alpha.9 → 3.0.0-alpha.90

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 (184) hide show
  1. package/README.md +121 -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 +49 -8
  11. package/src/index.d.ts +7 -2
  12. package/src/index.js +3 -1
  13. package/src/index.js.map +1 -1
  14. package/src/lib/analog-plugin-interop.d.ts +78 -0
  15. package/src/lib/analog-plugin-interop.js +97 -0
  16. package/src/lib/analog-plugin-interop.js.map +1 -0
  17. package/src/lib/angular-build-optimizer-plugin.d.ts +8 -4
  18. package/src/lib/angular-build-optimizer-plugin.js +66 -31
  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 +28 -6
  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.map +1 -1
  25. package/src/lib/angular-vite-plugin.d.ts +79 -69
  26. package/src/lib/angular-vite-plugin.js +774 -352
  27. package/src/lib/angular-vite-plugin.js.map +1 -1
  28. package/src/lib/angular-vitest-plugin.d.ts +26 -21
  29. package/src/lib/angular-vitest-plugin.js +34 -25
  30. package/src/lib/angular-vitest-plugin.js.map +1 -1
  31. package/src/lib/compilation-api/compilation-api-plugin.d.ts +24 -0
  32. package/src/lib/compilation-api/compilation-api-plugin.js +547 -0
  33. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
  34. package/src/lib/compilation-api/index.d.ts +1 -0
  35. package/src/lib/compilation-api/index.js +1 -0
  36. package/src/lib/compiler/angular-version.d.ts +19 -0
  37. package/src/lib/compiler/angular-version.js +31 -0
  38. package/src/lib/compiler/angular-version.js.map +1 -0
  39. package/src/lib/compiler/class-field-lowering.d.ts +23 -0
  40. package/src/lib/compiler/class-field-lowering.js +131 -0
  41. package/src/lib/compiler/class-field-lowering.js.map +1 -0
  42. package/src/lib/compiler/compile.d.ts +50 -0
  43. package/src/lib/compiler/compile.js +814 -0
  44. package/src/lib/compiler/compile.js.map +1 -0
  45. package/src/lib/compiler/constants.d.ts +24 -0
  46. package/src/lib/compiler/constants.js +59 -0
  47. package/src/lib/compiler/constants.js.map +1 -0
  48. package/src/lib/compiler/debug.d.ts +22 -0
  49. package/src/lib/compiler/debug.js +20 -0
  50. package/src/lib/compiler/debug.js.map +1 -0
  51. package/src/lib/compiler/defer.d.ts +57 -0
  52. package/src/lib/compiler/defer.js +154 -0
  53. package/src/lib/compiler/defer.js.map +1 -0
  54. package/src/lib/compiler/dts-reader.d.ts +45 -0
  55. package/src/lib/compiler/dts-reader.js +395 -0
  56. package/src/lib/compiler/dts-reader.js.map +1 -0
  57. package/src/lib/compiler/hmr.d.ts +16 -0
  58. package/src/lib/compiler/hmr.js +69 -0
  59. package/src/lib/compiler/hmr.js.map +1 -0
  60. package/src/lib/compiler/index.d.ts +8 -0
  61. package/src/lib/compiler/index.js +8 -0
  62. package/src/lib/compiler/jit-metadata.d.ts +14 -0
  63. package/src/lib/compiler/jit-metadata.js +168 -0
  64. package/src/lib/compiler/jit-metadata.js.map +1 -0
  65. package/src/lib/compiler/jit-transform.d.ts +24 -0
  66. package/src/lib/compiler/jit-transform.js +204 -0
  67. package/src/lib/compiler/jit-transform.js.map +1 -0
  68. package/src/lib/compiler/js-emitter.d.ts +10 -0
  69. package/src/lib/compiler/js-emitter.js +446 -0
  70. package/src/lib/compiler/js-emitter.js.map +1 -0
  71. package/src/lib/compiler/metadata.d.ts +36 -0
  72. package/src/lib/compiler/metadata.js +710 -0
  73. package/src/lib/compiler/metadata.js.map +1 -0
  74. package/src/lib/compiler/registry.d.ts +56 -0
  75. package/src/lib/compiler/registry.js +176 -0
  76. package/src/lib/compiler/registry.js.map +1 -0
  77. package/src/lib/compiler/resource-inliner.d.ts +43 -0
  78. package/src/lib/compiler/resource-inliner.js +230 -0
  79. package/src/lib/compiler/resource-inliner.js.map +1 -0
  80. package/src/lib/compiler/style-ast.d.ts +9 -0
  81. package/src/lib/compiler/style-ast.js +54 -0
  82. package/src/lib/compiler/style-ast.js.map +1 -0
  83. package/src/lib/compiler/styles.d.ts +13 -0
  84. package/src/lib/compiler/test-helpers.d.ts +7 -0
  85. package/src/lib/compiler/type-elision.d.ts +28 -0
  86. package/src/lib/compiler/type-elision.js +211 -0
  87. package/src/lib/compiler/type-elision.js.map +1 -0
  88. package/src/lib/compiler/utils.d.ts +40 -0
  89. package/src/lib/compiler/utils.js +76 -0
  90. package/src/lib/compiler/utils.js.map +1 -0
  91. package/src/lib/compiler-plugin.d.ts +13 -12
  92. package/src/lib/compiler-plugin.js +18 -18
  93. package/src/lib/compiler-plugin.js.map +1 -1
  94. package/src/lib/component-resolvers.d.ts +20 -4
  95. package/src/lib/component-resolvers.js +34 -20
  96. package/src/lib/component-resolvers.js.map +1 -1
  97. package/src/lib/encapsulation-plugin.d.ts +23 -0
  98. package/src/lib/encapsulation-plugin.js +68 -0
  99. package/src/lib/encapsulation-plugin.js.map +1 -0
  100. package/src/lib/fast-compile-plugin.d.ts +23 -0
  101. package/src/lib/fast-compile-plugin.js +433 -0
  102. package/src/lib/fast-compile-plugin.js.map +1 -0
  103. package/src/lib/host.d.ts +10 -8
  104. package/src/lib/host.js +59 -17
  105. package/src/lib/host.js.map +1 -1
  106. package/src/lib/live-reload-plugin.d.ts +5 -5
  107. package/src/lib/live-reload-plugin.js +10 -0
  108. package/src/lib/live-reload-plugin.js.map +1 -1
  109. package/src/lib/models.d.ts +9 -9
  110. package/src/lib/nx-folder-plugin.d.ts +5 -5
  111. package/src/lib/nx-folder-plugin.js.map +1 -1
  112. package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
  113. package/src/lib/plugins/file-replacements.plugin.js +6 -1
  114. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  115. package/src/lib/router-plugin.d.ts +1 -1
  116. package/src/lib/router-plugin.js +14 -2
  117. package/src/lib/router-plugin.js.map +1 -1
  118. package/src/lib/style-preprocessor.d.ts +35 -0
  119. package/src/lib/style-preprocessor.js +35 -0
  120. package/src/lib/style-preprocessor.js.map +1 -0
  121. package/src/lib/stylesheet-registry.d.ts +74 -0
  122. package/src/lib/stylesheet-registry.js +174 -0
  123. package/src/lib/stylesheet-registry.js.map +1 -0
  124. package/src/lib/tools/package.json +1 -3
  125. package/src/lib/tools/src/builders/vite/vite-build.impl.js +7 -5
  126. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  127. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +16 -19
  128. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  129. package/src/lib/utils/compilation-shared.d.ts +62 -0
  130. package/src/lib/utils/compilation-shared.js +138 -0
  131. package/src/lib/utils/compilation-shared.js.map +1 -0
  132. package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
  133. package/src/lib/utils/css-extension-resolver.d.ts +32 -0
  134. package/src/lib/utils/css-extension-resolver.js +73 -0
  135. package/src/lib/utils/css-extension-resolver.js.map +1 -0
  136. package/src/lib/utils/css-preprocessor-workers.d.ts +6 -0
  137. package/src/lib/utils/css-preprocessor-workers.js +29 -0
  138. package/src/lib/utils/css-preprocessor-workers.js.map +1 -0
  139. package/src/lib/utils/debug-harness.d.ts +23 -0
  140. package/src/lib/utils/debug-harness.js +88 -0
  141. package/src/lib/utils/debug-harness.js.map +1 -0
  142. package/src/lib/utils/debug-log-file.d.ts +5 -0
  143. package/src/lib/utils/debug-log-file.js +56 -0
  144. package/src/lib/utils/debug-log-file.js.map +1 -0
  145. package/src/lib/utils/debug.d.ts +26 -0
  146. package/src/lib/utils/debug.js +35 -0
  147. package/src/lib/utils/debug.js.map +1 -0
  148. package/src/lib/utils/devkit.d.ts +14 -6
  149. package/src/lib/utils/devkit.js +40 -2
  150. package/src/lib/utils/devkit.js.map +1 -1
  151. package/src/lib/utils/hmr-candidates.d.ts +28 -28
  152. package/src/lib/utils/jit-inline-styles.d.ts +3 -0
  153. package/src/lib/utils/jit-inline-styles.js +16 -0
  154. package/src/lib/utils/jit-inline-styles.js.map +1 -0
  155. package/src/lib/utils/plugin-config.d.ts +41 -0
  156. package/src/lib/utils/plugin-config.js +85 -0
  157. package/src/lib/utils/plugin-config.js.map +1 -0
  158. package/src/lib/utils/rolldown.d.ts +1 -1
  159. package/src/lib/utils/rolldown.js.map +1 -1
  160. package/src/lib/utils/safe-module-paths.d.ts +16 -0
  161. package/src/lib/utils/safe-module-paths.js +29 -0
  162. package/src/lib/utils/safe-module-paths.js.map +1 -0
  163. package/src/lib/utils/source-file-cache.d.ts +8 -15
  164. package/src/lib/utils/source-file-cache.js.map +1 -1
  165. package/src/lib/utils/transform-cache.d.ts +43 -0
  166. package/src/lib/utils/transform-cache.js +97 -0
  167. package/src/lib/utils/transform-cache.js.map +1 -0
  168. package/src/lib/utils/tsconfig-resolver.d.ts +34 -0
  169. package/src/lib/utils/tsconfig-resolver.js +205 -0
  170. package/src/lib/utils/tsconfig-resolver.js.map +1 -0
  171. package/src/lib/utils/virtual-ids.d.ts +4 -0
  172. package/src/lib/utils/virtual-ids.js +23 -0
  173. package/src/lib/utils/virtual-ids.js.map +1 -0
  174. package/src/lib/utils/virtual-resources.d.ts +19 -0
  175. package/src/lib/utils/virtual-resources.js +38 -0
  176. package/src/lib/utils/virtual-resources.js.map +1 -0
  177. package/src/lib/virtual-modules-plugin.d.ts +5 -0
  178. package/src/lib/virtual-modules-plugin.js +23 -0
  179. package/src/lib/virtual-modules-plugin.js.map +1 -0
  180. package/src/test-setup.d.ts +2 -0
  181. package/setup-vitest.d.ts +0 -4
  182. package/setup-vitest.js +0 -176
  183. package/setup-vitest.js.map +0 -1
  184. package/src/lib/tools/src/index.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stylesheet-registry.js","names":[],"sources":["../../../src/lib/stylesheet-registry.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { dirname, normalize, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\nimport type {\n StylePreprocessor,\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetTransformResult,\n StylesheetTransformContext,\n} from './style-preprocessor.js';\nimport { normalizeStylesheetTransformResult as normalizeTransformResult } from './style-preprocessor.js';\n\nexport interface AnalogStylesheetRecord {\n publicId: string;\n sourcePath?: string;\n originalCode?: string;\n normalizedCode: string;\n dependencies?: StylesheetDependency[];\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n}\n\nexport class AnalogStylesheetRegistry {\n private servedById = new Map<string, AnalogStylesheetRecord>();\n private servedAliasToId = new Map<string, string>();\n private externalRequestToSource = new Map<string, string>();\n /**\n * Maps a real source stylesheet path back to the generated public stylesheet\n * ids Analog serves for Angular. This is stable across requests and lets HMR\n * reason about \"which virtual stylesheet came from this source file?\"\n */\n private sourceToPublicIds = new Map<string, Set<string>>();\n /**\n * Tracks the live request ids Vite/Angular have actually served for a source\n * stylesheet, including both `?direct&ngcomp=...` CSS modules and\n * `?ngcomp=...` JS wrapper modules. HMR must use these live request ids\n * because Angular component styles are no longer addressed by their original\n * file paths once externalized.\n */\n private sourceToRequestIds = new Map<string, Set<string>>();\n private sourceToDependencies = new Map<string, StylesheetDependency[]>();\n private sourceToDiagnostics = new Map<string, StylesheetDiagnostic[]>();\n private sourceToTags = new Map<string, string[]>();\n\n /**\n * Canonicalizes browser-facing stylesheet request ids so Vite timestamp\n * variants (`?t=...`) and path-shape variants (`abc.css?...` vs\n * `/abc.css?...`) all collapse onto one logical module identity.\n *\n * This is critical for Angular component stylesheet HMR because the browser\n * can keep both timestamped and non-timestamped requests alive for the same\n * externalized stylesheet. If Analog tracks them as distinct resources, HMR\n * can update one module while the browser continues rendering another stale\n * module for the same public stylesheet id.\n */\n private normalizeRequestId(requestId: string): string {\n const [rawPathname, rawSearch = ''] = requestId.split('?');\n const normalizedPathname = rawPathname.replace(/^\\//, '');\n\n if (!rawSearch) {\n return normalizedPathname;\n }\n\n // Preserve bare query flags like `?direct&ngcomp=...` exactly. Using\n // URLSearchParams reserializes `direct` as `direct=`, which changes the\n // module identity and breaks Vite module-graph lookups for Angular's\n // externalized component stylesheet requests.\n const normalizedSearch = rawSearch\n .split('&')\n .filter((segment) => segment.length > 0)\n .filter((segment) => {\n const [key] = segment.split('=');\n return key !== 't';\n })\n .join('&');\n\n return normalizedSearch\n ? `${normalizedPathname}?${normalizedSearch}`\n : normalizedPathname;\n }\n\n get servedCount(): number {\n return this.servedById.size;\n }\n\n get externalCount(): number {\n return this.externalRequestToSource.size;\n }\n\n hasServed(requestId: string): boolean {\n return this.resolveServedRecord(requestId) !== undefined;\n }\n\n getServedContent(requestId: string): string | undefined {\n return this.resolveServedRecord(requestId)?.normalizedCode;\n }\n\n getServedSourcePath(requestId: string): string | undefined {\n return this.resolveServedRecord(requestId)?.sourcePath;\n }\n\n resolveExternalSource(requestId: string): string | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n return this.externalRequestToSource.get(normalizedRequestId);\n }\n\n getPublicIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToPublicIds.get(sourcePath) ?? [])];\n }\n\n getRequestIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToRequestIds.get(sourcePath) ?? [])];\n }\n\n getDependenciesForSource(sourcePath: string): StylesheetDependency[] {\n return [...(this.sourceToDependencies.get(sourcePath) ?? [])];\n }\n\n getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[] {\n return [...(this.sourceToDiagnostics.get(sourcePath) ?? [])];\n }\n\n getTagsForSource(sourcePath: string): string[] {\n return [...(this.sourceToTags.get(sourcePath) ?? [])];\n }\n\n registerExternalRequest(requestId: string, sourcePath: string): void {\n this.externalRequestToSource.set(\n this.normalizeRequestId(requestId),\n sourcePath,\n );\n }\n\n registerActiveRequest(requestId: string): void {\n // Requests arrive in multiple shapes depending on who asked for the\n // stylesheet (`abc123.css?...` vs `/abc123.css?...`). Normalize both back to\n // the source file so later HMR events for `/src/...component.css` can find\n // the currently active virtual requests.\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const requestPath = normalizedRequestId.split('?')[0];\n const sourcePath =\n this.resolveExternalSource(requestPath) ??\n this.resolveExternalSource(requestPath.replace(/^\\//, '')) ??\n this.getServedSourcePath(requestPath) ??\n this.getServedSourcePath(requestPath.replace(/^\\//, ''));\n if (!sourcePath) {\n return;\n }\n\n const requestIds = this.sourceToRequestIds.get(sourcePath) ?? new Set();\n requestIds.add(normalizedRequestId);\n // Angular component styles are served through both a direct CSS request\n // (`?direct&ngcomp=...`) and a JS wrapper request (`?ngcomp=...`). The\n // browser can already have the wrapper loaded even when Vite's live module\n // graph only surfaces the direct request during a CSS-only edit. Track the\n // derived wrapper id eagerly so HMR can reason about the browser-visible\n // stylesheet identity without waiting for that wrapper request to be\n // observed later in the session.\n if (normalizedRequestId.includes('?direct&ngcomp=')) {\n requestIds.add(\n normalizedRequestId.replace('?direct&ngcomp=', '?ngcomp='),\n );\n }\n this.sourceToRequestIds.set(sourcePath, requestIds);\n }\n\n registerServedStylesheet(\n record: AnalogStylesheetRecord,\n aliases: string[] = [],\n ): void {\n const publicId = this.normalizeRequestId(record.publicId);\n this.servedById.set(publicId, { ...record, publicId });\n this.servedAliasToId.set(publicId, publicId);\n\n for (const alias of aliases) {\n this.servedAliasToId.set(this.normalizeRequestId(alias), publicId);\n }\n\n if (record.sourcePath) {\n const publicIds =\n this.sourceToPublicIds.get(record.sourcePath) ?? new Set();\n publicIds.add(publicId);\n this.sourceToPublicIds.set(record.sourcePath, publicIds);\n this.recomputeSourceMetadata(record.sourcePath);\n }\n }\n\n private recomputeSourceMetadata(sourcePath: string): void {\n const dependencies = new Map<string, StylesheetDependency>();\n const diagnostics = new Map<string, StylesheetDiagnostic>();\n const tags = new Set<string>();\n\n for (const publicId of this.sourceToPublicIds.get(sourcePath) ?? []) {\n const record = this.servedById.get(publicId);\n if (!record) {\n continue;\n }\n\n for (const dependency of record.dependencies ?? []) {\n const key = `${dependency.kind ?? 'unknown'}:${dependency.id}:${dependency.owner ?? ''}`;\n dependencies.set(key, dependency);\n }\n\n for (const diagnostic of record.diagnostics ?? []) {\n const key = `${diagnostic.severity}:${diagnostic.code}:${diagnostic.message}`;\n diagnostics.set(key, diagnostic);\n }\n\n for (const tag of record.tags ?? []) {\n tags.add(tag);\n }\n }\n\n this.sourceToDependencies.set(sourcePath, [...dependencies.values()]);\n this.sourceToDiagnostics.set(sourcePath, [...diagnostics.values()]);\n this.sourceToTags.set(sourcePath, [...tags]);\n }\n\n private resolveServedRecord(\n requestId: string,\n ): AnalogStylesheetRecord | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const publicId =\n this.servedAliasToId.get(normalizedRequestId) ??\n this.servedAliasToId.get(normalizedRequestId.split('?')[0]) ??\n normalizedRequestId.split('?')[0];\n return this.servedById.get(publicId);\n }\n}\n\nexport function preprocessStylesheet(\n code: string,\n filename: string,\n stylePreprocessor?: StylePreprocessor,\n context?: StylesheetTransformContext,\n): string {\n return preprocessStylesheetResult(code, filename, stylePreprocessor, context)\n .code;\n}\n\nexport function preprocessStylesheetResult(\n code: string,\n filename: string,\n stylePreprocessor?: StylePreprocessor,\n context?: StylesheetTransformContext,\n): StylesheetTransformResult {\n return normalizeTransformResult(\n stylePreprocessor?.(code, filename, context),\n code,\n );\n}\n\nexport function rewriteRelativeCssImports(\n code: string,\n filename: string,\n): string {\n const cssDir = dirname(filename);\n return code.replace(\n /@import\\s+(?:url\\(\\s*([\"']?)(\\.[^'\")\\s;]+)\\1\\s*\\)|([\"'])(\\.[^'\"]+)\\3)/g,\n (_match, urlQuote, urlPath, stringQuote, stringPath) => {\n const relPath = urlPath ?? stringPath;\n const absPath = resolve(cssDir, relPath);\n\n if (typeof urlPath === 'string') {\n return `@import url(${urlQuote}${absPath}${urlQuote})`;\n }\n\n return `@import ${stringQuote}${absPath}${stringQuote}`;\n },\n );\n}\n\nexport function registerStylesheetContent(\n registry: AnalogStylesheetRegistry,\n {\n code,\n dependencies,\n diagnostics,\n tags,\n containingFile,\n className,\n order,\n inlineStylesExtension,\n resourceFile,\n }: {\n code: string;\n dependencies?: StylesheetDependency[];\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n containingFile: string;\n className?: string;\n order?: number;\n inlineStylesExtension: string;\n resourceFile?: string;\n },\n): string {\n const id = createHash('sha256')\n .update(containingFile)\n .update(className ?? '')\n .update(String(order ?? 0))\n .update(code)\n .digest('hex');\n const stylesheetId = `${id}.${inlineStylesExtension}`;\n const sourcePath =\n resourceFile ?? containingFile.replace('.ts', `.${inlineStylesExtension}`);\n const normalizedSourcePath = normalizePath(normalize(sourcePath));\n\n // Avoid basename-only aliases here: shared filenames like `index.css`\n // can collide across components and break HMR lookups.\n const aliases = [\n sourcePath,\n normalizedSourcePath,\n sourcePath.replace(/^\\//, ''),\n normalizedSourcePath.replace(/^\\//, ''),\n ];\n\n registry.registerServedStylesheet(\n {\n publicId: stylesheetId,\n sourcePath: normalizedSourcePath,\n normalizedCode: code,\n dependencies,\n diagnostics,\n tags,\n },\n aliases,\n );\n\n return stylesheetId;\n}\n"],"mappings":";;;;;AAsBA,IAAa,2BAAb,MAAsC;CACpC,6BAAqB,IAAI,KAAqC;CAC9D,kCAA0B,IAAI,KAAqB;CACnD,0CAAkC,IAAI,KAAqB;;;;;;CAM3D,oCAA4B,IAAI,KAA0B;;;;;;;;CAQ1D,qCAA6B,IAAI,KAA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AAgB,0BACd,MACA,UACQ;CACR,MAAM,SAAS,QAAQ,SAAS;AAChC,QAAO,KAAK,QACV,2EACC,QAAQ,UAAU,SAAS,aAAa,eAAe;EAEtD,MAAM,UAAU,QAAQ,QADR,WAAW,WACa;AAExC,MAAI,OAAO,YAAY,SACrB,QAAO,eAAe,WAAW,UAAU,SAAS;AAGtD,SAAO,WAAW,cAAc,UAAU;GAE7C;;AAGH,SAAgB,0BACd,UACA,EACE,MACA,cACA,aACA,MACA,gBACA,WACA,OACA,uBACA,gBAYM;CAOR,MAAM,eAAe,GANV,WAAW,SAAS,CAC5B,OAAO,eAAe,CACtB,OAAO,aAAa,GAAG,CACvB,OAAO,OAAO,SAAS,EAAE,CAAC,CAC1B,OAAO,KAAK,CACZ,OAAO,MAAM,CACW,GAAG;CAC9B,MAAM,aACJ,gBAAgB,eAAe,QAAQ,OAAO,IAAI,wBAAwB;CAC5E,MAAM,uBAAuB,cAAc,UAAU,WAAW,CAAC;CAIjE,MAAM,UAAU;EACd;EACA;EACA,WAAW,QAAQ,OAAO,GAAG;EAC7B,qBAAqB,QAAQ,OAAO,GAAG;EACxC;AAED,UAAS,yBACP;EACE,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB;EACA;EACA;EACD,EACD,QACD;AAED,QAAO"}
@@ -1,5 +1,3 @@
1
1
  {
2
- "name": "@analogjs/vite-plugin-angular-tools",
3
- "version": "0.0.1",
4
- "main": "src/index.js"
2
+ "type": "commonjs"
5
3
  }
@@ -1,4 +1,4 @@
1
- import { createBuilder, targetFromTargetString } from "@angular-devkit/architect";
1
+ let _angular_devkit_architect = require("@angular-devkit/architect");
2
2
  //#region packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts
3
3
  async function viteBuilder(options, context) {
4
4
  const { createBuilder } = await Function("return import(\"vite\")")();
@@ -6,14 +6,16 @@ async function viteBuilder(options, context) {
6
6
  const projectConfig = await context.getProjectMetadata(context.target);
7
7
  const projectName = context.target.project;
8
8
  const configuration = context.target.configuration || "production";
9
- const buildTarget = targetFromTargetString(`::${configuration}`, projectName, "build");
9
+ const buildTarget = (0, _angular_devkit_architect.targetFromTargetString)(`::${configuration}`, projectName, "build");
10
10
  const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
11
11
  const rawBuildOptions = await context.getTargetOptions(buildTarget);
12
12
  const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
13
+ const mode = buildOptions.mode ?? configuration;
14
+ if (process.env.NODE_ENV && process.env.NODE_ENV !== mode) context.logger.warn(`NODE_ENV is set to "${process.env.NODE_ENV}" but is ignored because the build resolved mode "${mode}" from the build options and configuration.`);
13
15
  const buildConfig = {
14
16
  configFile: options.configFile,
15
17
  root: projectConfig.root,
16
- mode: process.env.NODE_ENV ?? buildOptions.mode ?? configuration,
18
+ mode,
17
19
  build: {
18
20
  outDir: options.outputPath,
19
21
  sourcemap: !!buildOptions.sourcemap
@@ -27,8 +29,8 @@ async function viteBuilder(options, context) {
27
29
  return { success: false };
28
30
  }
29
31
  }
30
- var vite_build_impl_default = createBuilder(viteBuilder);
32
+ var vite_build_impl_default = (0, _angular_devkit_architect.createBuilder)(viteBuilder);
31
33
  //#endregion
32
- export { vite_build_impl_default as default };
34
+ module.exports = vite_build_impl_default;
33
35
 
34
36
  //# sourceMappingURL=vite-build.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-build.impl.js","names":[],"sources":["../../../../../../../../../packages/vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteBuildSchema } from './schema';\n\nasync function viteBuilder(\n options: ViteBuildSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createBuilder } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const configuration = context.target.configuration || 'production';\n const buildTargetSpecifier = `::${configuration}`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const buildConfig: InlineConfig = {\n configFile: options.configFile,\n root: projectConfig.root as string,\n mode: (process.env.NODE_ENV ??\n buildOptions.mode ??\n configuration) as string,\n build: {\n outDir: options.outputPath,\n sourcemap: !!buildOptions.sourcemap,\n },\n };\n\n try {\n const builder = await createBuilder(buildConfig, false);\n await builder.buildApp();\n\n return {\n success: true,\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n };\n }\n}\n\nexport default createBuilder(viteBuilder) as any;\n"],"mappings":";;AASA,eAAe,YACb,SACA,SACwB;CACxB,MAAM,EAAE,kBAAkB,MAAM,SAAS,0BAAwB,EAAE;AACnE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CACnC,MAAM,gBAAgB,QAAQ,OAAO,iBAAiB;CAEtD,MAAM,cAAc,uBADS,KAAK,iBAGhC,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAED,MAAM,cAA4B;EAChC,YAAY,QAAQ;EACpB,MAAM,cAAc;EACpB,MAAA,QAAA,IAAA,YACE,aAAa,QACb;EACF,OAAO;GACL,QAAQ,QAAQ;GAChB,WAAW,CAAC,CAAC,aAAa;GAC3B;EACF;AAED,KAAI;AAEF,SADgB,MAAM,cAAc,aAAa,MAAM,EACzC,UAAU;AAExB,SAAO,EACL,SAAS,MACV;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO,EACL,SAAS,OACV;;;AAIL,IAAA,0BAAe,cAAc,YAAY"}
1
+ {"version":3,"file":"vite-build.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite/vite-build.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteBuildSchema } from './schema';\n\nasync function viteBuilder(\n options: ViteBuildSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createBuilder } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const configuration = context.target.configuration || 'production';\n const buildTargetSpecifier = `::${configuration}`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n // Explicit build options and the requested configuration win over an\n // ambient NODE_ENV, so `build:production` cannot silently produce a\n // development build when NODE_ENV happens to be set. See #2458.\n const mode = (buildOptions.mode ?? configuration) as string;\n\n if (process.env.NODE_ENV && process.env.NODE_ENV !== mode) {\n context.logger.warn(\n `NODE_ENV is set to \"${process.env.NODE_ENV}\" but is ignored because the build resolved mode \"${mode}\" from the build options and configuration.`,\n );\n }\n\n const buildConfig: InlineConfig = {\n configFile: options.configFile,\n root: projectConfig.root as string,\n mode,\n build: {\n outDir: options.outputPath,\n sourcemap: !!buildOptions.sourcemap,\n },\n };\n\n try {\n const builder = await createBuilder(buildConfig, false);\n await builder.buildApp();\n\n return {\n success: true,\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n };\n }\n}\n\nexport default createBuilder(viteBuilder) as any;\n"],"mappings":";;AASA,eAAe,YACb,SACA,SACwB;CACxB,MAAM,EAAE,kBAAkB,MAAM,SAAS,0BAAwB,EAAE;AACnE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CACnC,MAAM,gBAAgB,QAAQ,OAAO,iBAAiB;CAEtD,MAAM,eAAA,GAAA,0BAAA,wBADuB,KAAK,iBAGhC,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAKD,MAAM,OAAQ,aAAa,QAAQ;AAEnC,KAAA,QAAA,IAAA,YAAA,QAAA,IAAA,aAAqD,KACnD,SAAQ,OAAO,KACb,uBAAA,QAAA,IAAA,SAA4C,oDAAoD,KAAK,6CACtG;CAGH,MAAM,cAA4B;EAChC,YAAY,QAAQ;EACpB,MAAM,cAAc;EACpB;EACA,OAAO;GACL,QAAQ,QAAQ;GAChB,WAAW,CAAC,CAAC,aAAa;GAC3B;EACF;AAED,KAAI;AAEF,SADgB,MAAM,cAAc,aAAa,MAAM,EACzC,UAAU;AAExB,SAAO,EACL,SAAS,MACV;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO,EACL,SAAS,OACV;;;AAIL,IAAA,2BAAA,GAAA,0BAAA,eAA6B,YAAY"}
@@ -1,18 +1,18 @@
1
- import { createBuilder, targetFromTargetString } from "@angular-devkit/architect";
1
+ let _angular_devkit_architect = require("@angular-devkit/architect");
2
2
  //#region packages/vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts
3
3
  async function viteDevServerBuilder(options, context) {
4
4
  const { createServer } = await Function("return import(\"vite\")")();
5
5
  if (!context.target) throw new Error("Builder must be executed with a target");
6
6
  const projectConfig = await context.getProjectMetadata(context.target);
7
7
  const projectName = context.target.project;
8
- const buildTarget = targetFromTargetString(options.buildTarget ?? `::development`, projectName, "build");
8
+ const buildTarget = (0, _angular_devkit_architect.targetFromTargetString)(options.buildTarget ?? `::development`, projectName, "build");
9
9
  const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
10
10
  const rawBuildOptions = await context.getTargetOptions(buildTarget);
11
11
  const buildOptions = await context.validateOptions(rawBuildOptions, browserBuilderName);
12
12
  const serverConfig = {
13
13
  configFile: buildOptions.configFile,
14
14
  root: projectConfig.root,
15
- mode: process.env.NODE_ENV ?? buildOptions.mode ?? "development",
15
+ mode: buildOptions.mode ?? process.env.NODE_ENV ?? "development",
16
16
  build: { sourcemap: !!buildOptions.sourcemap },
17
17
  server: {
18
18
  hmr: options?.hmr,
@@ -21,12 +21,19 @@ async function viteDevServerBuilder(options, context) {
21
21
  };
22
22
  try {
23
23
  const server = await createServer(serverConfig);
24
- await runViteDevServer(server);
24
+ await server.listen();
25
+ server.printUrls();
25
26
  const resolvedUrls = [...server.resolvedUrls.local, ...server.resolvedUrls.network];
27
+ const processOnExit = async () => {
28
+ await server.close();
29
+ };
26
30
  await new Promise((resolve) => {
27
- process.once("SIGINT", () => resolve());
28
- process.once("SIGTERM", () => resolve());
29
- process.once("exit", () => resolve());
31
+ const shutdown = () => {
32
+ processOnExit().then(() => resolve(), () => resolve());
33
+ };
34
+ process.once("SIGINT", shutdown);
35
+ process.once("SIGTERM", shutdown);
36
+ process.once("exit", shutdown);
30
37
  });
31
38
  return {
32
39
  success: true,
@@ -40,18 +47,8 @@ async function viteDevServerBuilder(options, context) {
40
47
  };
41
48
  }
42
49
  }
43
- async function runViteDevServer(server) {
44
- await server.listen();
45
- server.printUrls();
46
- const processOnExit = async () => {
47
- await server.close();
48
- };
49
- process.once("SIGINT", processOnExit);
50
- process.once("SIGTERM", processOnExit);
51
- process.once("exit", processOnExit);
52
- }
53
- var dev_server_impl_default = createBuilder(viteDevServerBuilder);
50
+ var dev_server_impl_default = (0, _angular_devkit_architect.createBuilder)(viteDevServerBuilder);
54
51
  //#endregion
55
- export { dev_server_impl_default as default };
52
+ module.exports = dev_server_impl_default;
56
53
 
57
54
  //# sourceMappingURL=dev-server.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev-server.impl.js","names":[],"sources":["../../../../../../../../../packages/vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteDevServerSchema } from './schema';\n\nasync function viteDevServerBuilder(\n options: ViteDevServerSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createServer } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const buildTargetSpecifier = options.buildTarget ?? `::development`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const serverConfig: InlineConfig = {\n configFile: buildOptions.configFile as string,\n root: projectConfig.root as string,\n mode: (process.env.NODE_ENV ??\n buildOptions.mode ??\n 'development') as string,\n build: {\n sourcemap: !!buildOptions.sourcemap,\n },\n server: {\n hmr: options?.hmr,\n port: options?.port,\n },\n };\n\n try {\n const server = await createServer(serverConfig);\n await runViteDevServer(server);\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n\n return {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n baseUrl: '',\n };\n }\n}\n\n// vite ViteDevServer\nasync function runViteDevServer(server: Record<string, any>): Promise<void> {\n await server.listen();\n\n server.printUrls();\n\n const processOnExit = async () => {\n await server.close();\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n}\n\nexport default createBuilder(viteDevServerBuilder) as any;\n"],"mappings":";;AASA,eAAe,qBACb,SACA,SACwB;CACxB,MAAM,EAAE,iBAAiB,MAAM,SAAS,0BAAwB,EAAE;AAClE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CAEnC,MAAM,cAAc,uBADS,QAAQ,eAAe,iBAGlD,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAED,MAAM,eAA6B;EACjC,YAAY,aAAa;EACzB,MAAM,cAAc;EACpB,MAAA,QAAA,IAAA,YACE,aAAa,QACb;EACF,OAAO,EACL,WAAW,CAAC,CAAC,aAAa,WAC3B;EACD,QAAQ;GACN,KAAK,SAAS;GACd,MAAM,SAAS;GAChB;EACF;AAED,KAAI;EACF,MAAM,SAAS,MAAM,aAAa,aAAa;AAC/C,QAAM,iBAAiB,OAAO;EAC9B,MAAM,eAAe,CACnB,GAAG,OAAO,aAAa,OACvB,GAAG,OAAO,aAAa,QACxB;AAED,QAAM,IAAI,SAAe,YAAY;AACnC,WAAQ,KAAK,gBAAgB,SAAS,CAAC;AACvC,WAAQ,KAAK,iBAAiB,SAAS,CAAC;AACxC,WAAQ,KAAK,cAAc,SAAS,CAAC;IACrC;AAEF,SAAO;GACL,SAAS;GACT,SAAS,aAAa,MAAM;GAC7B;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO;GACL,SAAS;GACT,SAAS;GACV;;;AAKL,eAAe,iBAAiB,QAA4C;AAC1E,OAAM,OAAO,QAAQ;AAErB,QAAO,WAAW;CAElB,MAAM,gBAAgB,YAAY;AAChC,QAAM,OAAO,OAAO;;AAGtB,SAAQ,KAAK,UAAU,cAAc;AACrC,SAAQ,KAAK,WAAW,cAAc;AACtC,SAAQ,KAAK,QAAQ,cAAc;;AAGrC,IAAA,0BAAe,cAAc,qBAAqB"}
1
+ {"version":3,"file":"dev-server.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteDevServerSchema } from './schema';\n\nasync function viteDevServerBuilder(\n options: ViteDevServerSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createServer } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const buildTargetSpecifier = options.buildTarget ?? `::development`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const serverConfig: InlineConfig = {\n configFile: buildOptions.configFile as string,\n root: projectConfig.root as string,\n // An explicit mode from the build options wins over an ambient NODE_ENV.\n // See #2458.\n mode: (buildOptions.mode ??\n process.env.NODE_ENV ??\n 'development') as string,\n build: {\n sourcemap: !!buildOptions.sourcemap,\n },\n server: {\n hmr: options?.hmr,\n port: options?.port,\n },\n };\n\n try {\n const server = await createServer(serverConfig);\n await server.listen();\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n const processOnExit = async () => {\n await server.close();\n };\n\n // Use process.once to avoid listener accumulation when Nx invokes\n // multiple builders in the same process during a large build graph.\n await new Promise<void>((resolve) => {\n const shutdown = () => {\n processOnExit().then(\n () => resolve(),\n () => resolve(),\n );\n };\n process.once('SIGINT', shutdown);\n process.once('SIGTERM', shutdown);\n process.once('exit', shutdown);\n });\n\n return {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n baseUrl: '',\n };\n }\n}\n\nexport default createBuilder(viteDevServerBuilder) as any;\n"],"mappings":";;AASA,eAAe,qBACb,SACA,SACwB;CACxB,MAAM,EAAE,iBAAiB,MAAM,SAAS,0BAAwB,EAAE;AAClE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CAEnC,MAAM,eAAA,GAAA,0BAAA,wBADuB,QAAQ,eAAe,iBAGlD,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAED,MAAM,eAA6B;EACjC,YAAY,aAAa;EACzB,MAAM,cAAc;EAGpB,MAAO,aAAa,QAAA,QAAA,IAAA,YAElB;EACF,OAAO,EACL,WAAW,CAAC,CAAC,aAAa,WAC3B;EACD,QAAQ;GACN,KAAK,SAAS;GACd,MAAM,SAAS;GAChB;EACF;AAED,KAAI;EACF,MAAM,SAAS,MAAM,aAAa,aAAa;AAC/C,QAAM,OAAO,QAAQ;AACrB,SAAO,WAAW;EAElB,MAAM,eAAe,CACnB,GAAG,OAAO,aAAa,OACvB,GAAG,OAAO,aAAa,QACxB;EAED,MAAM,gBAAgB,YAAY;AAChC,SAAM,OAAO,OAAO;;AAKtB,QAAM,IAAI,SAAe,YAAY;GACnC,MAAM,iBAAiB;AACrB,mBAAe,CAAC,WACR,SAAS,QACT,SAAS,CAChB;;AAEH,WAAQ,KAAK,UAAU,SAAS;AAChC,WAAQ,KAAK,WAAW,SAAS;AACjC,WAAQ,KAAK,QAAQ,SAAS;IAC9B;AAEF,SAAO;GACL,SAAS;GACT,SAAS,aAAa,MAAM;GAC7B;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO;GACL,SAAS;GACT,SAAS;GACV;;;AAIL,IAAA,2BAAA,GAAA,0BAAA,eAA6B,qBAAqB"}
@@ -0,0 +1,62 @@
1
+ import { AnalogStylesheetRegistry } from "../stylesheet-registry.js";
2
+ import type { StylePreprocessor } from "../style-preprocessor.js";
3
+ import type { FileReplacement } from "../plugins/file-replacements.plugin.js";
4
+ export declare enum DiagnosticModes {
5
+ None = 0,
6
+ Option = 1,
7
+ Syntactic = 2,
8
+ Semantic = 4,
9
+ All = 7
10
+ }
11
+ export declare function injectViteIgnoreForHmrMetadata(code: string): string;
12
+ export declare function isIgnoredHmrFile(file: string): boolean;
13
+ /**
14
+ * Convert Analog/Angular CLI-style file replacements into the flat record
15
+ * expected by `AngularHostOptions.fileReplacements`.
16
+ *
17
+ * Only browser replacements (`{ replace, with }`) are converted. SSR-only
18
+ * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to
19
+ * handle — they should not be baked into the Angular compilation host because
20
+ * that would apply them to both browser and server builds.
21
+ *
22
+ * Relative paths are resolved against `workspaceRoot` so that the host
23
+ * receives the same absolute paths it would get from the Angular CLI.
24
+ */
25
+ export declare function toAngularCompilationFileReplacements(replacements: FileReplacement[], workspaceRoot: string): Record<string, string> | undefined;
26
+ /**
27
+ * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)
28
+ * back to absolute file paths with their associated HMR code and component
29
+ * class name.
30
+ *
31
+ * Angular's private Compilation API emits template update keys in the form
32
+ * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve
33
+ * them so the caller can look up updates by the same normalized absolute path
34
+ * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
35
+ */
36
+ export declare function mapTemplateUpdatesToFiles(templateUpdates: ReadonlyMap<string, string> | undefined): Map<string, {
37
+ className: string;
38
+ code: string;
39
+ }>;
40
+ export declare function describeStylesheetContent(code: string): {
41
+ length: number;
42
+ digest: string;
43
+ preview: string;
44
+ };
45
+ /**
46
+ * Refreshes any already-served stylesheet records that map back to a changed
47
+ * source file.
48
+ *
49
+ * This is the critical bridge for externalized Angular component styles during
50
+ * HMR. Angular's resource watcher can notice that `/src/...component.css`
51
+ * changed before Angular recompilation has had a chance to repopulate the
52
+ * stylesheet registry. If we emit a CSS update against the existing virtual
53
+ * stylesheet id without first refreshing the registry content, the browser gets
54
+ * a hot update containing stale CSS. By rewriting the existing served records
55
+ * from disk up front, HMR always pushes the latest source content.
56
+ */
57
+ export declare function refreshStylesheetRegistryForFile(file: string, stylesheetRegistry?: AnalogStylesheetRegistry, stylePreprocessor?: StylePreprocessor): void;
58
+ /**
59
+ * Checks for vitest run from the command line
60
+ * @returns boolean
61
+ */
62
+ export declare function isTestWatchMode(args?): boolean;
@@ -0,0 +1,138 @@
1
+ import { debugStylesV } from "./debug.js";
2
+ import { normalizeStylesheetDependencies } from "../style-preprocessor.js";
3
+ import { preprocessStylesheetResult, rewriteRelativeCssImports } from "../stylesheet-registry.js";
4
+ import { createHash } from "node:crypto";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { basename, isAbsolute, resolve } from "node:path";
7
+ import { normalizePath } from "vite";
8
+ //#region packages/vite-plugin-angular/src/lib/utils/compilation-shared.ts
9
+ /**
10
+ * Shared utilities used by both angular-vite-plugin.ts and
11
+ * compilation-api/compilation-api-plugin.ts.
12
+ */
13
+ var DiagnosticModes = /* @__PURE__ */ function(DiagnosticModes) {
14
+ DiagnosticModes[DiagnosticModes["None"] = 0] = "None";
15
+ DiagnosticModes[DiagnosticModes["Option"] = 1] = "Option";
16
+ DiagnosticModes[DiagnosticModes["Syntactic"] = 2] = "Syntactic";
17
+ DiagnosticModes[DiagnosticModes["Semantic"] = 4] = "Semantic";
18
+ DiagnosticModes[DiagnosticModes["All"] = 7] = "All";
19
+ return DiagnosticModes;
20
+ }({});
21
+ function injectViteIgnoreForHmrMetadata(code) {
22
+ let patched = code.replace(/\bimport\(([a-zA-Z_$][\w$]*\.\u0275\u0275getReplaceMetadataURL)/g, "import(/* @vite-ignore */ $1");
23
+ if (patched === code) patched = patched.replace(/import\((\S+getReplaceMetadataURL)/g, "import(/* @vite-ignore */ $1");
24
+ return patched;
25
+ }
26
+ function isIgnoredHmrFile(file) {
27
+ return file.endsWith(".tsbuildinfo");
28
+ }
29
+ /**
30
+ * Convert Analog/Angular CLI-style file replacements into the flat record
31
+ * expected by `AngularHostOptions.fileReplacements`.
32
+ *
33
+ * Only browser replacements (`{ replace, with }`) are converted. SSR-only
34
+ * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to
35
+ * handle — they should not be baked into the Angular compilation host because
36
+ * that would apply them to both browser and server builds.
37
+ *
38
+ * Relative paths are resolved against `workspaceRoot` so that the host
39
+ * receives the same absolute paths it would get from the Angular CLI.
40
+ */
41
+ function toAngularCompilationFileReplacements(replacements, workspaceRoot) {
42
+ const mappedReplacements = replacements.flatMap((replacement) => {
43
+ if (!("with" in replacement)) return [];
44
+ return [[isAbsolute(replacement.replace) ? replacement.replace : resolve(workspaceRoot, replacement.replace), isAbsolute(replacement.with) ? replacement.with : resolve(workspaceRoot, replacement.with)]];
45
+ });
46
+ return mappedReplacements.length ? Object.fromEntries(mappedReplacements) : void 0;
47
+ }
48
+ /**
49
+ * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)
50
+ * back to absolute file paths with their associated HMR code and component
51
+ * class name.
52
+ *
53
+ * Angular's private Compilation API emits template update keys in the form
54
+ * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve
55
+ * them so the caller can look up updates by the same normalized absolute path
56
+ * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).
57
+ */
58
+ function mapTemplateUpdatesToFiles(templateUpdates) {
59
+ const updatesByFile = /* @__PURE__ */ new Map();
60
+ templateUpdates?.forEach((code, encodedUpdateId) => {
61
+ const [file, className = ""] = decodeURIComponent(encodedUpdateId).split("@");
62
+ const resolvedFile = normalizePath(resolve(process.cwd(), file));
63
+ updatesByFile.set(resolvedFile, {
64
+ className,
65
+ code
66
+ });
67
+ });
68
+ return updatesByFile;
69
+ }
70
+ function describeStylesheetContent(code) {
71
+ return {
72
+ length: code.length,
73
+ digest: createHash("sha256").update(code).digest("hex").slice(0, 12),
74
+ preview: code.replace(/\s+/g, " ").trim().slice(0, 160)
75
+ };
76
+ }
77
+ /**
78
+ * Refreshes any already-served stylesheet records that map back to a changed
79
+ * source file.
80
+ *
81
+ * This is the critical bridge for externalized Angular component styles during
82
+ * HMR. Angular's resource watcher can notice that `/src/...component.css`
83
+ * changed before Angular recompilation has had a chance to repopulate the
84
+ * stylesheet registry. If we emit a CSS update against the existing virtual
85
+ * stylesheet id without first refreshing the registry content, the browser gets
86
+ * a hot update containing stale CSS. By rewriting the existing served records
87
+ * from disk up front, HMR always pushes the latest source content.
88
+ */
89
+ function refreshStylesheetRegistryForFile(file, stylesheetRegistry, stylePreprocessor) {
90
+ const normalizedFile = normalizePath(file.split("?")[0]);
91
+ if (!stylesheetRegistry || !existsSync(normalizedFile)) return;
92
+ const publicIds = stylesheetRegistry.getPublicIdsForSource(normalizedFile);
93
+ if (publicIds.length === 0) return;
94
+ const rawCss = readFileSync(normalizedFile, "utf-8");
95
+ const preprocessed = preprocessStylesheetResult(rawCss, normalizedFile, stylePreprocessor);
96
+ const servedCss = rewriteRelativeCssImports(preprocessed.code, normalizedFile);
97
+ for (const publicId of publicIds) stylesheetRegistry.registerServedStylesheet({
98
+ publicId,
99
+ sourcePath: normalizedFile,
100
+ originalCode: rawCss,
101
+ normalizedCode: servedCss,
102
+ dependencies: normalizeStylesheetDependencies(preprocessed.dependencies),
103
+ diagnostics: preprocessed.diagnostics,
104
+ tags: preprocessed.tags
105
+ }, [
106
+ normalizedFile,
107
+ normalizePath(normalizedFile),
108
+ basename(normalizedFile),
109
+ normalizedFile.replace(/^\//, "")
110
+ ]);
111
+ debugStylesV("stylesheet registry refreshed from source file", {
112
+ file: normalizedFile,
113
+ publicIds,
114
+ dependencies: preprocessed.dependencies,
115
+ diagnostics: preprocessed.diagnostics,
116
+ tags: preprocessed.tags,
117
+ source: describeStylesheetContent(rawCss),
118
+ served: describeStylesheetContent(servedCss)
119
+ });
120
+ }
121
+ /**
122
+ * Checks for vitest run from the command line
123
+ * @returns boolean
124
+ */
125
+ function isTestWatchMode(args = process.argv) {
126
+ if (args.find((arg) => arg.includes("--run"))) return false;
127
+ if (args.includes("run")) return false;
128
+ if (args.find((arg) => arg.includes("--no-run"))) return true;
129
+ const hasWatch = args.find((arg) => arg.includes("watch"));
130
+ if (hasWatch && ["false", "no"].some((neg) => hasWatch.includes(neg))) return false;
131
+ const watchArg = args[args.findIndex((arg) => arg.includes("watch")) + 1];
132
+ if (watchArg && watchArg === "false") return false;
133
+ return true;
134
+ }
135
+ //#endregion
136
+ export { DiagnosticModes, describeStylesheetContent, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, toAngularCompilationFileReplacements };
137
+
138
+ //# sourceMappingURL=compilation-shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compilation-shared.js","names":[],"sources":["../../../../src/lib/utils/compilation-shared.ts"],"sourcesContent":["/**\n * Shared utilities used by both angular-vite-plugin.ts and\n * compilation-api/compilation-api-plugin.ts.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { basename, isAbsolute, resolve } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { normalizePath } from 'vite';\n\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport type { FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport { debugStylesV } from './debug.js';\n\nexport enum DiagnosticModes {\n None = 0,\n Option = 1 << 0,\n Syntactic = 1 << 1,\n Semantic = 1 << 2,\n All = Option | Syntactic | Semantic,\n}\n\nexport function injectViteIgnoreForHmrMetadata(code: string): string {\n let patched = code.replace(\n /\\bimport\\(([a-zA-Z_$][\\w$]*\\.\\u0275\\u0275getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n\n if (patched === code) {\n patched = patched.replace(\n /import\\((\\S+getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n }\n\n return patched;\n}\n\nexport function isIgnoredHmrFile(file: string): boolean {\n return file.endsWith('.tsbuildinfo');\n}\n\n/**\n * Convert Analog/Angular CLI-style file replacements into the flat record\n * expected by `AngularHostOptions.fileReplacements`.\n *\n * Only browser replacements (`{ replace, with }`) are converted. SSR-only\n * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to\n * handle — they should not be baked into the Angular compilation host because\n * that would apply them to both browser and server builds.\n *\n * Relative paths are resolved against `workspaceRoot` so that the host\n * receives the same absolute paths it would get from the Angular CLI.\n */\nexport function toAngularCompilationFileReplacements(\n replacements: FileReplacement[],\n workspaceRoot: string,\n): Record<string, string> | undefined {\n const mappedReplacements = replacements.flatMap((replacement) => {\n if (!('with' in replacement)) {\n return [];\n }\n\n return [\n [\n isAbsolute(replacement.replace)\n ? replacement.replace\n : resolve(workspaceRoot, replacement.replace),\n isAbsolute(replacement.with)\n ? replacement.with\n : resolve(workspaceRoot, replacement.with),\n ] as const,\n ];\n });\n\n return mappedReplacements.length\n ? Object.fromEntries(mappedReplacements)\n : undefined;\n}\n\n/**\n * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)\n * back to absolute file paths with their associated HMR code and component\n * class name.\n *\n * Angular's private Compilation API emits template update keys in the form\n * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve\n * them so the caller can look up updates by the same normalized absolute path\n * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).\n */\nexport function mapTemplateUpdatesToFiles(\n templateUpdates: ReadonlyMap<string, string> | undefined,\n): Map<\n string,\n {\n className: string;\n code: string;\n }\n> {\n const updatesByFile = new Map<string, { className: string; code: string }>();\n\n templateUpdates?.forEach((code, encodedUpdateId) => {\n const [file, className = ''] =\n decodeURIComponent(encodedUpdateId).split('@');\n const resolvedFile = normalizePath(resolve(process.cwd(), file));\n\n updatesByFile.set(resolvedFile, {\n className,\n code,\n });\n });\n\n return updatesByFile;\n}\n\nexport function describeStylesheetContent(code: string): {\n length: number;\n digest: string;\n preview: string;\n} {\n return {\n length: code.length,\n digest: createHash('sha256').update(code).digest('hex').slice(0, 12),\n preview: code.replace(/\\s+/g, ' ').trim().slice(0, 160),\n };\n}\n\n/**\n * Refreshes any already-served stylesheet records that map back to a changed\n * source file.\n *\n * This is the critical bridge for externalized Angular component styles during\n * HMR. Angular's resource watcher can notice that `/src/...component.css`\n * changed before Angular recompilation has had a chance to repopulate the\n * stylesheet registry. If we emit a CSS update against the existing virtual\n * stylesheet id without first refreshing the registry content, the browser gets\n * a hot update containing stale CSS. By rewriting the existing served records\n * from disk up front, HMR always pushes the latest source content.\n */\nexport function refreshStylesheetRegistryForFile(\n file: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n stylePreprocessor?: StylePreprocessor,\n): void {\n const normalizedFile = normalizePath(file.split('?')[0]);\n if (!stylesheetRegistry || !existsSync(normalizedFile)) {\n return;\n }\n\n const publicIds = stylesheetRegistry.getPublicIdsForSource(normalizedFile);\n if (publicIds.length === 0) {\n return;\n }\n\n const rawCss = readFileSync(normalizedFile, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n normalizedFile,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(\n preprocessed.code,\n normalizedFile,\n );\n\n for (const publicId of publicIds) {\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId,\n sourcePath: normalizedFile,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [\n normalizedFile,\n normalizePath(normalizedFile),\n basename(normalizedFile),\n normalizedFile.replace(/^\\//, ''),\n ],\n );\n }\n\n debugStylesV('stylesheet registry refreshed from source file', {\n file: normalizedFile,\n publicIds,\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n source: describeStylesheetContent(rawCss),\n served: describeStylesheetContent(servedCss),\n });\n}\n\n/**\n * Checks for vitest run from the command line\n * @returns boolean\n */\nexport function isTestWatchMode(args = process.argv): boolean {\n // vitest --run\n const hasRun = args.find((arg) => arg.includes('--run'));\n if (hasRun) {\n return false;\n }\n\n // vitest run\n if (args.includes('run')) {\n return false;\n }\n\n // vitest --no-run\n const hasNoRun = args.find((arg) => arg.includes('--no-run'));\n if (hasNoRun) {\n return true;\n }\n\n // check for --watch=false or --no-watch\n const hasWatch = args.find((arg) => arg.includes('watch'));\n if (hasWatch && ['false', 'no'].some((neg) => hasWatch.includes(neg))) {\n return false;\n }\n\n // check for --watch false\n const watchIndex = args.findIndex((arg) => arg.includes('watch'));\n const watchArg = args[watchIndex + 1];\n if (watchArg && watchArg === 'false') {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAY,kBAAL,yBAAA,iBAAA;AACL,iBAAA,gBAAA,UAAA,KAAA;AACA,iBAAA,gBAAA,YAAA,KAAA;AACA,iBAAA,gBAAA,eAAA,KAAA;AACA,iBAAA,gBAAA,cAAA,KA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source-file-cache";
2
2
  export interface CompilerPluginOptions {
3
- sourcemap: boolean;
4
- tsconfig: string;
5
- jit?: boolean;
6
- /** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
7
- noopTypeScriptCompilation?: boolean;
8
- advancedOptimizations?: boolean;
9
- thirdPartySourcemaps?: boolean;
10
- fileReplacements?: Record<string, string>;
11
- sourceFileCache?: SourceFileCache;
12
- incremental: boolean;
3
+ sourcemap: boolean;
4
+ tsconfig: string;
5
+ jit?: boolean;
6
+ /** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
7
+ noopTypeScriptCompilation?: boolean;
8
+ advancedOptimizations?: boolean;
9
+ thirdPartySourcemaps?: boolean;
10
+ fileReplacements?: Record<string, string>;
11
+ sourceFileCache?: SourceFileCache;
12
+ incremental: boolean;
13
13
  }
@@ -0,0 +1,32 @@
1
+ import * as vite from "vite";
2
+ /**
3
+ * Resolves bare-specifier `.css` imports with the `style` package-export
4
+ * condition in scope, without leaking `style` into Vite's global
5
+ * `resolve.conditions`.
6
+ *
7
+ * Two real cases pull in opposite directions on this condition:
8
+ *
9
+ * 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:
10
+ * Material's prebuilt theme entries are gated *only* under the `style`
11
+ * condition (no `default`, no `import`), so without `style` in scope
12
+ * the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
13
+ *
14
+ * 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS
15
+ * plugin resolver inherits Vite's global conditions. If `style` is
16
+ * injected globally, that resolver matches the package's `style`
17
+ * export (a `.css` file) and feeds it to Node's ESM loader, which
18
+ * can't load `.css` and throws
19
+ * `Internal server error: Unknown file extension ".css"`.
20
+ *
21
+ * The fix: scope the `style` condition to requests that *look* like CSS
22
+ * assets — bare specifiers ending in `.css` (with optional query suffix
23
+ * for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through
24
+ * to Vite's normal resolver chain, so packages with mixed exports
25
+ * (`tailwindcss-primeui` exposes both `style` and `import`) resolve to
26
+ * their JS surface.
27
+ *
28
+ * Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes
29
+ * `vite.createIdResolver(config, options)`. Their resolver-call signatures
30
+ * differ — this plugin normalizes both.
31
+ */
32
+ export declare function cssExtensionStyleResolverPlugin(): vite.Plugin;
@@ -0,0 +1,73 @@
1
+ import * as vite from "vite";
2
+ //#region packages/vite-plugin-angular/src/lib/utils/css-extension-resolver.ts
3
+ /**
4
+ * Resolves bare-specifier `.css` imports with the `style` package-export
5
+ * condition in scope, without leaking `style` into Vite's global
6
+ * `resolve.conditions`.
7
+ *
8
+ * Two real cases pull in opposite directions on this condition:
9
+ *
10
+ * 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:
11
+ * Material's prebuilt theme entries are gated *only* under the `style`
12
+ * condition (no `default`, no `import`), so without `style` in scope
13
+ * the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
14
+ *
15
+ * 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS
16
+ * plugin resolver inherits Vite's global conditions. If `style` is
17
+ * injected globally, that resolver matches the package's `style`
18
+ * export (a `.css` file) and feeds it to Node's ESM loader, which
19
+ * can't load `.css` and throws
20
+ * `Internal server error: Unknown file extension ".css"`.
21
+ *
22
+ * The fix: scope the `style` condition to requests that *look* like CSS
23
+ * assets — bare specifiers ending in `.css` (with optional query suffix
24
+ * for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through
25
+ * to Vite's normal resolver chain, so packages with mixed exports
26
+ * (`tailwindcss-primeui` exposes both `style` and `import`) resolve to
27
+ * their JS surface.
28
+ *
29
+ * Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes
30
+ * `vite.createIdResolver(config, options)`. Their resolver-call signatures
31
+ * differ — this plugin normalizes both.
32
+ */
33
+ function cssExtensionStyleResolverPlugin() {
34
+ let resolveCss;
35
+ return {
36
+ name: "@analogjs/vite-plugin-angular:css-style-resolver",
37
+ enforce: "pre",
38
+ configResolved(config) {
39
+ const styleResolveOptions = {
40
+ ...config.resolve,
41
+ conditions: [...config.resolve.conditions ?? [], "style"]
42
+ };
43
+ const createIdResolver = vite.createIdResolver;
44
+ if (typeof createIdResolver === "function") {
45
+ const r = createIdResolver(config, styleResolveOptions);
46
+ resolveCss = async (id, importer, environment) => {
47
+ return await r(environment ?? { name: "client" }, id, importer, false);
48
+ };
49
+ return;
50
+ }
51
+ const legacyCreateResolver = config.createResolver;
52
+ if (typeof legacyCreateResolver === "function") {
53
+ const r = legacyCreateResolver(styleResolveOptions);
54
+ resolveCss = async (id, importer) => {
55
+ return await r(id, importer, false, false);
56
+ };
57
+ return;
58
+ }
59
+ throw new Error("[@analogjs/vite-plugin-angular]: neither vite.createIdResolver (Vite 8) nor ResolvedConfig.createResolver (Vite 7) is available. Unsupported Vite version.");
60
+ },
61
+ async resolveId(id, importer) {
62
+ if (!resolveCss) return null;
63
+ if (id.startsWith(".") || id.startsWith("/") || /^[A-Za-z]:\//.test(id) || id.startsWith("\0") || id.startsWith("data:") || id.startsWith("virtual:")) return null;
64
+ if (!/\.css(?:\?|$)/.test(id)) return null;
65
+ const env = this.environment;
66
+ return await resolveCss(id, importer, env) ?? null;
67
+ }
68
+ };
69
+ }
70
+ //#endregion
71
+ export { cssExtensionStyleResolverPlugin };
72
+
73
+ //# sourceMappingURL=css-extension-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-extension-resolver.js","names":[],"sources":["../../../../src/lib/utils/css-extension-resolver.ts"],"sourcesContent":["import * as vite from 'vite';\n\ntype CssResolver = (\n id: string,\n importer: string | undefined,\n environment?: { name: string } | undefined,\n) => Promise<string | undefined>;\n\n/**\n * Resolves bare-specifier `.css` imports with the `style` package-export\n * condition in scope, without leaking `style` into Vite's global\n * `resolve.conditions`.\n *\n * Two real cases pull in opposite directions on this condition:\n *\n * 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:\n * Material's prebuilt theme entries are gated *only* under the `style`\n * condition (no `default`, no `import`), so without `style` in scope\n * the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.\n *\n * 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS\n * plugin resolver inherits Vite's global conditions. If `style` is\n * injected globally, that resolver matches the package's `style`\n * export (a `.css` file) and feeds it to Node's ESM loader, which\n * can't load `.css` and throws\n * `Internal server error: Unknown file extension \".css\"`.\n *\n * The fix: scope the `style` condition to requests that *look* like CSS\n * assets — bare specifiers ending in `.css` (with optional query suffix\n * for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through\n * to Vite's normal resolver chain, so packages with mixed exports\n * (`tailwindcss-primeui` exposes both `style` and `import`) resolve to\n * their JS surface.\n *\n * Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes\n * `vite.createIdResolver(config, options)`. Their resolver-call signatures\n * differ — this plugin normalizes both.\n */\nexport function cssExtensionStyleResolverPlugin(): vite.Plugin {\n let resolveCss: CssResolver | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:css-style-resolver',\n enforce: 'pre',\n\n configResolved(config) {\n const styleResolveOptions = {\n ...config.resolve,\n conditions: [...(config.resolve.conditions ?? []), 'style'],\n };\n\n const createIdResolver = (\n vite as unknown as {\n createIdResolver?: (\n c: vite.ResolvedConfig,\n o: typeof styleResolveOptions,\n ) => (\n environment: { name: string },\n id: string,\n importer: string | undefined,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createIdResolver;\n\n if (typeof createIdResolver === 'function') {\n const r = createIdResolver(config, styleResolveOptions);\n resolveCss = async (id, importer, environment) => {\n return await r(\n environment ?? { name: 'client' },\n id,\n importer,\n false,\n );\n };\n return;\n }\n\n const legacyCreateResolver = (\n config as unknown as {\n createResolver?: (\n o: typeof styleResolveOptions,\n ) => (\n id: string,\n importer: string | undefined,\n aliasOnly: boolean,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createResolver;\n\n if (typeof legacyCreateResolver === 'function') {\n const r = legacyCreateResolver(styleResolveOptions);\n resolveCss = async (id, importer) => {\n return await r(id, importer, false, false);\n };\n return;\n }\n\n // Both APIs have been stable across the supported Vite range\n // (7.x via `ResolvedConfig.createResolver`, 8.x via\n // `vite.createIdResolver`). If neither is present, fail loudly\n // rather than silently regressing CSS imports of `style`-only\n // package exports such as `@angular/material/prebuilt-themes/*`.\n throw new Error(\n '[@analogjs/vite-plugin-angular]: neither vite.createIdResolver ' +\n '(Vite 8) nor ResolvedConfig.createResolver (Vite 7) is available. ' +\n 'Unsupported Vite version.',\n );\n },\n\n async resolveId(id, importer) {\n if (!resolveCss) return null;\n\n // Skip non-bare specifiers — relative, absolute, virtual, and\n // data-URI imports don't consult package exports, so the `style`\n // condition is irrelevant for them.\n if (\n id.startsWith('.') ||\n id.startsWith('/') ||\n /^[A-Za-z]:\\//.test(id) ||\n id.startsWith('\\0') ||\n id.startsWith('data:') ||\n id.startsWith('virtual:')\n ) {\n return null;\n }\n\n // Only fire on `.css` requests (with optional query, e.g. `?inline`,\n // `?module`). Non-CSS bare specifiers go through Vite's normal\n // resolver chain unchanged, which is critical for packages whose\n // exports include both `style` and `import`/`default` — e.g.\n // `tailwindcss-primeui`, where `@plugin` resolution must land on\n // the JS file, not the CSS file.\n if (!/\\.css(?:\\?|$)/.test(id)) return null;\n\n const env = (this as unknown as { environment?: { name: string } })\n .environment;\n const resolved = await resolveCss(id, importer, env);\n return resolved ?? null;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,kCAA+C;CAC7D,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;EAET,eAAe,QAAQ;GACrB,MAAM,sBAAsB;IAC1B,GAAG,OAAO;IACV,YAAY,CAAC,GAAI,OAAO,QAAQ,cAAc,EAAE,EAAG,QAAQ;IAC5D;GAED,MAAM,mBACJ,KAWA;AAEF,OAAI,OAAO,qBAAqB,YAAY;IAC1C,MAAM,IAAI,iBAAiB,QAAQ,oBAAoB;AACvD,iBAAa,OAAO,IAAI,UAAU,gBAAgB;AAChD,YAAO,MAAM,EACX,eAAe,EAAE,MAAM,UAAU,EACjC,IACA,UACA,MACD;;AAEH;;GAGF,MAAM,uBACJ,OAUA;AAEF,OAAI,OAAO,yBAAyB,YAAY;IAC9C,MAAM,IAAI,qBAAqB,oBAAoB;AACnD,iBAAa,OAAO,IAAI,aAAa;AACnC,YAAO,MAAM,EAAE,IAAI,UAAU,OAAO,MAAM;;AAE5C;;AAQF,SAAM,IAAI,MACR,6JAGD;;EAGH,MAAM,UAAU,IAAI,UAAU;AAC5B,OAAI,CAAC,WAAY,QAAO;AAKxB,OACE,GAAG,WAAW,IAAI,IAClB,GAAG,WAAW,IAAI,IAClB,eAAe,KAAK,GAAG,IACvB,GAAG,WAAW,KAAK,IACnB,GAAG,WAAW,QAAQ,IACtB,GAAG,WAAW,WAAW,CAEzB,QAAO;AAST,OAAI,CAAC,gBAAgB,KAAK,GAAG,CAAE,QAAO;GAEtC,MAAM,MAAO,KACV;AAEH,UADiB,MAAM,WAAW,IAAI,UAAU,IAAI,IACjC;;EAEtB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Vite's `preprocessCSS` may spawn a fallback Sass/Less/Stylus compiler
3
+ * (`alwaysFakeWorkerWorkerControllerCache`) that is never closed. Unref those
4
+ * child processes so a one-off `vite build` can return the shell.
5
+ */
6
+ export declare function releaseCssPreprocessorWorkers(): void;
@@ -0,0 +1,29 @@
1
+ //#region packages/vite-plugin-angular/src/lib/utils/css-preprocessor-workers.ts
2
+ var PREPROCESSOR_PROCESS_RE = /sass-embedded|dart-sass|sass\.snapshot|[\\/]lessc(?:$|[\s])|[\\/]stylus(?:$|[\s])/i;
3
+ function getActiveHandles() {
4
+ const getHandles = process._getActiveHandles;
5
+ return typeof getHandles === "function" ? getHandles.call(process) : [];
6
+ }
7
+ function isCssPreprocessorProcess(handle) {
8
+ const haystack = `${handle.spawnfile ?? ""} ${(handle.spawnargs ?? []).join(" ")}`;
9
+ return PREPROCESSOR_PROCESS_RE.test(haystack);
10
+ }
11
+ /**
12
+ * Vite's `preprocessCSS` may spawn a fallback Sass/Less/Stylus compiler
13
+ * (`alwaysFakeWorkerWorkerControllerCache`) that is never closed. Unref those
14
+ * child processes so a one-off `vite build` can return the shell.
15
+ */
16
+ function releaseCssPreprocessorWorkers() {
17
+ for (const handle of getActiveHandles()) {
18
+ if (!isCssPreprocessorProcess(handle)) continue;
19
+ for (const stream of handle.stdio ?? []) stream?.unref?.();
20
+ handle.stdin?.unref?.();
21
+ handle.stdout?.unref?.();
22
+ handle.stderr?.unref?.();
23
+ handle.unref?.();
24
+ }
25
+ }
26
+ //#endregion
27
+ export { releaseCssPreprocessorWorkers };
28
+
29
+ //# sourceMappingURL=css-preprocessor-workers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-preprocessor-workers.js","names":[],"sources":["../../../../src/lib/utils/css-preprocessor-workers.ts"],"sourcesContent":["type ProcessHandle = {\n spawnfile?: string;\n spawnargs?: string[];\n stdin?: { unref?: () => void };\n stdout?: { unref?: () => void };\n stderr?: { unref?: () => void };\n stdio?: Array<{ unref?: () => void } | null | undefined>;\n unref?: () => void;\n};\n\nconst PREPROCESSOR_PROCESS_RE =\n /sass-embedded|dart-sass|sass\\.snapshot|[\\\\/]lessc(?:$|[\\s])|[\\\\/]stylus(?:$|[\\s])/i;\n\nfunction getActiveHandles(): ProcessHandle[] {\n const getHandles = (\n process as NodeJS.Process & { _getActiveHandles?: () => ProcessHandle[] }\n )._getActiveHandles;\n return typeof getHandles === 'function' ? getHandles.call(process) : [];\n}\n\nfunction isCssPreprocessorProcess(handle: ProcessHandle): boolean {\n const haystack = `${handle.spawnfile ?? ''} ${(handle.spawnargs ?? []).join(\n ' ',\n )}`;\n return PREPROCESSOR_PROCESS_RE.test(haystack);\n}\n\n/**\n * Vite's `preprocessCSS` may spawn a fallback Sass/Less/Stylus compiler\n * (`alwaysFakeWorkerWorkerControllerCache`) that is never closed. Unref those\n * child processes so a one-off `vite build` can return the shell.\n */\nexport function releaseCssPreprocessorWorkers(): void {\n for (const handle of getActiveHandles()) {\n if (!isCssPreprocessorProcess(handle)) {\n continue;\n }\n\n for (const stream of handle.stdio ?? []) {\n stream?.unref?.();\n }\n handle.stdin?.unref?.();\n handle.stdout?.unref?.();\n handle.stderr?.unref?.();\n handle.unref?.();\n }\n}\n"],"mappings":";AAUA,IAAM,0BACJ;AAEF,SAAS,mBAAoC;CAC3C,MAAM,aACJ,QACA;AACF,QAAO,OAAO,eAAe,aAAa,WAAW,KAAK,QAAQ,GAAG,EAAE;;AAGzE,SAAS,yBAAyB,QAAgC;CAChE,MAAM,WAAW,GAAG,OAAO,aAAa,GAAG,IAAI,OAAO,aAAa,EAAE,EAAE,KACrE,IACD;AACD,QAAO,wBAAwB,KAAK,SAAS;;;;;;;AAQ/C,SAAgB,gCAAsC;AACpD,MAAK,MAAM,UAAU,kBAAkB,EAAE;AACvC,MAAI,CAAC,yBAAyB,OAAO,CACnC;AAGF,OAAK,MAAM,UAAU,OAAO,SAAS,EAAE,CACrC,SAAQ,SAAS;AAEnB,SAAO,OAAO,SAAS;AACvB,SAAO,QAAQ,SAAS;AACxB,SAAO,QAAQ,SAAS;AACxB,SAAO,SAAS"}