@analogjs/vite-plugin-angular 3.0.0-alpha.52 → 3.0.0-alpha.54
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.
- package/package.json +1 -1
- package/src/lib/angular-vite-plugin.js +34 -7
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +11 -6
- package/src/lib/angular-vitest-plugin.js +14 -8
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.js +10 -1
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/stylesheet-registry.d.ts +1 -0
- package/src/lib/stylesheet-registry.js +13 -7
- package/src/lib/stylesheet-registry.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +2 -2
- package/src/lib/utils/tsconfig-resolver.js.map +1 -1
|
@@ -16,11 +16,16 @@ export declare function angularVitestPlugin(): Plugin;
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function angularVitestEsbuildPlugin(): Plugin;
|
|
18
18
|
/**
|
|
19
|
-
* Post-
|
|
20
|
-
*
|
|
19
|
+
* Post-processing pass that converts any `.ts` files Angular's compilation
|
|
20
|
+
* skipped (e.g. files without Angular decorators when
|
|
21
|
+
* `useAngularCompilationAPI` is on) into runnable JS via esbuild/OXC.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
23
|
+
* Files Angular already compiled have a sourcemap available via
|
|
24
|
+
* `getInMap` — we skip those here to avoid breaking the chain Vite is
|
|
25
|
+
* already wiring up. Re-running OXC over already-compiled JS produces a
|
|
26
|
+
* map relative to the TS-emitted JS, not the original .ts source, and
|
|
27
|
+
* OXC's `inMap` parameter does not chain through the way esbuild's inline
|
|
28
|
+
* `//# sourceMappingURL=` auto-detection does.
|
|
24
29
|
*/
|
|
25
|
-
export declare function angularVitestSourcemapPlugin(): Plugin;
|
|
26
|
-
export declare function angularVitestPlugins(): Plugin[];
|
|
30
|
+
export declare function angularVitestSourcemapPlugin(getInMap?: (id: string) => string | undefined): Plugin;
|
|
31
|
+
export declare function angularVitestPlugins(getInMap?: (id: string) => string | undefined): Plugin[];
|
|
@@ -74,31 +74,37 @@ function angularVitestEsbuildPlugin() {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Post-
|
|
78
|
-
*
|
|
77
|
+
* Post-processing pass that converts any `.ts` files Angular's compilation
|
|
78
|
+
* skipped (e.g. files without Angular decorators when
|
|
79
|
+
* `useAngularCompilationAPI` is on) into runnable JS via esbuild/OXC.
|
|
79
80
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
81
|
+
* Files Angular already compiled have a sourcemap available via
|
|
82
|
+
* `getInMap` — we skip those here to avoid breaking the chain Vite is
|
|
83
|
+
* already wiring up. Re-running OXC over already-compiled JS produces a
|
|
84
|
+
* map relative to the TS-emitted JS, not the original .ts source, and
|
|
85
|
+
* OXC's `inMap` parameter does not chain through the way esbuild's inline
|
|
86
|
+
* `//# sourceMappingURL=` auto-detection does.
|
|
82
87
|
*/
|
|
83
|
-
function angularVitestSourcemapPlugin() {
|
|
88
|
+
function angularVitestSourcemapPlugin(getInMap) {
|
|
84
89
|
return {
|
|
85
90
|
name: "@analogjs/vitest-angular-sourcemap-plugin",
|
|
86
91
|
transform: {
|
|
87
92
|
filter: { id: /\.ts(?:\?|$)/ },
|
|
88
93
|
async handler(code, id) {
|
|
89
|
-
const [, query] = id.split("?");
|
|
94
|
+
const [bareId, query] = id.split("?");
|
|
90
95
|
if (query && query.includes("inline")) return;
|
|
96
|
+
if (getInMap?.(bareId)) return;
|
|
91
97
|
if (isRolldown()) return await vite.transformWithOxc(code, id, { lang: "ts" });
|
|
92
98
|
else return await vite.transformWithEsbuild(code, id, { loader: "ts" });
|
|
93
99
|
}
|
|
94
100
|
}
|
|
95
101
|
};
|
|
96
102
|
}
|
|
97
|
-
function angularVitestPlugins() {
|
|
103
|
+
function angularVitestPlugins(getInMap) {
|
|
98
104
|
return [
|
|
99
105
|
angularVitestPlugin(),
|
|
100
106
|
angularVitestEsbuildPlugin(),
|
|
101
|
-
angularVitestSourcemapPlugin()
|
|
107
|
+
angularVitestSourcemapPlugin(getInMap)
|
|
102
108
|
];
|
|
103
109
|
}
|
|
104
110
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-vitest-plugin.js","names":[],"sources":["../../../src/lib/angular-vitest-plugin.ts"],"sourcesContent":["import type { Plugin, TransformResult, UserConfig } from 'vite';\n// Use the namespace import so these runtime helpers still resolve on Vite 6,\n// which does not expose them as named exports.\nimport * as vite from 'vite';\nimport { getJsTransformConfigKey, isRolldown } from './utils/rolldown.js';\n\nconst vitestAngularSetupEntries = [\n '@analogjs/vitest-angular/setup-testbed',\n '@analogjs/vitest-angular/setup-zone',\n '@analogjs/vitest-angular/setup-snapshots',\n '@analogjs/vitest-angular/setup-serializers',\n];\n\n/**\n * Sets up test config for Vitest and downlevels Angular FESM bundles and\n * `@angular/cdk` from modern async/await to ES2016 so that Zone.js can\n * intercept promises during `fakeAsync` tests.\n *\n * Under Vite 8+ (Rolldown) downleveling is not needed.\n * Under Vite ≤7, esbuild handles the downlevel.\n */\nexport function angularVitestPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esm-plugin',\n apply: 'serve',\n enforce: 'post',\n config(userConfig) {\n return {\n optimizeDeps: {\n include: [\n 'tslib',\n '@angular/core',\n '@angular/core/testing',\n '@angular/platform-browser/testing',\n ],\n },\n ssr: {\n noExternal: [\n ...vitestAngularSetupEntries,\n /fesm2022(.*?)testing/,\n /fesm2015/,\n ],\n },\n test: {\n pool: (userConfig as any).test?.pool ?? 'vmThreads',\n },\n };\n },\n // Filter by module ID so only Angular FESM2022 bundles and CDK enter\n // the handler. The inner guards add a secondary code-content check\n // (`async` keyword) for fesm2022 to avoid needless transforms.\n transform: {\n filter: {\n id: /fesm2022|@angular\\/cdk/,\n },\n async handler(_code, id) {\n if (\n (/fesm2022/.test(id) && _code.includes('async ')) ||\n _code.includes('@angular/cdk')\n ) {\n if (isRolldown()) {\n return undefined;\n }\n\n const { code, map } = await vite.transformWithEsbuild(_code, id, {\n loader: 'js',\n format: 'esm',\n target: 'es2016',\n sourcemap: true,\n sourcefile: id,\n });\n\n return {\n code,\n map,\n };\n }\n\n return undefined;\n },\n },\n };\n}\n\n/**\n * Eagerly disables the built-in JS transformer (esbuild on Vite ≤7, OXC on\n * Vite 8+) so Vitest's internal plugin doesn't race with the Angular\n * compiler. Must run at `enforce: 'pre'` to take effect before Vitest\n * reads the resolved config.\n */\nexport function angularVitestEsbuildPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esbuild-oxc-plugin',\n enforce: 'pre',\n config(userConfig: UserConfig) {\n const jsTransformConfigKey = getJsTransformConfigKey();\n\n return {\n [jsTransformConfigKey]:\n jsTransformConfigKey === 'oxc'\n ? (userConfig.oxc ?? false)\n : (userConfig.esbuild ?? false),\n };\n },\n };\n}\n\n/**\n * Post-
|
|
1
|
+
{"version":3,"file":"angular-vitest-plugin.js","names":[],"sources":["../../../src/lib/angular-vitest-plugin.ts"],"sourcesContent":["import type { Plugin, TransformResult, UserConfig } from 'vite';\n// Use the namespace import so these runtime helpers still resolve on Vite 6,\n// which does not expose them as named exports.\nimport * as vite from 'vite';\nimport { getJsTransformConfigKey, isRolldown } from './utils/rolldown.js';\n\nconst vitestAngularSetupEntries = [\n '@analogjs/vitest-angular/setup-testbed',\n '@analogjs/vitest-angular/setup-zone',\n '@analogjs/vitest-angular/setup-snapshots',\n '@analogjs/vitest-angular/setup-serializers',\n];\n\n/**\n * Sets up test config for Vitest and downlevels Angular FESM bundles and\n * `@angular/cdk` from modern async/await to ES2016 so that Zone.js can\n * intercept promises during `fakeAsync` tests.\n *\n * Under Vite 8+ (Rolldown) downleveling is not needed.\n * Under Vite ≤7, esbuild handles the downlevel.\n */\nexport function angularVitestPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esm-plugin',\n apply: 'serve',\n enforce: 'post',\n config(userConfig) {\n return {\n optimizeDeps: {\n include: [\n 'tslib',\n '@angular/core',\n '@angular/core/testing',\n '@angular/platform-browser/testing',\n ],\n },\n ssr: {\n noExternal: [\n ...vitestAngularSetupEntries,\n /fesm2022(.*?)testing/,\n /fesm2015/,\n ],\n },\n test: {\n pool: (userConfig as any).test?.pool ?? 'vmThreads',\n },\n };\n },\n // Filter by module ID so only Angular FESM2022 bundles and CDK enter\n // the handler. The inner guards add a secondary code-content check\n // (`async` keyword) for fesm2022 to avoid needless transforms.\n transform: {\n filter: {\n id: /fesm2022|@angular\\/cdk/,\n },\n async handler(_code, id) {\n if (\n (/fesm2022/.test(id) && _code.includes('async ')) ||\n _code.includes('@angular/cdk')\n ) {\n if (isRolldown()) {\n return undefined;\n }\n\n const { code, map } = await vite.transformWithEsbuild(_code, id, {\n loader: 'js',\n format: 'esm',\n target: 'es2016',\n sourcemap: true,\n sourcefile: id,\n });\n\n return {\n code,\n map,\n };\n }\n\n return undefined;\n },\n },\n };\n}\n\n/**\n * Eagerly disables the built-in JS transformer (esbuild on Vite ≤7, OXC on\n * Vite 8+) so Vitest's internal plugin doesn't race with the Angular\n * compiler. Must run at `enforce: 'pre'` to take effect before Vitest\n * reads the resolved config.\n */\nexport function angularVitestEsbuildPlugin(): Plugin {\n return {\n name: '@analogjs/vitest-angular-esbuild-oxc-plugin',\n enforce: 'pre',\n config(userConfig: UserConfig) {\n const jsTransformConfigKey = getJsTransformConfigKey();\n\n return {\n [jsTransformConfigKey]:\n jsTransformConfigKey === 'oxc'\n ? (userConfig.oxc ?? false)\n : (userConfig.esbuild ?? false),\n };\n },\n };\n}\n\n/**\n * Post-processing pass that converts any `.ts` files Angular's compilation\n * skipped (e.g. files without Angular decorators when\n * `useAngularCompilationAPI` is on) into runnable JS via esbuild/OXC.\n *\n * Files Angular already compiled have a sourcemap available via\n * `getInMap` — we skip those here to avoid breaking the chain Vite is\n * already wiring up. Re-running OXC over already-compiled JS produces a\n * map relative to the TS-emitted JS, not the original .ts source, and\n * OXC's `inMap` parameter does not chain through the way esbuild's inline\n * `//# sourceMappingURL=` auto-detection does.\n */\nexport function angularVitestSourcemapPlugin(\n getInMap?: (id: string) => string | undefined,\n): Plugin {\n return {\n name: '@analogjs/vitest-angular-sourcemap-plugin',\n transform: {\n filter: {\n // Match `.ts` at the end of the path OR before a `?` query string.\n // Vite/Vitest appends query params for virtual modules (e.g.\n // `component.ts?inline`), so a plain `$` anchor would reject them\n // and leave sourcemaps misaligned — causing Angular TestBed teardown\n // crashes (`_doc` undefined in `removeAllRootElements`).\n // The negative lookahead `(?!x)` prevents matching `.tsx` or `.d.ts`.\n id: /\\.ts(?:\\?|$)/,\n },\n async handler(code: string, id: string) {\n const [bareId, query] = id.split('?');\n\n if (query && query.includes('inline')) {\n return;\n }\n\n if (getInMap?.(bareId)) {\n return;\n }\n\n if (isRolldown()) {\n const result = await vite.transformWithOxc(code, id, { lang: 'ts' });\n return result as unknown as vite.TransformResult;\n } else {\n const result = await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n });\n return result;\n }\n },\n },\n };\n}\n\nexport function angularVitestPlugins(\n getInMap?: (id: string) => string | undefined,\n): Plugin[] {\n return [\n angularVitestPlugin(),\n angularVitestEsbuildPlugin(),\n angularVitestSourcemapPlugin(getInMap),\n ];\n}\n"],"mappings":";;;AAMA,IAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACD;;;;;;;;;AAUD,SAAgB,sBAA8B;AAC5C,QAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;EACT,OAAO,YAAY;AACjB,UAAO;IACL,cAAc,EACZ,SAAS;KACP;KACA;KACA;KACA;KACD,EACF;IACD,KAAK,EACH,YAAY;KACV,GAAG;KACH;KACA;KACD,EACF;IACD,MAAM,EACJ,MAAO,WAAmB,MAAM,QAAQ,aACzC;IACF;;EAKH,WAAW;GACT,QAAQ,EACN,IAAI,0BACL;GACD,MAAM,QAAQ,OAAO,IAAI;AACvB,QACG,WAAW,KAAK,GAAG,IAAI,MAAM,SAAS,SAAS,IAChD,MAAM,SAAS,eAAe,EAC9B;AACA,SAAI,YAAY,CACd;KAGF,MAAM,EAAE,MAAM,QAAQ,MAAM,KAAK,qBAAqB,OAAO,IAAI;MAC/D,QAAQ;MACR,QAAQ;MACR,QAAQ;MACR,WAAW;MACX,YAAY;MACb,CAAC;AAEF,YAAO;MACL;MACA;MACD;;;GAKN;EACF;;;;;;;;AASH,SAAgB,6BAAqC;AACnD,QAAO;EACL,MAAM;EACN,SAAS;EACT,OAAO,YAAwB;GAC7B,MAAM,uBAAuB,yBAAyB;AAEtD,UAAO,GACJ,uBACC,yBAAyB,QACpB,WAAW,OAAO,QAClB,WAAW,WAAW,OAC9B;;EAEJ;;;;;;;;;;;;;;AAeH,SAAgB,6BACd,UACQ;AACR,QAAO;EACL,MAAM;EACN,WAAW;GACT,QAAQ,EAON,IAAI,gBACL;GACD,MAAM,QAAQ,MAAc,IAAY;IACtC,MAAM,CAAC,QAAQ,SAAS,GAAG,MAAM,IAAI;AAErC,QAAI,SAAS,MAAM,SAAS,SAAS,CACnC;AAGF,QAAI,WAAW,OAAO,CACpB;AAGF,QAAI,YAAY,CAEd,QADe,MAAM,KAAK,iBAAiB,MAAM,IAAI,EAAE,MAAM,MAAM,CAAC;QAMpE,QAHe,MAAM,KAAK,qBAAqB,MAAM,IAAI,EACvD,QAAQ,MACT,CAAC;;GAIP;EACF;;AAGH,SAAgB,qBACd,UACU;AACV,QAAO;EACL,qBAAqB;EACrB,4BAA4B;EAC5B,6BAA6B,SAAS;EACvC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { angularFullVersion, createAngularCompilation, sourceFileCache } from "../utils/devkit.js";
|
|
2
2
|
import { isRolldown } from "../utils/rolldown.js";
|
|
3
|
-
import { activateDeferredDebug, debugCompilationApi, debugCompiler, debugEmit, debugHmr, debugHmrV, debugStyles } from "../utils/debug.js";
|
|
3
|
+
import { activateDeferredDebug, debugCompilationApi, debugCompiler, debugEmit, debugHmr, debugHmrV, debugStyles, debugStylesV } from "../utils/debug.js";
|
|
4
4
|
import { isTailwindReferenceError } from "../utils/tailwind-reference.js";
|
|
5
5
|
import { createCompilerPlugin, createRolldownCompilerPlugin } from "../compiler-plugin.js";
|
|
6
6
|
import { normalizeStylesheetDependencies } from "../style-preprocessor.js";
|
|
@@ -399,6 +399,15 @@ function compilationAPIPlugin(pluginOptions) {
|
|
|
399
399
|
resolveId(id) {
|
|
400
400
|
if (isComponentStyleSheet(id)) {
|
|
401
401
|
const filename = getFilenameFromPath(id);
|
|
402
|
+
const search = new URL(id, "http://localhost").search;
|
|
403
|
+
const servedSourcePath = stylesheetRegistry?.getServedSourcePath(filename);
|
|
404
|
+
if (servedSourcePath) {
|
|
405
|
+
debugStylesV("resolveId: mapped served stylesheet to source", {
|
|
406
|
+
filename,
|
|
407
|
+
resolvedPath: servedSourcePath
|
|
408
|
+
});
|
|
409
|
+
return servedSourcePath + search;
|
|
410
|
+
}
|
|
402
411
|
if (stylesheetRegistry?.hasServed(filename)) return id;
|
|
403
412
|
const componentStyles = stylesheetRegistry?.resolveExternalSource(filename);
|
|
404
413
|
if (componentStyles) return componentStyles + new URL(id, "http://localhost").search;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isTailwindReferenceError } from '../utils/tailwind-reference.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n AngularStylePipelineOptions,\n configureStylePipelineRegistry,\n} from '../style-pipeline.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n} from '../utils/compilation-shared.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface CompilationAPIPluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n disableTypeChecking: boolean;\n supportedBrowsers: string[];\n transformFilter?: (code: string, id: string) => boolean;\n fileReplacements: FileReplacement[];\n stylePreprocessor?: StylePreprocessor;\n stylePipeline?: AngularStylePipelineOptions;\n hasTailwindCss: boolean;\n tailwindCss?: {\n rootStylesheet: string;\n prefixes?: string[];\n };\n isTest: boolean;\n isAstroIntegration: boolean;\n include: string[];\n additionalContentDirs: string[];\n debug?: DebugOption;\n}\n\nexport function compilationAPIPlugin(\n pluginOptions: CompilationAPIPluginOptions,\n): Plugin {\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n hasTailwindCss: pluginOptions.hasTailwindCss,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || pluginOptions.hasTailwindCss);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n pluginOptions.stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n if (isTailwindReferenceError(e)) {\n throw e;\n }\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(_workerFile: string, _containingFile: string) {\n return '';\n },\n },\n (tsCompilerOptions: Record<string, unknown>) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n hasTailwindCss: pluginOptions.hasTailwindCss,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n },\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!pluginOptions.stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (\n stylesheetRegistry &&\n pluginOptions.stylePreprocessor &&\n existsSync(key)\n ) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n pluginOptions.stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n if (angularFullVersion < 200100) {\n console.warn(\n '[@analogjs/vite-plugin-angular]: The Angular Compilation API is only available with Angular v20.1 and later',\n );\n } else {\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n }\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\n };\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`, registered once at the\n // `angular()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n configureStylePipelineRegistry(\n pluginOptions.stylePipeline,\n stylesheetRegistry,\n { workspaceRoot: pluginOptions.workspaceRoot },\n );\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!isVitestVscode) {\n await performCompilation(resolvedConfig);\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n pendingCompilation = performCompilation(resolvedConfig, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n await pendingCompilation;\n pendingCompilation = null;\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n pluginOptions.stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [/node_modules/, 'type=script', '@ng/component'],\n },\n },\n async handler(code, id) {\n if (\n pluginOptions.transformFilter &&\n !(pluginOptions.transformFilter(code, id) ?? true)\n ) {\n return;\n }\n\n // Skip non-Angular files — in compilation API mode, Angular\n // compiles TypeScript before this hook, so only Angular files\n // need processing.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n if (!isAngular) {\n debugCompilationApi('transform skip (non-Angular file)', { id });\n return;\n }\n\n if (id.includes('?') && id.includes('analog-content-')) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (isVitestVscode && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n closeBundle() {\n angularCompilation?.close?.();\n angularCompilation = undefined;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoEA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;AA0BhC,SAAgB,qBACd,eACQ;CACR,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAIhB,IAAI;CAGJ,MAAM,oBAAuC,IAAI,iBAAiB;CAClE,MAAM,8BAAc,IAAI,KAA6B;CACrD,MAAM,6BAAa,IAAI,KAAqB;CAC5C,IAAI;CACJ,IAAI,kBAAkB,Q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vD,QAAO,+BAA+B,KAAK;;AAI/C,WAAO;KACL,MAAM;KACN,KAAK;KACN;;GAEJ;EACD,cAAc;AACZ,uBAAoB,SAAS;AAC7B,wBAAqB,KAAA;;EAExB"}
|
|
1
|
+
{"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isTailwindReferenceError } from '../utils/tailwind-reference.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n AngularStylePipelineOptions,\n configureStylePipelineRegistry,\n} from '../style-pipeline.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n} from '../utils/compilation-shared.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface CompilationAPIPluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n disableTypeChecking: boolean;\n supportedBrowsers: string[];\n transformFilter?: (code: string, id: string) => boolean;\n fileReplacements: FileReplacement[];\n stylePreprocessor?: StylePreprocessor;\n stylePipeline?: AngularStylePipelineOptions;\n hasTailwindCss: boolean;\n tailwindCss?: {\n rootStylesheet: string;\n prefixes?: string[];\n };\n isTest: boolean;\n isAstroIntegration: boolean;\n include: string[];\n additionalContentDirs: string[];\n debug?: DebugOption;\n}\n\nexport function compilationAPIPlugin(\n pluginOptions: CompilationAPIPluginOptions,\n): Plugin {\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n hasTailwindCss: pluginOptions.hasTailwindCss,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || pluginOptions.hasTailwindCss);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n pluginOptions.stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n if (isTailwindReferenceError(e)) {\n throw e;\n }\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(_workerFile: string, _containingFile: string) {\n return '';\n },\n },\n (tsCompilerOptions: Record<string, unknown>) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n hasTailwindCss: pluginOptions.hasTailwindCss,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n },\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!pluginOptions.stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (\n stylesheetRegistry &&\n pluginOptions.stylePreprocessor &&\n existsSync(key)\n ) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n pluginOptions.stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n if (angularFullVersion < 200100) {\n console.warn(\n '[@analogjs/vite-plugin-angular]: The Angular Compilation API is only available with Angular v20.1 and later',\n );\n } else {\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n }\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\n };\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`, registered once at the\n // `angular()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n configureStylePipelineRegistry(\n pluginOptions.stylePipeline,\n stylesheetRegistry,\n { workspaceRoot: pluginOptions.workspaceRoot },\n );\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!isVitestVscode) {\n await performCompilation(resolvedConfig);\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n pendingCompilation = performCompilation(resolvedConfig, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n await pendingCompilation;\n pendingCompilation = null;\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n pluginOptions.stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath =\n stylesheetRegistry?.getServedSourcePath(filename);\n\n if (servedSourcePath) {\n debugStylesV('resolveId: mapped served stylesheet to source', {\n filename,\n resolvedPath: servedSourcePath,\n });\n return servedSourcePath + search;\n }\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [/node_modules/, 'type=script', '@ng/component'],\n },\n },\n async handler(code, id) {\n if (\n pluginOptions.transformFilter &&\n !(pluginOptions.transformFilter(code, id) ?? true)\n ) {\n return;\n }\n\n // Skip non-Angular files — in compilation API mode, Angular\n // compiles TypeScript before this hook, so only Angular files\n // need processing.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n if (!isAngular) {\n debugCompilationApi('transform skip (non-Angular file)', { id });\n return;\n }\n\n if (id.includes('?') && id.includes('analog-content-')) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (isVitestVscode && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n closeBundle() {\n angularCompilation?.close?.();\n angularCompilation = undefined;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqEA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;AA0BhC,SAAgB,qBACd,eACQ;CACR,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAIhB,IAAI;CAGJ,MAAM,oBAAuC,IAAI,iBAAiB;CAClE,MAAM,8BAAc,IAAI,KAA6B;CACrD,MAAM,6BAAa,IAAI,KAAqB;CAC5C,IAAI;CACJ,IAAI,kBAAkB,QAAQ,SAAS;CACvC,IAAI,qBAA2C;CAC/C,IAAI,qBAAqB;CACzB,IAAI;CAEJ,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,mBAAmB,IAAI,iBAAiB;EAC5C,eAAe,cAAc;EAC7B,SAAS,cAAc;EACvB,YAAY,cAAc;EAC1B,gBAAgB,cAAc;EAC9B;EACD,CAAC;CACF,MAAM,iBAAiB,CAAC,CAAC,QAAQ,IAAI;CACrC,IAAI,gBAAgB,iBAAiB;CAErC,SAAS,sBAA+B;AACtC,SAAO,iBAAiB,eAAe,OAAO,QAAQ,QAAQ;;CAGhE,SAAS,yBAAkC;AAEzC,SAAO,CAAC,GADmB,SAAS,gBAAgB,cAGlD,cAAc,cACd,qBAAq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C,EAAE,IAAI,CAAC;AAChE;;AAGF,QAAI,GAAG,SAAS,IAAI,IAAI,GAAG,SAAS,kBAAkB,CACpD;AAGF,QAAI,GAAG,SAAS,OAAO,CACrB,MAAK,GAAG,QAAQ,UAAU,GAAG;AAG/B,QAAI,QAAQ;AACV,SAAI,kBAAkB,CAAC,oBAAoB;AACzC,2BAAqB,mBAAmB,eAAe;AACvD,2BAAqB;;KAGvB,MAAM,QAAQ,YAAY,YAAY,cAAc,GAAG;AACvD,SAAI,OAAO;MACT,MAAM,cAAc,MAAM;AAC1B,UAAI,iBAAiB,YACnB,sBAAqB,mBAAmB,gBAAgB,CAAC,GAAG,CAAC;;;AAKnE,QAAI,oBAAoB;AACtB,WAAM;AACN,0BAAqB;;IAGvB,MAAM,mBAAmB,YAAY,GAAG;AACxC,QAAI,CAAC,kBAAkB;AACrB,yBAAoB,qCAAqC,EAAE,IAAI,CAAC;AAChE,SAAI,UACF,MAAK,KACH,qCAAqC,GAAG,6GAEzC;AAEH;;AAGF,QAAI,iBAAiB,YAAY,iBAAiB,SAAS,SAAS,EAClE,MAAK,KAAK,GAAG,iBAAiB,SAAS,KAAK,KAAK,GAAG;AAGtD,QAAI,iBAAiB,UAAU,iBAAiB,OAAO,SAAS,EAC9D,MAAK,MAAM,GAAG,iBAAiB,OAAO,KAAK,KAAK,GAAG;IAGrD,IAAI,OAAO,iBAAiB,WAAW;AAGvC,QAAI,KAAK,SAAS,UAAU;SACP,KAAK,SAAS,wBAAwB,CAEvD,QAAO,+BAA+B,KAAK;;AAI/C,WAAO;KACL,MAAM;KACN,KAAK;KACN;;GAEJ;EACD,cAAc;AACZ,uBAAoB,SAAS;AAC7B,wBAAqB,KAAA;;EAExB"}
|
|
@@ -45,6 +45,7 @@ export declare class AnalogStylesheetRegistry {
|
|
|
45
45
|
get externalCount(): number;
|
|
46
46
|
hasServed(requestId: string): boolean;
|
|
47
47
|
getServedContent(requestId: string): string | undefined;
|
|
48
|
+
getServedSourcePath(requestId: string): string | undefined;
|
|
48
49
|
resolveExternalSource(requestId: string): string | undefined;
|
|
49
50
|
getPublicIdsForSource(sourcePath: string): string[];
|
|
50
51
|
getRequestIdsForSource(sourcePath: string): string[];
|
|
@@ -57,6 +57,9 @@ var AnalogStylesheetRegistry = class {
|
|
|
57
57
|
getServedContent(requestId) {
|
|
58
58
|
return this.resolveServedRecord(requestId)?.normalizedCode;
|
|
59
59
|
}
|
|
60
|
+
getServedSourcePath(requestId) {
|
|
61
|
+
return this.resolveServedRecord(requestId)?.sourcePath;
|
|
62
|
+
}
|
|
60
63
|
resolveExternalSource(requestId) {
|
|
61
64
|
const normalizedRequestId = this.normalizeRequestId(requestId);
|
|
62
65
|
return this.externalRequestToSource.get(normalizedRequestId);
|
|
@@ -82,7 +85,7 @@ var AnalogStylesheetRegistry = class {
|
|
|
82
85
|
registerActiveRequest(requestId) {
|
|
83
86
|
const normalizedRequestId = this.normalizeRequestId(requestId);
|
|
84
87
|
const requestPath = normalizedRequestId.split("?")[0];
|
|
85
|
-
const sourcePath = this.resolveExternalSource(requestPath) ?? this.resolveExternalSource(requestPath.replace(/^\//, ""));
|
|
88
|
+
const sourcePath = this.resolveExternalSource(requestPath) ?? this.resolveExternalSource(requestPath.replace(/^\//, "")) ?? this.getServedSourcePath(requestPath) ?? this.getServedSourcePath(requestPath.replace(/^\//, ""));
|
|
86
89
|
if (!sourcePath) return;
|
|
87
90
|
const requestIds = this.sourceToRequestIds.get(sourcePath) ?? /* @__PURE__ */ new Set();
|
|
88
91
|
requestIds.add(normalizedRequestId);
|
|
@@ -147,14 +150,17 @@ function rewriteRelativeCssImports(code, filename) {
|
|
|
147
150
|
}
|
|
148
151
|
function registerStylesheetContent(registry, { code, dependencies, diagnostics, tags, containingFile, className, order, inlineStylesExtension, resourceFile }) {
|
|
149
152
|
const stylesheetId = `${createHash("sha256").update(containingFile).update(className ?? "").update(String(order ?? 0)).update(code).digest("hex")}.${inlineStylesExtension}`;
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
const sourcePath = resourceFile ?? containingFile.replace(".ts", `.${inlineStylesExtension}`);
|
|
154
|
+
const normalizedSourcePath = normalizePath(normalize(sourcePath));
|
|
155
|
+
const aliases = [
|
|
156
|
+
sourcePath,
|
|
157
|
+
normalizedSourcePath,
|
|
158
|
+
sourcePath.replace(/^\//, ""),
|
|
159
|
+
normalizedSourcePath.replace(/^\//, "")
|
|
160
|
+
];
|
|
155
161
|
registry.registerServedStylesheet({
|
|
156
162
|
publicId: stylesheetId,
|
|
157
|
-
sourcePath:
|
|
163
|
+
sourcePath: normalizedSourcePath,
|
|
158
164
|
normalizedCode: code,
|
|
159
165
|
dependencies,
|
|
160
166
|
diagnostics,
|
|
@@ -1 +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 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 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\n const aliases: string[] = [];\n\n if (resourceFile) {\n const normalizedResourceFile = normalizePath(normalize(resourceFile));\n // Avoid basename-only aliases here: shared filenames like `index.css`\n // can collide across components and break HMR lookups.\n aliases.push(\n resourceFile,\n normalizedResourceFile,\n resourceFile.replace(/^\\//, ''),\n normalizedResourceFile.replace(/^\\//, ''),\n );\n }\n\n registry.registerServedStylesheet(\n {\n publicId: stylesheetId,\n sourcePath: resourceFile,\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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AS,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;CAE9B,MAAM,UAAoB,EAAE;AAE5B,KAAI,cAAc;EAChB,MAAM,yBAAyB,cAAc,UAAU,aAAa,CAAC;AAGrE,UAAQ,KACN,cACA,wBACA,aAAa,QAAQ,OAAO,GAAG,EAC/B,uBAAuB,QAAQ,OAAO,GAAG,CAC1C;;AAGH,UAAS,yBACP;EACE,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB;EACA;EACA;EACD,EACD,QACD;AAED,QAAO"}
|
|
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,KAA0B;CAC3D,uCAA+B,IAAI,KAAqC;CACxE,sCAA8B,IAAI,KAAqC;CACvE,+BAAuB,IAAI,KAAuB;;;;;;;;;;;;CAalD,mBAA2B,WAA2B;EACpD,MAAM,CAAC,aAAa,YAAY,MAAM,UAAU,MAAM,IAAI;EAC1D,MAAM,qBAAqB,YAAY,QAAQ,OAAO,GAAG;AAEzD,MAAI,CAAC,UACH,QAAO;EAOT,MAAM,mBAAmB,UACtB,MAAM,IAAI,CACV,QAAQ,YAAY,QAAQ,SAAS,EAAE,CACvC,QAAQ,YAAY;GACnB,MAAM,CAAC,OAAO,QAAQ,MAAM,IAAI;AAChC,UAAO,QAAQ;IACf,CACD,KAAK,IAAI;AAEZ,SAAO,mBACH,GAAG,mBAAmB,GAAG,qBACzB;;CAGN,IAAI,cAAsB;AACxB,SAAO,KAAK,WAAW;;CAGzB,IAAI,gBAAwB;AAC1B,SAAO,KAAK,wBAAwB;;CAGtC,UAAU,WAA4B;AACpC,SAAO,KAAK,oBAAoB,UAAU,KAAK,KAAA;;CAGjD,iBAAiB,WAAuC;AACtD,SAAO,KAAK,oBAAoB,UAAU,EAAE;;CAG9C,oBAA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;EACE,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB;EACA;EACA;EACD,EACD,QACD;AAED,QAAO"}
|
|
@@ -43,8 +43,8 @@ var TsconfigResolver = class {
|
|
|
43
43
|
return compilerCli.readConfiguration(resolvedTsConfigPath, {
|
|
44
44
|
suppressOutputPathCheck: true,
|
|
45
45
|
outDir: void 0,
|
|
46
|
-
sourceMap:
|
|
47
|
-
inlineSourceMap:
|
|
46
|
+
sourceMap: !isProd,
|
|
47
|
+
inlineSourceMap: false,
|
|
48
48
|
inlineSources: !isProd,
|
|
49
49
|
declaration: false,
|
|
50
50
|
declarationMap: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig-resolver.js","names":[],"sources":["../../../../src/lib/utils/tsconfig-resolver.ts"],"sourcesContent":["/**\n * Shared tsconfig resolution logic used by both the ngtsc and compilation-api\n * compilation plugins. Encapsulates the caching, include-glob discovery,\n * tsconfig-graph expansion, and path-root resolution that were previously\n * duplicated across angular-vite-plugin.ts and compilation-api-plugin.ts.\n */\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport { normalizePath, ResolvedConfig } from 'vite';\nimport { globSync } from 'tinyglobby';\nimport { debugEmit, debugEmitV } from './debug.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface TsconfigResolverOptions {\n workspaceRoot: string;\n include: string[];\n liveReload: boolean;\n hasTailwindCss: boolean;\n isTest: boolean;\n}\n\nexport class TsconfigResolver {\n private includeCache: string[] = [];\n private tsconfigOptionsCache = new Map<\n string,\n { options: any; rootNames: string[] }\n >();\n private tsconfigGraphRootCache = new Map<string, string[]>();\n\n constructor(private options: TsconfigResolverOptions) {}\n\n invalidateIncludeCache(): void {\n this.includeCache = [];\n }\n\n invalidateTsconfigCaches(): void {\n this.tsconfigOptionsCache.clear();\n this.tsconfigGraphRootCache.clear();\n }\n\n invalidateAll(): void {\n this.invalidateIncludeCache();\n this.invalidateTsconfigCaches();\n }\n\n ensureIncludeCache(): string[] {\n if (this.options.include.length > 0 && this.includeCache.length === 0) {\n this.includeCache = this.findIncludes();\n debugEmit('include cache populated', {\n fileCount: this.includeCache.length,\n });\n }\n return this.includeCache;\n }\n\n readAngularTsconfigConfiguration(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ) {\n const isProd = config.mode === 'production';\n return compilerCli.readConfiguration(resolvedTsConfigPath, {\n suppressOutputPathCheck: true,\n outDir: undefined,\n sourceMap: false,\n inlineSourceMap: !isProd,\n inlineSources: !isProd,\n declaration: false,\n declarationMap: false,\n allowEmptyCodegenFiles: false,\n annotationsAs: 'decorators',\n enableResourceInlining: false,\n noEmitOnError: false,\n mapRoot: '',\n sourceRoot: '',\n supportTestBed: false,\n supportJitMode: false,\n });\n }\n\n getCachedTsconfigOptions(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): { options: any; rootNames: string[] } {\n const tsconfigKey = this.getTsconfigCacheKey(resolvedTsConfigPath, config);\n let cached = this.tsconfigOptionsCache.get(tsconfigKey);\n\n if (!cached) {\n const read = this.readAngularTsconfigConfiguration(\n resolvedTsConfigPath,\n config,\n );\n cached = { options: read.options, rootNames: read.rootNames };\n this.tsconfigOptionsCache.set(tsconfigKey, cached);\n debugEmit('tsconfig root names loaded', {\n resolvedTsConfigPath,\n rootNameCount: read.rootNames.length,\n });\n debugEmitV('tsconfig root names', {\n resolvedTsConfigPath,\n rootNames: read.rootNames.map((file: string) => normalizePath(file)),\n });\n }\n\n return cached;\n }\n\n collectExpandedTsconfigRoots(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n visited = new Set<string>(),\n ): string[] {\n const normalizedTsConfigPath = normalizePath(resolvedTsConfigPath);\n if (visited.has(normalizedTsConfigPath)) {\n return [];\n }\n\n const tsconfigKey = `${this.getTsconfigCacheKey(normalizedTsConfigPath, config)}|graph`;\n const cached = this.tsconfigGraphRootCache.get(tsconfigKey);\n if (cached) {\n return cached;\n }\n\n visited.add(normalizedTsConfigPath);\n\n const read = this.readAngularTsconfigConfiguration(\n normalizedTsConfigPath,\n config,\n );\n const rawTsconfig = (ts.readConfigFile(\n normalizedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n references?: Array<{ path?: unknown }>;\n };\n\n const expandedRoots = new Set(\n read.rootNames.map((file: string) => normalizePath(file)),\n );\n const pathRoots = collectTsconfigPathRoots(\n normalizedTsConfigPath,\n read.options,\n rawTsconfig,\n );\n for (const pathRoot of pathRoots) {\n expandedRoots.add(pathRoot);\n }\n\n const referenceConfigs = (rawTsconfig.references ?? [])\n .flatMap((reference) =>\n typeof reference.path === 'string'\n ? [\n resolveReferenceTsconfigPath(\n reference.path,\n normalizedTsConfigPath,\n ),\n ]\n : [],\n )\n .filter((reference): reference is string => !!reference);\n\n for (const referenceConfig of referenceConfigs) {\n for (const referenceRoot of this.collectExpandedTsconfigRoots(\n referenceConfig,\n config,\n visited,\n )) {\n expandedRoots.add(referenceRoot);\n }\n }\n\n const expandedRootList = [...expandedRoots];\n this.tsconfigGraphRootCache.set(tsconfigKey, expandedRootList);\n debugEmit('expanded tsconfig graph roots', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n directRootNameCount: read.rootNames.length,\n pathRootCount: pathRoots.length,\n referenceConfigCount: referenceConfigs.length,\n expandedRootCount: expandedRootList.length,\n });\n debugEmitV('expanded tsconfig graph root files', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n pathRoots,\n referenceConfigs,\n rootNames: expandedRootList,\n });\n\n return expandedRootList;\n }\n\n private getTsconfigCacheKey(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const isProd = config.mode === 'production';\n return [\n resolvedTsConfigPath,\n isProd ? 'prod' : 'dev',\n this.options.isTest ? 'test' : 'app',\n config.build?.lib ? 'lib' : 'nolib',\n this.options.liveReload ? 'live-reload' : 'no-live-reload',\n this.options.hasTailwindCss ? 'tw' : 'notw',\n ].join('|');\n }\n\n private findIncludes(): string[] {\n const globs = this.options.include.map((glob) =>\n normalizeIncludeGlob(this.options.workspaceRoot, glob),\n );\n const files = globSync(globs, { dot: true, absolute: true });\n debugEmit('include discovery', {\n patternCount: globs.length,\n fileCount: files.length,\n });\n debugEmitV('include discovery files', {\n globs,\n files: files.map((file) => normalizePath(file)),\n });\n return files;\n }\n}\n\nexport function normalizeIncludeGlob(\n workspaceRoot: string,\n glob: string,\n): string {\n const normalizedWorkspaceRoot = normalizePath(resolve(workspaceRoot));\n const normalizedGlob = normalizePath(glob);\n\n if (\n normalizedGlob === normalizedWorkspaceRoot ||\n normalizedGlob.startsWith(`${normalizedWorkspaceRoot}/`)\n ) {\n return normalizedGlob;\n }\n\n if (normalizedGlob.startsWith('/')) {\n return `${normalizedWorkspaceRoot}${normalizedGlob}`;\n }\n\n return normalizePath(resolve(normalizedWorkspaceRoot, normalizedGlob));\n}\n\nfunction resolveReferenceTsconfigPath(\n referencePath: string,\n ownerTsconfigPath: string,\n): string | undefined {\n const ownerDir = dirname(ownerTsconfigPath);\n const resolvedReference = normalizePath(\n isAbsolute(referencePath)\n ? referencePath\n : resolve(ownerDir, referencePath),\n );\n\n if (existsSync(resolvedReference)) {\n try {\n if (statSync(resolvedReference).isDirectory()) {\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n return existsSync(nestedTsconfig)\n ? normalizePath(nestedTsconfig)\n : undefined;\n }\n } catch {\n return undefined;\n }\n return resolvedReference;\n }\n\n if (!resolvedReference.endsWith('.json')) {\n const asJson = `${resolvedReference}.json`;\n if (existsSync(asJson)) {\n return normalizePath(asJson);\n }\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n if (existsSync(nestedTsconfig)) {\n return normalizePath(nestedTsconfig);\n }\n }\n\n return undefined;\n}\n\nfunction collectTsconfigPathRoots(\n resolvedTsConfigPath: string,\n options: any,\n rawTsconfig: {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n },\n): string[] {\n const tsPaths = rawTsconfig.compilerOptions?.paths ?? options.paths;\n if (!tsPaths) {\n return [];\n }\n\n const tsconfigDir = dirname(resolvedTsConfigPath);\n const configuredBaseUrl =\n typeof options.baseUrl === 'string'\n ? options.baseUrl\n : typeof rawTsconfig.compilerOptions?.baseUrl === 'string'\n ? rawTsconfig.compilerOptions.baseUrl\n : undefined;\n const resolvedBaseUrl = configuredBaseUrl\n ? isAbsolute(configuredBaseUrl)\n ? configuredBaseUrl\n : resolve(tsconfigDir, configuredBaseUrl)\n : tsconfigDir;\n const discoveredRoots = new Set<string>();\n\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n const resolvedTarget = normalizePath(\n isAbsolute(target) ? target : resolve(resolvedBaseUrl, target),\n );\n\n if (target.includes('*')) {\n for (const match of globSync(resolvedTarget, {\n dot: true,\n absolute: true,\n })) {\n discoveredRoots.add(normalizePath(match));\n }\n continue;\n }\n\n if (existsSync(resolvedTarget)) {\n discoveredRoots.add(resolvedTarget);\n }\n }\n }\n\n return [...discoveredRoots];\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;AAUhC,IAAa,mBAAb,MAA8B;CAC5B,eAAiC,EAAE;CACnC,uCAA+B,IAAI,KAGhC;CACH,yCAAiC,IAAI,KAAuB;CAE5D,YAAY,SAA0C;AAAlC,OAAA,UAAA;;CAEpB,yBAA+B;AAC7B,OAAK,eAAe,EAAE;;CAGxB,2BAAiC;AAC/B,OAAK,qBAAqB,OAAO;AACjC,OAAK,uBAAuB,OAAO;;CAGrC,gBAAsB;AACpB,OAAK,wBAAwB;AAC7B,OAAK,0BAA0B;;CAGjC,qBAA+B;AAC7B,MAAI,KAAK,QAAQ,QAAQ,SAAS,KAAK,KAAK,aAAa,WAAW,GAAG;AACrE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AY,gBAAgB,UAC5B,KAAA;CACR,MAAM,kBAAkB,oBACpB,WAAW,kBAAkB,GAC3B,oBACA,QAAQ,aAAa,kBAAkB,GACzC;CACJ,MAAM,kCAAkB,IAAI,KAAa;AAEzC,MAAK,MAAM,WAAW,OAAO,OAAO,QAAQ,CAC1C,MAAK,MAAM,UAAU,SAAqB;EACxC,MAAM,iBAAiB,cACrB,WAAW,OAAO,GAAG,SAAS,QAAQ,iBAAiB,OAAO,CAC/D;AAED,MAAI,OAAO,SAAS,IAAI,EAAE;AACxB,QAAK,MAAM,SAAS,SAAS,gBAAgB;IAC3C,KAAK;IACL,UAAU;IACX,CAAC,CACA,iBAAgB,IAAI,cAAc,MAAM,CAAC;AAE3C;;AAGF,MAAI,WAAW,eAAe,CAC5B,iBAAgB,IAAI,eAAe;;AAKzC,QAAO,CAAC,GAAG,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"tsconfig-resolver.js","names":[],"sources":["../../../../src/lib/utils/tsconfig-resolver.ts"],"sourcesContent":["/**\n * Shared tsconfig resolution logic used by both the ngtsc and compilation-api\n * compilation plugins. Encapsulates the caching, include-glob discovery,\n * tsconfig-graph expansion, and path-root resolution that were previously\n * duplicated across angular-vite-plugin.ts and compilation-api-plugin.ts.\n */\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport { normalizePath, ResolvedConfig } from 'vite';\nimport { globSync } from 'tinyglobby';\nimport { debugEmit, debugEmitV } from './debug.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface TsconfigResolverOptions {\n workspaceRoot: string;\n include: string[];\n liveReload: boolean;\n hasTailwindCss: boolean;\n isTest: boolean;\n}\n\nexport class TsconfigResolver {\n private includeCache: string[] = [];\n private tsconfigOptionsCache = new Map<\n string,\n { options: any; rootNames: string[] }\n >();\n private tsconfigGraphRootCache = new Map<string, string[]>();\n\n constructor(private options: TsconfigResolverOptions) {}\n\n invalidateIncludeCache(): void {\n this.includeCache = [];\n }\n\n invalidateTsconfigCaches(): void {\n this.tsconfigOptionsCache.clear();\n this.tsconfigGraphRootCache.clear();\n }\n\n invalidateAll(): void {\n this.invalidateIncludeCache();\n this.invalidateTsconfigCaches();\n }\n\n ensureIncludeCache(): string[] {\n if (this.options.include.length > 0 && this.includeCache.length === 0) {\n this.includeCache = this.findIncludes();\n debugEmit('include cache populated', {\n fileCount: this.includeCache.length,\n });\n }\n return this.includeCache;\n }\n\n readAngularTsconfigConfiguration(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ) {\n const isProd = config.mode === 'production';\n return compilerCli.readConfiguration(resolvedTsConfigPath, {\n suppressOutputPathCheck: true,\n outDir: undefined,\n sourceMap: !isProd,\n inlineSourceMap: false,\n inlineSources: !isProd,\n declaration: false,\n declarationMap: false,\n allowEmptyCodegenFiles: false,\n annotationsAs: 'decorators',\n enableResourceInlining: false,\n noEmitOnError: false,\n mapRoot: '',\n sourceRoot: '',\n supportTestBed: false,\n supportJitMode: false,\n });\n }\n\n getCachedTsconfigOptions(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): { options: any; rootNames: string[] } {\n const tsconfigKey = this.getTsconfigCacheKey(resolvedTsConfigPath, config);\n let cached = this.tsconfigOptionsCache.get(tsconfigKey);\n\n if (!cached) {\n const read = this.readAngularTsconfigConfiguration(\n resolvedTsConfigPath,\n config,\n );\n cached = { options: read.options, rootNames: read.rootNames };\n this.tsconfigOptionsCache.set(tsconfigKey, cached);\n debugEmit('tsconfig root names loaded', {\n resolvedTsConfigPath,\n rootNameCount: read.rootNames.length,\n });\n debugEmitV('tsconfig root names', {\n resolvedTsConfigPath,\n rootNames: read.rootNames.map((file: string) => normalizePath(file)),\n });\n }\n\n return cached;\n }\n\n collectExpandedTsconfigRoots(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n visited = new Set<string>(),\n ): string[] {\n const normalizedTsConfigPath = normalizePath(resolvedTsConfigPath);\n if (visited.has(normalizedTsConfigPath)) {\n return [];\n }\n\n const tsconfigKey = `${this.getTsconfigCacheKey(normalizedTsConfigPath, config)}|graph`;\n const cached = this.tsconfigGraphRootCache.get(tsconfigKey);\n if (cached) {\n return cached;\n }\n\n visited.add(normalizedTsConfigPath);\n\n const read = this.readAngularTsconfigConfiguration(\n normalizedTsConfigPath,\n config,\n );\n const rawTsconfig = (ts.readConfigFile(\n normalizedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n references?: Array<{ path?: unknown }>;\n };\n\n const expandedRoots = new Set(\n read.rootNames.map((file: string) => normalizePath(file)),\n );\n const pathRoots = collectTsconfigPathRoots(\n normalizedTsConfigPath,\n read.options,\n rawTsconfig,\n );\n for (const pathRoot of pathRoots) {\n expandedRoots.add(pathRoot);\n }\n\n const referenceConfigs = (rawTsconfig.references ?? [])\n .flatMap((reference) =>\n typeof reference.path === 'string'\n ? [\n resolveReferenceTsconfigPath(\n reference.path,\n normalizedTsConfigPath,\n ),\n ]\n : [],\n )\n .filter((reference): reference is string => !!reference);\n\n for (const referenceConfig of referenceConfigs) {\n for (const referenceRoot of this.collectExpandedTsconfigRoots(\n referenceConfig,\n config,\n visited,\n )) {\n expandedRoots.add(referenceRoot);\n }\n }\n\n const expandedRootList = [...expandedRoots];\n this.tsconfigGraphRootCache.set(tsconfigKey, expandedRootList);\n debugEmit('expanded tsconfig graph roots', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n directRootNameCount: read.rootNames.length,\n pathRootCount: pathRoots.length,\n referenceConfigCount: referenceConfigs.length,\n expandedRootCount: expandedRootList.length,\n });\n debugEmitV('expanded tsconfig graph root files', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n pathRoots,\n referenceConfigs,\n rootNames: expandedRootList,\n });\n\n return expandedRootList;\n }\n\n private getTsconfigCacheKey(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const isProd = config.mode === 'production';\n return [\n resolvedTsConfigPath,\n isProd ? 'prod' : 'dev',\n this.options.isTest ? 'test' : 'app',\n config.build?.lib ? 'lib' : 'nolib',\n this.options.liveReload ? 'live-reload' : 'no-live-reload',\n this.options.hasTailwindCss ? 'tw' : 'notw',\n ].join('|');\n }\n\n private findIncludes(): string[] {\n const globs = this.options.include.map((glob) =>\n normalizeIncludeGlob(this.options.workspaceRoot, glob),\n );\n const files = globSync(globs, { dot: true, absolute: true });\n debugEmit('include discovery', {\n patternCount: globs.length,\n fileCount: files.length,\n });\n debugEmitV('include discovery files', {\n globs,\n files: files.map((file) => normalizePath(file)),\n });\n return files;\n }\n}\n\nexport function normalizeIncludeGlob(\n workspaceRoot: string,\n glob: string,\n): string {\n const normalizedWorkspaceRoot = normalizePath(resolve(workspaceRoot));\n const normalizedGlob = normalizePath(glob);\n\n if (\n normalizedGlob === normalizedWorkspaceRoot ||\n normalizedGlob.startsWith(`${normalizedWorkspaceRoot}/`)\n ) {\n return normalizedGlob;\n }\n\n if (normalizedGlob.startsWith('/')) {\n return `${normalizedWorkspaceRoot}${normalizedGlob}`;\n }\n\n return normalizePath(resolve(normalizedWorkspaceRoot, normalizedGlob));\n}\n\nfunction resolveReferenceTsconfigPath(\n referencePath: string,\n ownerTsconfigPath: string,\n): string | undefined {\n const ownerDir = dirname(ownerTsconfigPath);\n const resolvedReference = normalizePath(\n isAbsolute(referencePath)\n ? referencePath\n : resolve(ownerDir, referencePath),\n );\n\n if (existsSync(resolvedReference)) {\n try {\n if (statSync(resolvedReference).isDirectory()) {\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n return existsSync(nestedTsconfig)\n ? normalizePath(nestedTsconfig)\n : undefined;\n }\n } catch {\n return undefined;\n }\n return resolvedReference;\n }\n\n if (!resolvedReference.endsWith('.json')) {\n const asJson = `${resolvedReference}.json`;\n if (existsSync(asJson)) {\n return normalizePath(asJson);\n }\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n if (existsSync(nestedTsconfig)) {\n return normalizePath(nestedTsconfig);\n }\n }\n\n return undefined;\n}\n\nfunction collectTsconfigPathRoots(\n resolvedTsConfigPath: string,\n options: any,\n rawTsconfig: {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n },\n): string[] {\n const tsPaths = rawTsconfig.compilerOptions?.paths ?? options.paths;\n if (!tsPaths) {\n return [];\n }\n\n const tsconfigDir = dirname(resolvedTsConfigPath);\n const configuredBaseUrl =\n typeof options.baseUrl === 'string'\n ? options.baseUrl\n : typeof rawTsconfig.compilerOptions?.baseUrl === 'string'\n ? rawTsconfig.compilerOptions.baseUrl\n : undefined;\n const resolvedBaseUrl = configuredBaseUrl\n ? isAbsolute(configuredBaseUrl)\n ? configuredBaseUrl\n : resolve(tsconfigDir, configuredBaseUrl)\n : tsconfigDir;\n const discoveredRoots = new Set<string>();\n\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n const resolvedTarget = normalizePath(\n isAbsolute(target) ? target : resolve(resolvedBaseUrl, target),\n );\n\n if (target.includes('*')) {\n for (const match of globSync(resolvedTarget, {\n dot: true,\n absolute: true,\n })) {\n discoveredRoots.add(normalizePath(match));\n }\n continue;\n }\n\n if (existsSync(resolvedTarget)) {\n discoveredRoots.add(resolvedTarget);\n }\n }\n }\n\n return [...discoveredRoots];\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;AAUhC,IAAa,mBAAb,MAA8B;CAC5B,eAAiC,EAAE;CACnC,uCAA+B,IAAI,KAGhC;CACH,yCAAiC,IAAI,KAAuB;CAE5D,YAAY,SAA0C;AAAlC,OAAA,UAAA;;CAEpB,yBAA+B;AAC7B,OAAK,eAAe,EAAE;;CAGxB,2BAAiC;AAC/B,OAAK,qBAAqB,OAAO;AACjC,OAAK,uBAAuB,OAAO;;CAGrC,gBAAsB;AACpB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