@analogjs/vite-plugin-angular 3.0.0-beta.39 → 3.0.0-beta.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/vite-plugin-angular",
3
- "version": "3.0.0-beta.39",
3
+ "version": "3.0.0-beta.40",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -6,7 +6,7 @@ import { AnalogStylesheetRegistry, preprocessStylesheetResult, registerStyleshee
6
6
  import { describeStylesheetContent, getBrowserModeCliOverride, isIgnoredHmrFile, isTestWatchMode, refreshStylesheetRegistryForFile } from "./utils/compilation-shared.js";
7
7
  import { angularFullVersion } from "./utils/devkit.js";
8
8
  import { createTsConfigGetter, getTsConfigPath, isProdMode } from "./utils/plugin-config.js";
9
- import { warnStylesheetError } from "./utils/stylesheet-warning.js";
9
+ import { reportStylesheetError } from "./utils/stylesheet-warning.js";
10
10
  import { TsconfigResolver } from "./utils/tsconfig-resolver.js";
11
11
  import { readFileSync } from "node:fs";
12
12
  import { relative, resolve } from "node:path";
@@ -234,7 +234,7 @@ function createAngularBuildContext(options) {
234
234
  resourceFile: input.resourceFile ?? "(inline)",
235
235
  error: String(e)
236
236
  });
237
- warnStylesheetError(input.logger ?? ctx.resolvedConfig?.logger, filename, e);
237
+ reportStylesheetError(input.logger ?? ctx.resolvedConfig?.logger, filename, e, ctx.resolvedConfig?.command === "build");
238
238
  }
239
239
  if (!stylesheetResult?.code) return null;
240
240
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"angular-build-context.js","names":[],"sources":["../../../src/lib/angular-build-context.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport {\n normalizePath,\n preprocessCSS,\n type Logger,\n type Plugin,\n type ResolvedConfig,\n type UserConfig,\n type ViteDevServer,\n} from 'vite';\n\nimport {\n discoverAnalogIntegrations,\n type AnalogIntegrations,\n type ComponentRegistryEntries,\n type StylesheetRegistryConfigurator,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport { isComponentStyleSheet } from './encapsulation-plugin.js';\nimport type { EmitFileResult } from './models.js';\nimport type { FileReplacement } from './plugins/file-replacements.plugin.js';\nimport {\n normalizeStylesheetDependencies,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n} from './stylesheet-registry.js';\nimport {\n describeStylesheetContent,\n getBrowserModeCliOverride,\n isIgnoredHmrFile,\n isTestWatchMode,\n refreshStylesheetRegistryForFile,\n} from './utils/compilation-shared.js';\nimport {\n applyDebugOption,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from './utils/debug.js';\nimport { angularFullVersion } from './utils/devkit.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n createTsConfigGetter,\n getTsConfigPath,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { warnStylesheetError } from './utils/stylesheet-warning.js';\nimport { TsconfigResolver } from './utils/tsconfig-resolver.js';\n\nexport interface PluginOptions {\n /**\n * Path to the tsconfig used for compilation, or a function returning it.\n * Defaults to `tsconfig.app.json` (`tsconfig.lib.json` for libraries,\n * `tsconfig.spec.json` in tests).\n */\n tsconfig?: string | (() => string);\n /**\n * Absolute path to the workspace root. Defaults to `NX_WORKSPACE_ROOT`,\n * then `process.cwd()`.\n */\n workspaceRoot?: string;\n /**\n * Stylesheet extension used for inline component `styles`. Defaults to `css`.\n */\n inlineStylesExtension?: string;\n /**\n * Compile components in JIT mode. Defaults to `true` in tests and `false`\n * otherwise.\n */\n jit?: boolean;\n /**\n * Additional files to include in compilation, as globs relative to the\n * workspace root.\n */\n include?: string[];\n /**\n * Enables Analog's Angular live-reload/HMR pipeline during development/watch mode.\n *\n * This is separate from Vite's `server.hmr` option, which configures the\n * HMR client transport.\n *\n * Defaults to `true` for watch mode, or `false` with `compilation: 'ngp'`,\n * which reloads the page on every change unless this is `true`. Set to\n * `false` to disable Angular reload updates while keeping other stylesheet\n * externalization behavior available when needed.\n */\n liveReload?: boolean;\n /**\n * Skip semantic and Angular template diagnostics during compilation.\n * Defaults to `true`, or `false` with `compilation: 'ngp'`, which requires\n * a TypeScript 7 type checker (see `typeChecker`).\n */\n disableTypeChecking?: boolean;\n /**\n * TypeScript 7 type checker used with `compilation: 'ngp'`: `'tsgo'`\n * (default), `'tsrs'`, or a command serving the TypeScript 7 language\n * server over stdio (`args` defaults to `['--lsp', '--stdio']`).\n */\n typeChecker?: TypeCheckerOption;\n /**\n * Replace source files at build time, like `fileReplacements` in\n * `angular.json`.\n */\n fileReplacements?: FileReplacement[];\n /**\n * Opt into the fast compile path. Skips Angular's template type-checking\n * and routes compilation through an internal single-pass transform when\n * `compilation` is not specified.\n * Defaults to `false`.\n */\n fastCompile?: boolean;\n /**\n * Selects the compilation path, overriding fastCompile. Defaults to 'ngtsc';\n * 'ngp' is experimental and falls back to 'ngtsc' under Vitest's JIT default.\n */\n compilation?: 'ngtsc' | 'ngp';\n /**\n * Compilation output mode used when `fastCompile` is enabled.\n * - `'full'` (default): Emit final Ivy definitions for application builds.\n * - `'partial'`: Emit partial declarations for library publishing.\n */\n fastCompileMode?: 'full' | 'partial';\n /**\n * Enable debug logging for specific scopes.\n *\n * - `true` → enables all `analog:angular:*` scopes\n * - `string[]` → enables listed namespaces (e.g. `['analog:angular:hmr']`)\n * - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`\n * to restrict output to a specific Vite command (omit for both)\n *\n * Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`\n * (browser), using the `obug` convention.\n */\n debug?: DebugOption;\n}\n\nexport type AngularCompilationBackend =\n | 'ngtsc'\n | 'fast'\n | 'ngp'\n | 'compilation-api';\n\nexport interface AngularBuildContextOptions extends PluginOptions {\n /**\n * Explicit compiler backend selection when composing plugins directly.\n * Overrides `compilation` and `fastCompile` when set.\n */\n compilationBackend?: AngularCompilationBackend;\n /**\n * Target browser list used by `@angular/build` Compilation API.\n */\n supportedBrowsers?: string[];\n}\n\nexport interface NormalizedAngularOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n include: string[];\n liveReload: boolean;\n disableTypeChecking: boolean;\n typeChecker?: TypeCheckerOption;\n fileReplacements: FileReplacement[];\n compilation: AngularCompilationBackend;\n fastCompile: boolean;\n fastCompileMode: 'full' | 'partial';\n supportedBrowsers: string[];\n isTest: boolean;\n isStackBlitz: boolean;\n isAstroIntegration: boolean;\n isVitestVscode: boolean;\n}\n\nexport interface AngularCompilerCapabilities {\n readonly name: string;\n readonly getTsConfigPath: () => string;\n readonly getSourceMap?: (id: string) => string | undefined;\n readonly hasEmitted?: (id: string) => boolean;\n}\n\nexport type HmrIgnorePredicate = (file: string) => boolean;\n\nexport interface AngularHmrStore {\n readonly rootDir: string;\n readonly classNames: Map<string, string>;\n fileEmitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined;\n setFileEmitter(\n emitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined,\n ): void;\n toComponentUpdateId(fileId: string, className?: string): string;\n resolveComponentFileId(fileId: string): string;\n sendComponentUpdate(server: ViteDevServer, id: string): void;\n addIgnoreFilter(predicate: HmrIgnorePredicate): void;\n isIgnoredFile(file: string): boolean;\n clear(): void;\n}\n\nexport interface StylesheetTransformInput {\n data: string;\n containingFile: string;\n resourceFile?: string | null;\n order?: number;\n className?: string | null;\n readMissingResource?: boolean;\n eagerTransform?: (\n code: string,\n id: string,\n ) => Promise<{ code?: string } | null | undefined>;\n logger?: Logger;\n}\n\nexport interface AngularStylesheetService {\n registry: AnalogStylesheetRegistry | undefined;\n resetRegistry(externalize: boolean): AnalogStylesheetRegistry | undefined;\n ensureRegistry(): AnalogStylesheetRegistry;\n transformStylesheet(\n input: StylesheetTransformInput,\n ): Promise<{ content: string; externalized: boolean } | null>;\n resolveComponentStyleId(id: string): string | undefined;\n loadComponentStyle(id: string): string | undefined;\n refreshForFile(file: string): void;\n clear(): void;\n}\n\nconst ANGULAR_BUILD_CONTEXT_BRAND = Symbol.for(\n '@analogjs/vite-plugin-angular:build-context',\n);\n\nexport const ANGULAR_COMPILER_PLUGIN_NAMES: readonly string[] = [\n '@analogjs/vite-plugin-angular',\n '@analogjs/vite-plugin-angular-fast-compile',\n '@analogjs/vite-plugin-angular-compilation-api',\n '@analogjs/vite-plugin-angular-ngp',\n];\n\nexport interface AngularBuildContext {\n readonly kind: 'angular-build-context';\n readonly options: NormalizedAngularOptions;\n readonly tsconfigResolver: TsconfigResolver;\n readonly hmr: AngularHmrStore;\n readonly styles: AngularStylesheetService;\n compiler: AngularCompilerCapabilities | undefined;\n watchMode: boolean;\n testWatchMode: boolean;\n deferInitialCompilation: boolean;\n resolvedConfig: ResolvedConfig | undefined;\n tsConfigResolutionContext: TsConfigResolutionContext | null;\n stylePreprocessor: StylePreprocessor | undefined;\n configureStylesheetRegistry: StylesheetRegistryConfigurator | undefined;\n transformFilter: TransformFilter | undefined;\n componentRegistries: ComponentRegistryEntries[];\n externalizeStylesRequested: boolean;\n initConfig(\n config: UserConfig,\n env: { command: 'build' | 'serve'; mode?: string },\n ): TsConfigResolutionContext;\n setResolvedConfig(config: ResolvedConfig): void;\n resolveConfig(config: ResolvedConfig): Promise<AnalogIntegrations>;\n refreshIntegrations(config?: ResolvedConfig): Promise<AnalogIntegrations>;\n resolveTsConfigPath(): string;\n hasViteHmrTransport(): boolean;\n shouldEnableLiveReload(): boolean;\n shouldExternalizeStyles(): boolean;\n registerCompiler(capabilities: AngularCompilerCapabilities): void;\n}\n\nconst patchedLoggers = new WeakSet<Logger>();\n\n/**\n * Removes leading `/` and query string from a URL path.\n * e.g. `/foo.scss?direct&ngcomp=ng-c3153525609&e=0` returns `foo.scss`.\n */\nexport function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n // Defensive fallback: if the ID cannot be parsed as a URL (e.g., it\n // contains characters that are invalid in URLs but valid in file paths\n // on some platforms), strip the query string manually.\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n}\n\nexport function resolveComponentStyleId(\n id: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n): string | undefined {\n if (!isComponentStyleSheet(id)) {\n return undefined;\n }\n\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath = 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 debugStylesV('resolveId: kept preprocessed ID', { filename });\n return id;\n }\n\n const componentStyles = stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n debugStylesV('resolveId: mapped external stylesheet', {\n filename,\n resolvedPath: componentStyles,\n });\n return componentStyles + search;\n }\n\n debugStyles('resolveId: component stylesheet NOT FOUND in either map', {\n filename,\n inlineMapSize: stylesheetRegistry?.servedCount ?? 0,\n externalMapSize: stylesheetRegistry?.externalCount ?? 0,\n });\n\n return undefined;\n}\n\nexport function loadComponentStyle(\n id: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n): string | undefined {\n if (!isComponentStyleSheet(id)) {\n return undefined;\n }\n\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (!componentStyles) {\n return undefined;\n }\n\n stylesheetRegistry?.registerActiveRequest(id);\n const sourcePath =\n stylesheetRegistry?.resolveExternalSource(filename) ??\n stylesheetRegistry?.resolveExternalSource(filename.replace(/^\\//, '')) ??\n stylesheetRegistry?.getServedSourcePath(filename) ??\n stylesheetRegistry?.getServedSourcePath(filename.replace(/^\\//, ''));\n debugHmrV('stylesheet active request registered', {\n requestId: id,\n filename,\n sourcePath,\n trackedRequestIds:\n stylesheetRegistry?.getRequestIdsForSource(sourcePath ?? '') ?? [],\n });\n debugStylesV('load: served inline component stylesheet', {\n filename,\n requestId: id,\n ...describeStylesheetContent(componentStyles),\n });\n return componentStyles;\n}\n\nexport function isAngularBuildContext(\n value: unknown,\n): value is AngularBuildContext {\n return (\n typeof value === 'object' &&\n value !== null &&\n ANGULAR_BUILD_CONTEXT_BRAND in value\n );\n}\n\nexport function createAngularHmrStore(\n rootDir: string = process.cwd(),\n): AngularHmrStore {\n const classNames = new Map<string, string>();\n const ignoreFilters: HmrIgnorePredicate[] = [isIgnoredHmrFile];\n let activeEmitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined = () => undefined;\n\n return {\n rootDir,\n classNames,\n fileEmitter(file: string, className: string) {\n return activeEmitter(file, className);\n },\n setFileEmitter(emitter) {\n activeEmitter = emitter;\n },\n toComponentUpdateId(fileId: string, className?: string): string {\n const resolvedClassName = className ?? classNames.get(fileId) ?? '';\n return `${normalizePath(relative(rootDir, fileId))}@${resolvedClassName}`;\n },\n resolveComponentFileId(fileId: string): string {\n return normalizePath(resolve(rootDir, fileId));\n },\n sendComponentUpdate(server: ViteDevServer, id: string): void {\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 addIgnoreFilter(predicate: HmrIgnorePredicate): void {\n if (!ignoreFilters.includes(predicate)) {\n ignoreFilters.push(predicate);\n }\n },\n isIgnoredFile(file: string): boolean {\n return ignoreFilters.some((predicate) => predicate(file));\n },\n clear(): void {\n classNames.clear();\n },\n };\n}\n\nfunction resolveBackend(\n options: AngularBuildContextOptions | undefined,\n isTest: boolean,\n): AngularCompilationBackend {\n if (options?.compilationBackend) {\n return options.compilationBackend;\n }\n\n const compilation =\n options?.compilation === 'ngp' && !(isTest && options.jit === undefined)\n ? 'ngp'\n : 'ngtsc';\n\n if (compilation === 'ngp') {\n return 'ngp';\n }\n\n if (options?.compilation === undefined && options?.fastCompile) {\n return 'fast';\n }\n\n return 'ngtsc';\n}\n\nexport function createAngularBuildContext(\n options?: AngularBuildContextOptions,\n): AngularBuildContext {\n applyDebugOption(options?.debug, options?.workspaceRoot);\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const isAstroIntegration = process.env['ANALOG_ASTRO'] === 'true';\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n const compilation = resolveBackend(options, isTest);\n\n // Test mode under NgtscProgram disables WebSocket-based liveReload because\n // Vitest's runner does not consume Angular's component-update WS events.\n // Style externalization still checks `externalizeStylesRequested` separately.\n let liveReload =\n options?.liveReload ?? (compilation !== 'ngp' ? true : false);\n if (compilation === 'ngtsc' && isTest) {\n liveReload = false;\n debugHmr('hmr disabled', {\n angularVersion: angularFullVersion,\n isTest,\n });\n }\n\n const normalizedOptions: NormalizedAngularOptions = {\n tsconfigGetter: createTsConfigGetter(options?.tsconfig),\n workspaceRoot:\n options?.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options?.inlineStylesExtension ?? 'css',\n jit: typeof options?.jit !== 'undefined' ? options.jit : isTest,\n include: options?.include ?? [],\n liveReload,\n disableTypeChecking:\n options?.disableTypeChecking ?? (compilation !== 'ngp' ? true : false),\n typeChecker: options?.typeChecker,\n fileReplacements: options?.fileReplacements ?? [],\n compilation,\n fastCompile: compilation === 'fast',\n fastCompileMode: options?.fastCompileMode ?? 'full',\n supportedBrowsers: options?.supportedBrowsers ?? ['safari 15'],\n isTest,\n isStackBlitz,\n isAstroIntegration,\n isVitestVscode,\n };\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: normalizedOptions.workspaceRoot,\n include: normalizedOptions.include,\n liveReload: normalizedOptions.liveReload,\n isTest: normalizedOptions.isTest,\n });\n\n const hmr = createAngularHmrStore();\n\n let ctx!: AngularBuildContext;\n\n const styles: AngularStylesheetService = {\n registry: undefined,\n\n resetRegistry(externalize: boolean): AnalogStylesheetRegistry | undefined {\n styles.registry = externalize\n ? new AnalogStylesheetRegistry()\n : undefined;\n if (styles.registry) {\n ctx.configureStylesheetRegistry?.(styles.registry, {\n workspaceRoot: normalizedOptions.workspaceRoot,\n });\n }\n return styles.registry;\n },\n\n ensureRegistry(): AnalogStylesheetRegistry {\n if (!styles.registry) {\n styles.registry = new AnalogStylesheetRegistry();\n ctx.configureStylesheetRegistry?.(styles.registry, {\n workspaceRoot: normalizedOptions.workspaceRoot,\n });\n }\n return styles.registry;\n },\n\n async transformStylesheet(\n input: StylesheetTransformInput,\n ): Promise<{ content: string; externalized: boolean } | null> {\n let data = input.data;\n if (input.readMissingResource && input.resourceFile && !data) {\n data = readFileSync(input.resourceFile, 'utf-8');\n }\n\n const filename =\n input.resourceFile ??\n input.containingFile.replace(\n '.ts',\n `.${normalizedOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n ctx.stylePreprocessor,\n {\n filename,\n containingFile: input.containingFile,\n resourceFile: input.resourceFile ?? undefined,\n className: input.className ?? undefined,\n order: input.order,\n inline: !input.resourceFile,\n },\n );\n\n if (ctx.shouldExternalizeStyles() && styles.registry) {\n const stylesheetId = registerStylesheetContent(styles.registry, {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile: input.containingFile,\n className: input.className ?? undefined,\n order: input.order,\n inlineStylesExtension: normalizedOptions.inlineStylesExtension,\n resourceFile: input.resourceFile ?? undefined,\n });\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: input.resourceFile ?? '(inline)',\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n });\n\n return { content: stylesheetId, externalized: true };\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: input.resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult: { code?: string } | null | undefined;\n try {\n if (input.eagerTransform) {\n stylesheetResult = await input.eagerTransform(\n preprocessed.code,\n `${filename}?direct`,\n );\n } else if (ctx.resolvedConfig) {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n ctx.resolvedConfig,\n );\n }\n } catch (e) {\n debugStyles('stylesheet transform error', {\n filename,\n resourceFile: input.resourceFile ?? '(inline)',\n error: String(e),\n });\n warnStylesheetError(\n input.logger ?? ctx.resolvedConfig?.logger,\n filename,\n e,\n );\n }\n\n if (!stylesheetResult?.code) {\n return null;\n }\n\n return { content: stylesheetResult.code, externalized: false };\n },\n\n resolveComponentStyleId(id: string): string | undefined {\n return resolveComponentStyleId(id, styles.registry);\n },\n\n loadComponentStyle(id: string): string | undefined {\n return loadComponentStyle(id, styles.registry);\n },\n\n refreshForFile(file: string): void {\n refreshStylesheetRegistryForFile(\n file,\n styles.registry,\n ctx.stylePreprocessor,\n );\n },\n\n clear(): void {\n styles.registry = undefined;\n },\n };\n\n ctx = {\n kind: 'angular-build-context',\n options: normalizedOptions,\n tsconfigResolver,\n hmr,\n styles,\n compiler: undefined,\n watchMode: false,\n testWatchMode: isTestWatchMode(),\n deferInitialCompilation: isVitestVscode,\n resolvedConfig: undefined,\n tsConfigResolutionContext: null,\n stylePreprocessor: undefined,\n configureStylesheetRegistry: undefined,\n transformFilter: undefined,\n componentRegistries: [],\n externalizeStylesRequested: false,\n\n initConfig(config, { command }) {\n ctx.watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n ctx.tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n return ctx.tsConfigResolutionContext;\n },\n\n setResolvedConfig(config: ResolvedConfig) {\n ctx.resolvedConfig = config;\n ctx.tsConfigResolutionContext ??= {\n root: config.root || '.',\n isProd: isProdMode(config.mode),\n isLib: !!config?.build?.lib,\n };\n\n // Suppress noisy sourcemap warnings from Angular packages that ship\n // FESM bundles whose sourcemaps reference source files not included\n // in the npm package.\n if (config.logger?.warnOnce && !patchedLoggers.has(config.logger)) {\n patchedLoggers.add(config.logger);\n const originalWarnOnce = config.logger.warnOnce;\n config.logger.warnOnce = (msg, warnOptions) => {\n if (\n typeof msg === 'string' &&\n msg.includes('Sourcemap') &&\n msg.includes('node_modules')\n ) {\n return;\n }\n originalWarnOnce(msg, warnOptions);\n };\n }\n\n if (normalizedOptions.isTest) {\n const browser = (\n config as unknown as {\n test?: { browser?: { enabled?: boolean }; watch?: boolean };\n }\n ).test?.browser;\n ctx.deferInitialCompilation =\n normalizedOptions.isVitestVscode ||\n (!!browser &&\n (getBrowserModeCliOverride() ?? browser.enabled) === true);\n\n ctx.testWatchMode =\n !(config.server?.watch === null) ||\n (config as unknown as { test?: { watch?: boolean } }).test?.watch ===\n true ||\n ctx.testWatchMode;\n }\n },\n\n async resolveConfig(config: ResolvedConfig): Promise<AnalogIntegrations> {\n ctx.setResolvedConfig(config);\n return ctx.refreshIntegrations(config);\n },\n\n async refreshIntegrations(\n config?: ResolvedConfig,\n ): Promise<AnalogIntegrations> {\n const targetConfig = config ?? ctx.resolvedConfig;\n if (!targetConfig) {\n return {\n componentRegistries: [],\n include: [],\n externalizeStyles: false,\n };\n }\n\n const integrations = await discoverAnalogIntegrations(targetConfig);\n ctx.stylePreprocessor = integrations.stylePreprocessor;\n ctx.configureStylesheetRegistry =\n integrations.configureStylesheetRegistry;\n ctx.transformFilter = integrations.transformFilter;\n ctx.componentRegistries = integrations.componentRegistries;\n ctx.externalizeStylesRequested = integrations.externalizeStyles;\n ctx.tsconfigResolver.setIntegrationIncludes(integrations.include);\n return integrations;\n },\n\n resolveTsConfigPath(): string {\n const resolution = ctx.tsConfigResolutionContext ?? {\n root: ctx.resolvedConfig?.root || '.',\n isProd: isProdMode(ctx.resolvedConfig?.mode),\n isLib: !!ctx.resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n normalizedOptions.tsconfigGetter(),\n resolution.isProd,\n normalizedOptions.isTest,\n resolution.isLib,\n normalizedOptions.workspaceRoot,\n );\n },\n\n hasViteHmrTransport(): boolean {\n return ctx.resolvedConfig\n ? ctx.resolvedConfig.server?.hmr !== false\n : true;\n },\n\n shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = normalizedOptions.isTest\n ? ctx.testWatchMode\n : ctx.watchMode;\n return !!(\n effectiveWatchMode &&\n normalizedOptions.liveReload &&\n ctx.hasViteHmrTransport()\n );\n },\n\n shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = normalizedOptions.isTest\n ? ctx.testWatchMode\n : ctx.watchMode;\n if (!effectiveWatchMode) return false;\n return !!(ctx.shouldEnableLiveReload() || ctx.externalizeStylesRequested);\n },\n\n registerCompiler(capabilities: AngularCompilerCapabilities): void {\n ctx.compiler = capabilities;\n },\n };\n\n Object.defineProperty(ctx, ANGULAR_BUILD_CONTEXT_BRAND, {\n value: true,\n enumerable: false,\n });\n\n return ctx;\n}\n\nexport function ensureAngularBuildContext(\n ctxOrOptions?: AngularBuildContext | AngularBuildContextOptions,\n): AngularBuildContext {\n if (isAngularBuildContext(ctxOrOptions)) {\n return ctxOrOptions;\n }\n return createAngularBuildContext(ctxOrOptions);\n}\n\nexport function isAngularCompilerPlugin(plugin: Plugin): boolean {\n const api = plugin.api as\n | { angularCompiler?: boolean; getTsConfigPath?: unknown }\n | undefined;\n return (\n api?.angularCompiler === true ||\n ANGULAR_COMPILER_PLUGIN_NAMES.includes(plugin.name)\n );\n}\n\nexport function getAngularCompilerApi(\n plugins: readonly Plugin[],\n): AngularCompilerCapabilities | undefined {\n for (const plugin of plugins) {\n if (!isAngularCompilerPlugin(plugin)) {\n continue;\n }\n const api = plugin.api as Partial<AngularCompilerCapabilities> | undefined;\n if (typeof api?.getTsConfigPath === 'function') {\n return {\n name: plugin.name,\n getTsConfigPath: api.getTsConfigPath,\n getSourceMap: api.getSourceMap,\n hasEmitted: api.hasEmitted,\n };\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;AA+OA,IAAM,8BAA8B,OAAO,IACzC,6CACF;AAwCA,IAAM,iCAAiB,IAAI,QAAgB;;;;;AAM3C,SAAgB,oBAAoB,IAAoB;CACtD,IAAI;EACF,OAAO,IAAI,IAAI,IAAI,kBAAkB,CAAC,CAAC,SAAS,QAAQ,OAAO,EAAE;CACnE,QAAQ;EAIN,MAAM,aAAa,GAAG,QAAQ,GAAG;EAEjC,QADiB,cAAc,IAAI,GAAG,MAAM,GAAG,UAAU,IAAI,GAAA,CAC7C,QAAQ,OAAO,EAAE;CACnC;AACF;AAEA,SAAgB,wBACd,IACA,oBACoB;CACpB,IAAI,CAAC,sBAAsB,EAAE,GAC3B;CAGF,MAAM,WAAW,oBAAoB,EAAE;CACvC,MAAM,SAAS,IAAI,IAAI,IAAI,kBAAkB,CAAC,CAAC;CAC/C,MAAM,mBAAmB,oBAAoB,oBAAoB,QAAQ;CAEzE,IAAI,kBAAkB;EACpB,aAAa,iDAAiD;GAC5D;GACA,cAAc;EAChB,CAAC;EACD,OAAO,mBAAmB;CAC5B;CAEA,IAAI,oBAAoB,UAAU,QAAQ,GAAG;EAC3C,aAAa,mCAAmC,EAAE,SAAS,CAAC;EAC5D,OAAO;CACT;CAEA,MAAM,kBAAkB,oBAAoB,sBAAsB,QAAQ;CAC1E,IAAI,iBAAiB;EACnB,aAAa,yCAAyC;GACpD;GACA,cAAc;EAChB,CAAC;EACD,OAAO,kBAAkB;CAC3B;CAEA,YAAY,2DAA2D;EACrE;EACA,eAAe,oBAAoB,eAAe;EAClD,iBAAiB,oBAAoB,iBAAiB;CACxD,CAAC;AAGH;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/lib/angular-build-context.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport {\n normalizePath,\n preprocessCSS,\n type Logger,\n type Plugin,\n type ResolvedConfig,\n type UserConfig,\n type ViteDevServer,\n} from 'vite';\n\nimport {\n discoverAnalogIntegrations,\n type AnalogIntegrations,\n type ComponentRegistryEntries,\n type StylesheetRegistryConfigurator,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport { isComponentStyleSheet } from './encapsulation-plugin.js';\nimport type { EmitFileResult } from './models.js';\nimport type { FileReplacement } from './plugins/file-replacements.plugin.js';\nimport {\n normalizeStylesheetDependencies,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n} from './stylesheet-registry.js';\nimport {\n describeStylesheetContent,\n getBrowserModeCliOverride,\n isIgnoredHmrFile,\n isTestWatchMode,\n refreshStylesheetRegistryForFile,\n} from './utils/compilation-shared.js';\nimport {\n applyDebugOption,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from './utils/debug.js';\nimport { angularFullVersion } from './utils/devkit.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n createTsConfigGetter,\n getTsConfigPath,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { reportStylesheetError } from './utils/stylesheet-warning.js';\nimport { TsconfigResolver } from './utils/tsconfig-resolver.js';\n\nexport interface PluginOptions {\n /**\n * Path to the tsconfig used for compilation, or a function returning it.\n * Defaults to `tsconfig.app.json` (`tsconfig.lib.json` for libraries,\n * `tsconfig.spec.json` in tests).\n */\n tsconfig?: string | (() => string);\n /**\n * Absolute path to the workspace root. Defaults to `NX_WORKSPACE_ROOT`,\n * then `process.cwd()`.\n */\n workspaceRoot?: string;\n /**\n * Stylesheet extension used for inline component `styles`. Defaults to `css`.\n */\n inlineStylesExtension?: string;\n /**\n * Compile components in JIT mode. Defaults to `true` in tests and `false`\n * otherwise.\n */\n jit?: boolean;\n /**\n * Additional files to include in compilation, as globs relative to the\n * workspace root.\n */\n include?: string[];\n /**\n * Enables Analog's Angular live-reload/HMR pipeline during development/watch mode.\n *\n * This is separate from Vite's `server.hmr` option, which configures the\n * HMR client transport.\n *\n * Defaults to `true` for watch mode, or `false` with `compilation: 'ngp'`,\n * which reloads the page on every change unless this is `true`. Set to\n * `false` to disable Angular reload updates while keeping other stylesheet\n * externalization behavior available when needed.\n */\n liveReload?: boolean;\n /**\n * Skip semantic and Angular template diagnostics during compilation.\n * Defaults to `true`, or `false` with `compilation: 'ngp'`, which requires\n * a TypeScript 7 type checker (see `typeChecker`).\n */\n disableTypeChecking?: boolean;\n /**\n * TypeScript 7 type checker used with `compilation: 'ngp'`: `'tsgo'`\n * (default), `'tsrs'`, or a command serving the TypeScript 7 language\n * server over stdio (`args` defaults to `['--lsp', '--stdio']`).\n */\n typeChecker?: TypeCheckerOption;\n /**\n * Replace source files at build time, like `fileReplacements` in\n * `angular.json`.\n */\n fileReplacements?: FileReplacement[];\n /**\n * Opt into the fast compile path. Skips Angular's template type-checking\n * and routes compilation through an internal single-pass transform when\n * `compilation` is not specified.\n * Defaults to `false`.\n */\n fastCompile?: boolean;\n /**\n * Selects the compilation path, overriding fastCompile. Defaults to 'ngtsc';\n * 'ngp' is experimental and falls back to 'ngtsc' under Vitest's JIT default.\n */\n compilation?: 'ngtsc' | 'ngp';\n /**\n * Compilation output mode used when `fastCompile` is enabled.\n * - `'full'` (default): Emit final Ivy definitions for application builds.\n * - `'partial'`: Emit partial declarations for library publishing.\n */\n fastCompileMode?: 'full' | 'partial';\n /**\n * Enable debug logging for specific scopes.\n *\n * - `true` → enables all `analog:angular:*` scopes\n * - `string[]` → enables listed namespaces (e.g. `['analog:angular:hmr']`)\n * - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`\n * to restrict output to a specific Vite command (omit for both)\n *\n * Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`\n * (browser), using the `obug` convention.\n */\n debug?: DebugOption;\n}\n\nexport type AngularCompilationBackend =\n | 'ngtsc'\n | 'fast'\n | 'ngp'\n | 'compilation-api';\n\nexport interface AngularBuildContextOptions extends PluginOptions {\n /**\n * Explicit compiler backend selection when composing plugins directly.\n * Overrides `compilation` and `fastCompile` when set.\n */\n compilationBackend?: AngularCompilationBackend;\n /**\n * Target browser list used by `@angular/build` Compilation API.\n */\n supportedBrowsers?: string[];\n}\n\nexport interface NormalizedAngularOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n include: string[];\n liveReload: boolean;\n disableTypeChecking: boolean;\n typeChecker?: TypeCheckerOption;\n fileReplacements: FileReplacement[];\n compilation: AngularCompilationBackend;\n fastCompile: boolean;\n fastCompileMode: 'full' | 'partial';\n supportedBrowsers: string[];\n isTest: boolean;\n isStackBlitz: boolean;\n isAstroIntegration: boolean;\n isVitestVscode: boolean;\n}\n\nexport interface AngularCompilerCapabilities {\n readonly name: string;\n readonly getTsConfigPath: () => string;\n readonly getSourceMap?: (id: string) => string | undefined;\n readonly hasEmitted?: (id: string) => boolean;\n}\n\nexport type HmrIgnorePredicate = (file: string) => boolean;\n\nexport interface AngularHmrStore {\n readonly rootDir: string;\n readonly classNames: Map<string, string>;\n fileEmitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined;\n setFileEmitter(\n emitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined,\n ): void;\n toComponentUpdateId(fileId: string, className?: string): string;\n resolveComponentFileId(fileId: string): string;\n sendComponentUpdate(server: ViteDevServer, id: string): void;\n addIgnoreFilter(predicate: HmrIgnorePredicate): void;\n isIgnoredFile(file: string): boolean;\n clear(): void;\n}\n\nexport interface StylesheetTransformInput {\n data: string;\n containingFile: string;\n resourceFile?: string | null;\n order?: number;\n className?: string | null;\n readMissingResource?: boolean;\n eagerTransform?: (\n code: string,\n id: string,\n ) => Promise<{ code?: string } | null | undefined>;\n logger?: Logger;\n}\n\nexport interface AngularStylesheetService {\n registry: AnalogStylesheetRegistry | undefined;\n resetRegistry(externalize: boolean): AnalogStylesheetRegistry | undefined;\n ensureRegistry(): AnalogStylesheetRegistry;\n transformStylesheet(\n input: StylesheetTransformInput,\n ): Promise<{ content: string; externalized: boolean } | null>;\n resolveComponentStyleId(id: string): string | undefined;\n loadComponentStyle(id: string): string | undefined;\n refreshForFile(file: string): void;\n clear(): void;\n}\n\nconst ANGULAR_BUILD_CONTEXT_BRAND = Symbol.for(\n '@analogjs/vite-plugin-angular:build-context',\n);\n\nexport const ANGULAR_COMPILER_PLUGIN_NAMES: readonly string[] = [\n '@analogjs/vite-plugin-angular',\n '@analogjs/vite-plugin-angular-fast-compile',\n '@analogjs/vite-plugin-angular-compilation-api',\n '@analogjs/vite-plugin-angular-ngp',\n];\n\nexport interface AngularBuildContext {\n readonly kind: 'angular-build-context';\n readonly options: NormalizedAngularOptions;\n readonly tsconfigResolver: TsconfigResolver;\n readonly hmr: AngularHmrStore;\n readonly styles: AngularStylesheetService;\n compiler: AngularCompilerCapabilities | undefined;\n watchMode: boolean;\n testWatchMode: boolean;\n deferInitialCompilation: boolean;\n resolvedConfig: ResolvedConfig | undefined;\n tsConfigResolutionContext: TsConfigResolutionContext | null;\n stylePreprocessor: StylePreprocessor | undefined;\n configureStylesheetRegistry: StylesheetRegistryConfigurator | undefined;\n transformFilter: TransformFilter | undefined;\n componentRegistries: ComponentRegistryEntries[];\n externalizeStylesRequested: boolean;\n initConfig(\n config: UserConfig,\n env: { command: 'build' | 'serve'; mode?: string },\n ): TsConfigResolutionContext;\n setResolvedConfig(config: ResolvedConfig): void;\n resolveConfig(config: ResolvedConfig): Promise<AnalogIntegrations>;\n refreshIntegrations(config?: ResolvedConfig): Promise<AnalogIntegrations>;\n resolveTsConfigPath(): string;\n hasViteHmrTransport(): boolean;\n shouldEnableLiveReload(): boolean;\n shouldExternalizeStyles(): boolean;\n registerCompiler(capabilities: AngularCompilerCapabilities): void;\n}\n\nconst patchedLoggers = new WeakSet<Logger>();\n\n/**\n * Removes leading `/` and query string from a URL path.\n * e.g. `/foo.scss?direct&ngcomp=ng-c3153525609&e=0` returns `foo.scss`.\n */\nexport function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n // Defensive fallback: if the ID cannot be parsed as a URL (e.g., it\n // contains characters that are invalid in URLs but valid in file paths\n // on some platforms), strip the query string manually.\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n}\n\nexport function resolveComponentStyleId(\n id: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n): string | undefined {\n if (!isComponentStyleSheet(id)) {\n return undefined;\n }\n\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath = 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 debugStylesV('resolveId: kept preprocessed ID', { filename });\n return id;\n }\n\n const componentStyles = stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n debugStylesV('resolveId: mapped external stylesheet', {\n filename,\n resolvedPath: componentStyles,\n });\n return componentStyles + search;\n }\n\n debugStyles('resolveId: component stylesheet NOT FOUND in either map', {\n filename,\n inlineMapSize: stylesheetRegistry?.servedCount ?? 0,\n externalMapSize: stylesheetRegistry?.externalCount ?? 0,\n });\n\n return undefined;\n}\n\nexport function loadComponentStyle(\n id: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n): string | undefined {\n if (!isComponentStyleSheet(id)) {\n return undefined;\n }\n\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (!componentStyles) {\n return undefined;\n }\n\n stylesheetRegistry?.registerActiveRequest(id);\n const sourcePath =\n stylesheetRegistry?.resolveExternalSource(filename) ??\n stylesheetRegistry?.resolveExternalSource(filename.replace(/^\\//, '')) ??\n stylesheetRegistry?.getServedSourcePath(filename) ??\n stylesheetRegistry?.getServedSourcePath(filename.replace(/^\\//, ''));\n debugHmrV('stylesheet active request registered', {\n requestId: id,\n filename,\n sourcePath,\n trackedRequestIds:\n stylesheetRegistry?.getRequestIdsForSource(sourcePath ?? '') ?? [],\n });\n debugStylesV('load: served inline component stylesheet', {\n filename,\n requestId: id,\n ...describeStylesheetContent(componentStyles),\n });\n return componentStyles;\n}\n\nexport function isAngularBuildContext(\n value: unknown,\n): value is AngularBuildContext {\n return (\n typeof value === 'object' &&\n value !== null &&\n ANGULAR_BUILD_CONTEXT_BRAND in value\n );\n}\n\nexport function createAngularHmrStore(\n rootDir: string = process.cwd(),\n): AngularHmrStore {\n const classNames = new Map<string, string>();\n const ignoreFilters: HmrIgnorePredicate[] = [isIgnoredHmrFile];\n let activeEmitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined = () => undefined;\n\n return {\n rootDir,\n classNames,\n fileEmitter(file: string, className: string) {\n return activeEmitter(file, className);\n },\n setFileEmitter(emitter) {\n activeEmitter = emitter;\n },\n toComponentUpdateId(fileId: string, className?: string): string {\n const resolvedClassName = className ?? classNames.get(fileId) ?? '';\n return `${normalizePath(relative(rootDir, fileId))}@${resolvedClassName}`;\n },\n resolveComponentFileId(fileId: string): string {\n return normalizePath(resolve(rootDir, fileId));\n },\n sendComponentUpdate(server: ViteDevServer, id: string): void {\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 addIgnoreFilter(predicate: HmrIgnorePredicate): void {\n if (!ignoreFilters.includes(predicate)) {\n ignoreFilters.push(predicate);\n }\n },\n isIgnoredFile(file: string): boolean {\n return ignoreFilters.some((predicate) => predicate(file));\n },\n clear(): void {\n classNames.clear();\n },\n };\n}\n\nfunction resolveBackend(\n options: AngularBuildContextOptions | undefined,\n isTest: boolean,\n): AngularCompilationBackend {\n if (options?.compilationBackend) {\n return options.compilationBackend;\n }\n\n const compilation =\n options?.compilation === 'ngp' && !(isTest && options.jit === undefined)\n ? 'ngp'\n : 'ngtsc';\n\n if (compilation === 'ngp') {\n return 'ngp';\n }\n\n if (options?.compilation === undefined && options?.fastCompile) {\n return 'fast';\n }\n\n return 'ngtsc';\n}\n\nexport function createAngularBuildContext(\n options?: AngularBuildContextOptions,\n): AngularBuildContext {\n applyDebugOption(options?.debug, options?.workspaceRoot);\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const isAstroIntegration = process.env['ANALOG_ASTRO'] === 'true';\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n const compilation = resolveBackend(options, isTest);\n\n // Test mode under NgtscProgram disables WebSocket-based liveReload because\n // Vitest's runner does not consume Angular's component-update WS events.\n // Style externalization still checks `externalizeStylesRequested` separately.\n let liveReload =\n options?.liveReload ?? (compilation !== 'ngp' ? true : false);\n if (compilation === 'ngtsc' && isTest) {\n liveReload = false;\n debugHmr('hmr disabled', {\n angularVersion: angularFullVersion,\n isTest,\n });\n }\n\n const normalizedOptions: NormalizedAngularOptions = {\n tsconfigGetter: createTsConfigGetter(options?.tsconfig),\n workspaceRoot:\n options?.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options?.inlineStylesExtension ?? 'css',\n jit: typeof options?.jit !== 'undefined' ? options.jit : isTest,\n include: options?.include ?? [],\n liveReload,\n disableTypeChecking:\n options?.disableTypeChecking ?? (compilation !== 'ngp' ? true : false),\n typeChecker: options?.typeChecker,\n fileReplacements: options?.fileReplacements ?? [],\n compilation,\n fastCompile: compilation === 'fast',\n fastCompileMode: options?.fastCompileMode ?? 'full',\n supportedBrowsers: options?.supportedBrowsers ?? ['safari 15'],\n isTest,\n isStackBlitz,\n isAstroIntegration,\n isVitestVscode,\n };\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: normalizedOptions.workspaceRoot,\n include: normalizedOptions.include,\n liveReload: normalizedOptions.liveReload,\n isTest: normalizedOptions.isTest,\n });\n\n const hmr = createAngularHmrStore();\n\n let ctx!: AngularBuildContext;\n\n const styles: AngularStylesheetService = {\n registry: undefined,\n\n resetRegistry(externalize: boolean): AnalogStylesheetRegistry | undefined {\n styles.registry = externalize\n ? new AnalogStylesheetRegistry()\n : undefined;\n if (styles.registry) {\n ctx.configureStylesheetRegistry?.(styles.registry, {\n workspaceRoot: normalizedOptions.workspaceRoot,\n });\n }\n return styles.registry;\n },\n\n ensureRegistry(): AnalogStylesheetRegistry {\n if (!styles.registry) {\n styles.registry = new AnalogStylesheetRegistry();\n ctx.configureStylesheetRegistry?.(styles.registry, {\n workspaceRoot: normalizedOptions.workspaceRoot,\n });\n }\n return styles.registry;\n },\n\n async transformStylesheet(\n input: StylesheetTransformInput,\n ): Promise<{ content: string; externalized: boolean } | null> {\n let data = input.data;\n if (input.readMissingResource && input.resourceFile && !data) {\n data = readFileSync(input.resourceFile, 'utf-8');\n }\n\n const filename =\n input.resourceFile ??\n input.containingFile.replace(\n '.ts',\n `.${normalizedOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n ctx.stylePreprocessor,\n {\n filename,\n containingFile: input.containingFile,\n resourceFile: input.resourceFile ?? undefined,\n className: input.className ?? undefined,\n order: input.order,\n inline: !input.resourceFile,\n },\n );\n\n if (ctx.shouldExternalizeStyles() && styles.registry) {\n const stylesheetId = registerStylesheetContent(styles.registry, {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile: input.containingFile,\n className: input.className ?? undefined,\n order: input.order,\n inlineStylesExtension: normalizedOptions.inlineStylesExtension,\n resourceFile: input.resourceFile ?? undefined,\n });\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: input.resourceFile ?? '(inline)',\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n });\n\n return { content: stylesheetId, externalized: true };\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: input.resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult: { code?: string } | null | undefined;\n try {\n if (input.eagerTransform) {\n stylesheetResult = await input.eagerTransform(\n preprocessed.code,\n `${filename}?direct`,\n );\n } else if (ctx.resolvedConfig) {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n ctx.resolvedConfig,\n );\n }\n } catch (e) {\n debugStyles('stylesheet transform error', {\n filename,\n resourceFile: input.resourceFile ?? '(inline)',\n error: String(e),\n });\n reportStylesheetError(\n input.logger ?? ctx.resolvedConfig?.logger,\n filename,\n e,\n ctx.resolvedConfig?.command === 'build',\n );\n }\n\n if (!stylesheetResult?.code) {\n return null;\n }\n\n return { content: stylesheetResult.code, externalized: false };\n },\n\n resolveComponentStyleId(id: string): string | undefined {\n return resolveComponentStyleId(id, styles.registry);\n },\n\n loadComponentStyle(id: string): string | undefined {\n return loadComponentStyle(id, styles.registry);\n },\n\n refreshForFile(file: string): void {\n refreshStylesheetRegistryForFile(\n file,\n styles.registry,\n ctx.stylePreprocessor,\n );\n },\n\n clear(): void {\n styles.registry = undefined;\n },\n };\n\n ctx = {\n kind: 'angular-build-context',\n options: normalizedOptions,\n tsconfigResolver,\n hmr,\n styles,\n compiler: undefined,\n watchMode: false,\n testWatchMode: isTestWatchMode(),\n deferInitialCompilation: isVitestVscode,\n resolvedConfig: undefined,\n tsConfigResolutionContext: null,\n stylePreprocessor: undefined,\n configureStylesheetRegistry: undefined,\n transformFilter: undefined,\n componentRegistries: [],\n externalizeStylesRequested: false,\n\n initConfig(config, { command }) {\n ctx.watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n ctx.tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n return ctx.tsConfigResolutionContext;\n },\n\n setResolvedConfig(config: ResolvedConfig) {\n ctx.resolvedConfig = config;\n ctx.tsConfigResolutionContext ??= {\n root: config.root || '.',\n isProd: isProdMode(config.mode),\n isLib: !!config?.build?.lib,\n };\n\n // Suppress noisy sourcemap warnings from Angular packages that ship\n // FESM bundles whose sourcemaps reference source files not included\n // in the npm package.\n if (config.logger?.warnOnce && !patchedLoggers.has(config.logger)) {\n patchedLoggers.add(config.logger);\n const originalWarnOnce = config.logger.warnOnce;\n config.logger.warnOnce = (msg, warnOptions) => {\n if (\n typeof msg === 'string' &&\n msg.includes('Sourcemap') &&\n msg.includes('node_modules')\n ) {\n return;\n }\n originalWarnOnce(msg, warnOptions);\n };\n }\n\n if (normalizedOptions.isTest) {\n const browser = (\n config as unknown as {\n test?: { browser?: { enabled?: boolean }; watch?: boolean };\n }\n ).test?.browser;\n ctx.deferInitialCompilation =\n normalizedOptions.isVitestVscode ||\n (!!browser &&\n (getBrowserModeCliOverride() ?? browser.enabled) === true);\n\n ctx.testWatchMode =\n !(config.server?.watch === null) ||\n (config as unknown as { test?: { watch?: boolean } }).test?.watch ===\n true ||\n ctx.testWatchMode;\n }\n },\n\n async resolveConfig(config: ResolvedConfig): Promise<AnalogIntegrations> {\n ctx.setResolvedConfig(config);\n return ctx.refreshIntegrations(config);\n },\n\n async refreshIntegrations(\n config?: ResolvedConfig,\n ): Promise<AnalogIntegrations> {\n const targetConfig = config ?? ctx.resolvedConfig;\n if (!targetConfig) {\n return {\n componentRegistries: [],\n include: [],\n externalizeStyles: false,\n };\n }\n\n const integrations = await discoverAnalogIntegrations(targetConfig);\n ctx.stylePreprocessor = integrations.stylePreprocessor;\n ctx.configureStylesheetRegistry =\n integrations.configureStylesheetRegistry;\n ctx.transformFilter = integrations.transformFilter;\n ctx.componentRegistries = integrations.componentRegistries;\n ctx.externalizeStylesRequested = integrations.externalizeStyles;\n ctx.tsconfigResolver.setIntegrationIncludes(integrations.include);\n return integrations;\n },\n\n resolveTsConfigPath(): string {\n const resolution = ctx.tsConfigResolutionContext ?? {\n root: ctx.resolvedConfig?.root || '.',\n isProd: isProdMode(ctx.resolvedConfig?.mode),\n isLib: !!ctx.resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n normalizedOptions.tsconfigGetter(),\n resolution.isProd,\n normalizedOptions.isTest,\n resolution.isLib,\n normalizedOptions.workspaceRoot,\n );\n },\n\n hasViteHmrTransport(): boolean {\n return ctx.resolvedConfig\n ? ctx.resolvedConfig.server?.hmr !== false\n : true;\n },\n\n shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = normalizedOptions.isTest\n ? ctx.testWatchMode\n : ctx.watchMode;\n return !!(\n effectiveWatchMode &&\n normalizedOptions.liveReload &&\n ctx.hasViteHmrTransport()\n );\n },\n\n shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = normalizedOptions.isTest\n ? ctx.testWatchMode\n : ctx.watchMode;\n if (!effectiveWatchMode) return false;\n return !!(ctx.shouldEnableLiveReload() || ctx.externalizeStylesRequested);\n },\n\n registerCompiler(capabilities: AngularCompilerCapabilities): void {\n ctx.compiler = capabilities;\n },\n };\n\n Object.defineProperty(ctx, ANGULAR_BUILD_CONTEXT_BRAND, {\n value: true,\n enumerable: false,\n });\n\n return ctx;\n}\n\nexport function ensureAngularBuildContext(\n ctxOrOptions?: AngularBuildContext | AngularBuildContextOptions,\n): AngularBuildContext {\n if (isAngularBuildContext(ctxOrOptions)) {\n return ctxOrOptions;\n }\n return createAngularBuildContext(ctxOrOptions);\n}\n\nexport function isAngularCompilerPlugin(plugin: Plugin): boolean {\n const api = plugin.api as\n | { angularCompiler?: boolean; getTsConfigPath?: unknown }\n | undefined;\n return (\n api?.angularCompiler === true ||\n ANGULAR_COMPILER_PLUGIN_NAMES.includes(plugin.name)\n );\n}\n\nexport function getAngularCompilerApi(\n plugins: readonly Plugin[],\n): AngularCompilerCapabilities | undefined {\n for (const plugin of plugins) {\n if (!isAngularCompilerPlugin(plugin)) {\n continue;\n }\n const api = plugin.api as Partial<AngularCompilerCapabilities> | undefined;\n if (typeof api?.getTsConfigPath === 'function') {\n return {\n name: plugin.name,\n getTsConfigPath: api.getTsConfigPath,\n getSourceMap: api.getSourceMap,\n hasEmitted: api.hasEmitted,\n };\n }\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;AA+OA,IAAM,8BAA8B,OAAO,IACzC,6CACF;AAwCA,IAAM,iCAAiB,IAAI,QAAgB;;;;;AAM3C,SAAgB,oBAAoB,IAAoB;CACtD,IAAI;EACF,OAAO,IAAI,IAAI,IAAI,kBAAkB,CAAC,CAAC,SAAS,QAAQ,OAAO,EAAE;CACnE,QAAQ;EAIN,MAAM,aAAa,GAAG,QAAQ,GAAG;EAEjC,QADiB,cAAc,IAAI,GAAG,MAAM,GAAG,UAAU,IAAI,GAAA,CAC7C,QAAQ,OAAO,EAAE;CACnC;AACF;AAEA,SAAgB,wBACd,IACA,oBACoB;CACpB,IAAI,CAAC,sBAAsB,EAAE,GAC3B;CAGF,MAAM,WAAW,oBAAoB,EAAE;CACvC,MAAM,SAAS,IAAI,IAAI,IAAI,kBAAkB,CAAC,CAAC;CAC/C,MAAM,mBAAmB,oBAAoB,oBAAoB,QAAQ;CAEzE,IAAI,kBAAkB;EACpB,aAAa,iDAAiD;GAC5D;GACA,cAAc;EAChB,CAAC;EACD,OAAO,mBAAmB;CAC5B;CAEA,IAAI,oBAAoB,UAAU,QAAQ,GAAG;EAC3C,aAAa,mCAAmC,EAAE,SAAS,CAAC;EAC5D,OAAO;CACT;CAEA,MAAM,kBAAkB,oBAAoB,sBA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W;EACjB;CACF;CAEA,OAAO,eAAe,KAAK,6BAA6B;EACtD,OAAO;EACP,YAAY;CACd,CAAC;CAED,OAAO;AACT;AAEA,SAAgB,0BACd,cACqB;CACrB,IAAI,sBAAsB,YAAY,GACpC,OAAO;CAET,OAAO,0BAA0B,YAAY;AAC/C"}
@@ -208,7 +208,7 @@ function collectReExports(code, fileName, program) {
208
208
  for (const stmt of program.body || []) {
209
209
  if (stmt.type !== "ExportAllDeclaration" && stmt.type !== "ExportNamedDeclaration") continue;
210
210
  const specifier = stmt.source?.value;
211
- if (specifier) result.push(specifier);
211
+ if (specifier && !isTypeOnly(stmt)) result.push(specifier);
212
212
  }
213
213
  return result;
214
214
  }
@@ -229,10 +229,13 @@ function collectAllImports(code, fileName, program) {
229
229
  const result = [];
230
230
  for (const stmt of program.body || []) if (stmt.type === "ImportDeclaration" || stmt.type === "ExportAllDeclaration" || stmt.type === "ExportNamedDeclaration") {
231
231
  const specifier = stmt.source?.value;
232
- if (specifier) result.push(specifier);
232
+ if (specifier && !isTypeOnly(stmt)) result.push(specifier);
233
233
  }
234
234
  return result;
235
235
  }
236
+ function isTypeOnly(stmt) {
237
+ return stmt.importKind === "type" || stmt.exportKind === "type";
238
+ }
236
239
  function visitStatements(stmts, fileName, entries) {
237
240
  for (const stmt of stmts) {
238
241
  const decl = stmt.type === "ExportNamedDeclaration" || stmt.type === "ExportDefaultDeclaration" ? stmt.declaration : stmt;
@@ -1 +1 @@
1
- {"version":3,"file":"dts-reader.js","names":[],"sources":["../../../../src/lib/compiler/dts-reader.ts"],"sourcesContent":["import type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { RegistryEntry, RegistryInput } from './registry.js';\n\n/**\n * Scan a single .d.ts file and extract Angular directive/component/pipe\n * metadata from the static ɵdir / ɵcmp / ɵpipe type declarations.\n *\n * This mirrors what ngtsc's DtsMetadataReader does: it reads the type\n * parameters of ɵɵDirectiveDeclaration / ɵɵComponentDeclaration /\n * ɵɵPipeDeclaration to discover selectors, inputs, and outputs for\n * pre-compiled Angular packages.\n */\nexport function scanDtsFile(code: string, fileName: string): RegistryEntry[] {\n // Fast pre-filter — skip files that can't contain Angular declarations\n if (\n !code.includes('DirectiveDeclaration') &&\n !code.includes('ComponentDeclaration') &&\n !code.includes('PipeDeclaration') &&\n !code.includes('NgModuleDeclaration')\n )\n return [];\n\n const { program } = parseOxc(fileName, code);\n const entries: RegistryEntry[] = [];\n\n visitStatements(program.body, fileName, entries);\n return entries;\n}\n\n/**\n * Resolve a package's directory in node_modules, scan all its .d.ts files,\n * and return RegistryEntry[] for every Angular declaration found.\n *\n * @param packageName e.g. \"@angular/router\"\n * @param basePath project root (where node_modules lives)\n */\nexport function scanPackageDts(\n packageName: string,\n basePath: string,\n visited?: Set<string>,\n): RegistryEntry[] {\n // Walk up from basePath to find the nearest node_modules containing the package.\n // This handles monorepos where node_modules is at the workspace root,\n // not in the project subdirectory.\n let pkgDir = '';\n let searchBase = basePath;\n while (searchBase !== path.dirname(searchBase)) {\n const candidate = path.join(searchBase, 'node_modules', packageName);\n if (fs.existsSync(candidate)) {\n pkgDir = candidate;\n break;\n }\n searchBase = path.dirname(searchBase);\n }\n if (!pkgDir) return [];\n\n // Build a map from className → correct import path using package.json exports.\n // This handles packages with sub-entry points (e.g. @angular/material/tabs)\n // where re-exported classes must be imported from their origin entry point.\n const classToImportPath = buildClassToImportMap(packageName, pkgDir);\n\n // Check for a \"types\" directory first (Angular packages use this),\n // then fall back to the package root.\n const typesDir = path.join(pkgDir, 'types');\n const searchDir = fs.existsSync(typesDir) ? typesDir : pkgDir;\n\n const dtsFiles = collectDtsFiles(searchDir);\n const entries: RegistryEntry[] = [];\n // Packages re-exported by this package's NgModule declarations. A library\n // NgModule can re-export another package's module (e.g. BrowserModule exports\n // CommonModule), so those packages must be scanned too or their directives\n // (NgIf, NgForOf, …) never reach the registry.\n const referencedPackages = new Set<string>();\n\n for (const file of dtsFiles) {\n try {\n const code = fs.readFileSync(file, 'utf-8');\n const fileEntries = scanDtsFile(code, file);\n for (const entry of fileEntries) {\n entry.sourcePackage =\n classToImportPath.get(entry.className) ||\n subEntryFromFilePath(packageName, pkgDir, file) ||\n packageName;\n }\n entries.push(...fileEntries);\n // Only follow cross-package imports of declaration files that actually\n // contain an NgModule — those are the ones whose exports can pull in\n // another package's directives/pipes. This keeps the walk bounded.\n if (visited && fileEntries.some((e) => e.kind === 'ngmodule')) {\n for (const p of collectImportedPackages(code, file)) {\n referencedPackages.add(p);\n }\n }\n } catch {\n // Skip unreadable files\n }\n }\n\n if (visited) {\n for (const p of referencedPackages) {\n if (p === packageName || visited.has(p)) continue;\n visited.add(p);\n try {\n entries.push(...scanPackageDts(p, basePath, visited));\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n }\n\n return entries;\n}\n\n/**\n * Read package.json exports to build a map from class name to the correct\n * sub-entry import path (e.g. \"MatTabNav\" → \"@angular/material/tabs\").\n *\n * For each sub-entry that has a \"types\" field, the corresponding .d.ts file\n * is read to collect declared class names and re-exported names.\n */\nfunction buildClassToImportMap(\n packageName: string,\n pkgDir: string,\n): Map<string, string> {\n const map = new Map<string, string>();\n try {\n const pkgJson = JSON.parse(\n fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8'),\n );\n if (!pkgJson.exports) return map;\n\n for (const [key, value] of Object.entries(pkgJson.exports) as [\n string,\n any,\n ][]) {\n if (key !== '.' && !key.startsWith('./')) continue;\n // Resolve types from the export entry. Some packages declare\n // `types` only at the package root (top-level package.json `types`\n // field) rather than per-export, so fall back to that for `.`.\n let typesFile: string | undefined =\n typeof value === 'object' && value !== null && value.types;\n if (!typesFile && key === '.' && typeof pkgJson.types === 'string') {\n typesFile = pkgJson.types;\n }\n if (!typesFile) continue;\n\n // Root entry (`.`) maps classes to the bare package name; sub-entries\n // (`./tabs`) map to `${packageName}/tabs`. Mapping root-exported\n // classes prevents `subEntryFromFilePath` from deriving an invalid\n // subpath like `ngx-scrollbar/lib` for files that physically live in\n // a `lib/` subdirectory but are only re-exported from the root entry.\n const importPath =\n key === '.' ? packageName : packageName + '/' + key.slice(2);\n const fullTypesPath = path.resolve(pkgDir, typesFile);\n if (!fs.existsSync(fullTypesPath)) continue;\n\n collectExportedClassesFromDts(fullTypesPath, importPath, map);\n }\n } catch {\n // No package.json or no exports — fall back to packageName\n }\n return map;\n}\n\n/**\n * Read a `.d.ts` entry file and add every class it exports to `map`,\n * following `export * from './rel'` chains so re-exported classes from\n * physically nested files (e.g. `lib/foo.d.ts`) are still mapped to the\n * exporting entry's import path.\n *\n * Without this, packages whose root `index.d.ts` is just a barrel of\n * `export * from './lib/...'` would never get their classes mapped, and the\n * `subEntryFromFilePath` fallback would derive an invalid `${pkg}/lib`\n * import for files living under `lib/`.\n */\nfunction collectExportedClassesFromDts(\n filePath: string,\n importPath: string,\n map: Map<string, string>,\n visited: Set<string> = new Set(),\n): void {\n if (visited.has(filePath)) return;\n visited.add(filePath);\n let code: string;\n try {\n code = fs.readFileSync(filePath, 'utf-8');\n } catch {\n return;\n }\n\n let program: any;\n try {\n program = parseOxc(filePath, code).program;\n } catch {\n return;\n }\n\n const dir = path.dirname(filePath);\n for (const stmt of program.body || []) {\n // `declare class Foo` (top-level)\n if (stmt.type === 'ClassDeclaration' && stmt.id?.name) {\n map.set(stmt.id.name, importPath);\n continue;\n }\n\n // `export declare class Foo` / `export class Foo` /\n // `export { A, B as C } from '...'` / `export { A, B }`\n if (stmt.type === 'ExportNamedDeclaration') {\n if (\n stmt.declaration?.type === 'ClassDeclaration' &&\n stmt.declaration.id?.name\n ) {\n map.set(stmt.declaration.id.name, importPath);\n }\n for (const spec of stmt.specifiers || []) {\n // ExportSpecifier: { local, exported }\n const exportedNode = spec.exported;\n const exportedName =\n exportedNode?.type === 'Identifier'\n ? exportedNode.name\n : exportedNode?.type === 'Literal'\n ? exportedNode.value\n : undefined;\n if (typeof exportedName === 'string') {\n map.set(exportedName, importPath);\n }\n }\n continue;\n }\n\n // `export * from './rel'` and `export * as Ns from './rel'`\n if (stmt.type === 'ExportAllDeclaration') {\n const rel: string | undefined = stmt.source?.value;\n if (!rel || !rel.startsWith('.')) continue;\n // TypeScript preserves the original specifier text in emitted\n // `.d.ts` files, so NodeNext-style packages keep their `.js`\n // (or `.mjs`) extensions in re-exports — but the actual\n // declaration is at `foo.d.ts` / `foo/index.d.ts`. Strip the\n // ESM extension before probing.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const candidates = [\n path.resolve(dir, normalizedRel + '.d.ts'),\n path.resolve(dir, normalizedRel, 'index.d.ts'),\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n collectExportedClassesFromDts(candidate, importPath, map, visited);\n break;\n }\n }\n continue;\n }\n }\n}\n\n/**\n * Derive a sub-entry import path from a .d.ts file's location relative to the\n * package root. This handles older Angular packages that keep .d.ts files in\n * subdirectories (e.g. `@angular/material/tabs/index.d.ts`) instead of a\n * top-level `types/` folder.\n *\n * Returns `undefined` when no sub-entry can be determined (e.g. file is at the\n * package root, inside `types/`, or in a non-entry directory).\n */\nfunction subEntryFromFilePath(\n packageName: string,\n pkgDir: string,\n filePath: string,\n): string | undefined {\n const NON_ENTRY_DIRS = new Set([\n 'types',\n 'fesm2022',\n 'fesm2020',\n 'fesm2015',\n 'esm2022',\n 'esm2020',\n 'esm2015',\n 'bundles',\n 'schematics',\n 'node_modules',\n ]);\n const rel = path.relative(pkgDir, filePath);\n const segments = rel.split(path.sep);\n // File directly in pkgDir (no subdirectory) → no sub-entry\n if (segments.length < 2) return undefined;\n const firstDir = segments[0];\n // Skip internal/build directories and chunk files\n if (NON_ENTRY_DIRS.has(firstDir) || firstDir.startsWith('_'))\n return undefined;\n return packageName + '/' + firstDir;\n}\n\n/**\n * Parse a source file with OXC and return the set of bare-specifier package\n * names it imports (e.g. \"@angular/router\", \"rxjs\"). Relative imports are\n * skipped.\n */\nexport function collectImportedPackages(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): Set<string> {\n const packages = new Set<string>();\n program ??= parseOxc(fileName, code).program;\n\n for (const stmt of program.body) {\n if (stmt.type !== 'ImportDeclaration') continue;\n const specifier: string = stmt.source?.value;\n if (!specifier || specifier.startsWith('.')) continue;\n\n const parts = specifier.split('/');\n packages.add(\n specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0],\n );\n }\n\n return packages;\n}\n\n/**\n * Parse a source file with OXC and return the relative-path specifiers it\n * re-exports via `export * from './x'`, `export * as Ns from './x'`, or\n * `export { … } from './x'`. Bare-specifier re-exports are skipped.\n *\n * Used by the analog Vite plugin to walk library entry barrels at startup\n * (e.g. `helm/select/src/index.ts` → `./lib/hlm-select`) so the underlying\n * directive classes land in the registry before any consumer is compiled.\n */\nexport function collectRelativeReExports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n return collectReExports(code, fileName, program).filter((specifier) =>\n specifier.startsWith('.'),\n );\n}\n\n/**\n * Parse a source file with OXC and return every specifier it re-exports from\n * (relative AND bare) via `export * from` or `export { … } from`.\n */\nexport function collectReExports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseOxc(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type !== 'ExportAllDeclaration' &&\n stmt.type !== 'ExportNamedDeclaration'\n ) {\n continue;\n }\n // ExportNamedDeclaration without `source` is `export { x }` (no\n // re-export), which we don't care about here.\n const specifier: string | undefined = stmt.source?.value;\n if (specifier) result.push(specifier);\n }\n return result;\n}\n\n/**\n * Parse a source file with OXC and return every module specifier it imports or\n * re-exports from (relative AND bare), including `import`, `export * from`, and\n * `export { … } from`. Used to walk the transitive import graph at startup so\n * the registry contains components/directives/pipes/modules from files not\n * directly listed in tsconfig `files`/`include` (transitively-imported app\n * sources) or behind wildcard `paths` (workspace libraries).\n */\nexport function collectAllImports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseOxc(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type === 'ImportDeclaration' ||\n stmt.type === 'ExportAllDeclaration' ||\n stmt.type === 'ExportNamedDeclaration'\n ) {\n const specifier: string | undefined = stmt.source?.value;\n if (specifier) result.push(specifier);\n }\n }\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction visitStatements(\n stmts: any[],\n fileName: string,\n entries: RegistryEntry[],\n) {\n for (const stmt of stmts) {\n // Unwrap exports: `export declare class ...` / `export default class ...`\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? stmt.declaration\n : stmt;\n\n if (!decl) continue;\n\n // Recurse into `declare module \"...\" { ... }` blocks\n if (decl.type === 'TSModuleDeclaration' && decl.body?.body) {\n visitStatements(decl.body.body, fileName, entries);\n continue;\n }\n\n if (decl.type !== 'ClassDeclaration' || !decl.id?.name) continue;\n const className: string = decl.id.name;\n const members: any[] = decl.body?.body || [];\n\n for (const member of members) {\n if (member.type !== 'PropertyDefinition' || !member.static) continue;\n const propName: string | undefined = member.key?.name;\n\n // Read the type annotation: e.g. `i0.ɵɵDirectiveDeclaration<...>`\n const typeRef = member.typeAnnotation?.typeAnnotation;\n if (!typeRef || typeRef.type !== 'TSTypeReference') continue;\n\n const typeName = qualifiedName(typeRef.typeName);\n const typeParams: any[] | undefined = typeRef.typeArguments?.params;\n\n if (\n (propName === 'ɵdir' || propName === 'ɵcmp') &&\n (typeName.includes('DirectiveDeclaration') ||\n typeName.includes('ComponentDeclaration')) &&\n typeParams &&\n typeParams.length >= 5\n ) {\n const selector = literalString(typeParams[1]);\n if (!selector) continue;\n\n const inputs = extractInputs(typeParams[3]);\n const outputs = extractOutputs(typeParams[4]);\n\n entries.push({\n selector: selector.split(',')[0].trim(),\n kind: propName === 'ɵcmp' ? 'component' : 'directive',\n fileName,\n className,\n ...(Object.keys(inputs).length > 0 ? { inputs } : {}),\n ...(Object.keys(outputs).length > 0 ? { outputs } : {}),\n });\n } else if (\n propName === 'ɵpipe' &&\n typeName.includes('PipeDeclaration') &&\n typeParams &&\n typeParams.length >= 2\n ) {\n const pipeName = literalString(typeParams[1]);\n if (!pipeName) continue;\n\n entries.push({\n selector: pipeName,\n kind: 'pipe',\n pipeName,\n fileName,\n className,\n });\n } else if (\n propName === 'ɵmod' &&\n typeName.includes('NgModuleDeclaration') &&\n typeParams &&\n typeParams.length >= 4\n ) {\n // ɵɵNgModuleDeclaration<Module, Declarations, Imports, Exports>\n // Extract exported class names from the 4th type param (index 3).\n const exportsParam = typeParams[3];\n const exportedNames: string[] = [];\n if (exportsParam?.type === 'TSTupleType' && exportsParam.elementTypes) {\n for (const el of exportsParam.elementTypes) {\n if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'Identifier'\n ) {\n exportedNames.push(el.exprName.name);\n } else if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'TSQualifiedName'\n ) {\n // e.g. typeof i2.BidiModule → extract \"BidiModule\"\n const right = el.exprName.right;\n if (right?.type === 'Identifier') {\n exportedNames.push(right.name);\n }\n }\n }\n }\n entries.push({\n selector: className,\n kind: 'ngmodule',\n exports: exportedNames,\n fileName,\n className,\n });\n }\n }\n }\n}\n\n/**\n * Extract inputs from the type-argument at position [3].\n *\n * Handles two formats:\n * v16+: { \"prop\": { \"alias\": \"binding\"; \"required\": false; \"isSignal\"?: true } }\n * pre-v16: { \"prop\": \"binding\" }\n */\nfunction extractInputs(node: any): Record<string, RegistryInput> {\n const inputs: Record<string, RegistryInput> = {};\n if (node?.type !== 'TSTypeLiteral') return inputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const innerType = member.typeAnnotation?.typeAnnotation;\n if (!propName || !innerType) continue;\n\n if (innerType.type === 'TSTypeLiteral') {\n // v16+ object format\n let alias = propName;\n let required = false;\n let isSignal = false;\n\n for (const inner of innerType.members) {\n if (inner.type !== 'TSPropertySignature') continue;\n const key = keyName(inner.key);\n const val = inner.typeAnnotation?.typeAnnotation;\n if (!key || !val) continue;\n\n if (key === 'alias') {\n alias = literalString(val) ?? propName;\n } else if (key === 'required') {\n required = literalBoolean(val) === true;\n } else if (key === 'isSignal') {\n isSignal = literalBoolean(val) === true;\n }\n }\n\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal,\n required,\n };\n } else {\n // pre-v16 string format\n const alias = literalString(innerType);\n if (alias) {\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal: false,\n required: false,\n };\n }\n }\n }\n\n return inputs;\n}\n\n/**\n * Extract outputs from the type-argument at position [4].\n * Format: { \"propName\": \"eventName\" }\n */\nfunction extractOutputs(node: any): Record<string, string> {\n const outputs: Record<string, string> = {};\n if (node?.type !== 'TSTypeLiteral') return outputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const val = member.typeAnnotation?.typeAnnotation;\n if (!propName || !val) continue;\n\n const value = literalString(val);\n if (value) outputs[propName] = value;\n }\n\n return outputs;\n}\n\n/** Get the string name from a property key (Identifier or Literal). */\nfunction keyName(key: any): string | undefined {\n if (!key) return undefined;\n if (key.type === 'Identifier') return key.name;\n if (key.type === 'Literal' && typeof key.value === 'string') return key.value;\n return undefined;\n}\n\n/** Build a dotted name from an Identifier or TSQualifiedName. */\nfunction qualifiedName(node: any): string {\n if (!node) return '';\n if (node.type === 'Identifier') return node.name;\n if (node.type === 'TSQualifiedName')\n return qualifiedName(node.left) + '.' + qualifiedName(node.right);\n return '';\n}\n\n/** Extract a string value from a TSLiteralType node. */\nfunction literalString(node: any): string | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'string'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Extract a boolean value from a TSLiteralType node. */\nfunction literalBoolean(node: any): boolean | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'boolean'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Recursively collect all .d.ts files under a directory. */\nfunction collectDtsFiles(dir: string): string[] {\n const results: string[] = [];\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return results;\n }\n\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory() && entry.name !== 'node_modules') {\n results.push(...collectDtsFiles(full));\n } else if (entry.isFile() && entry.name.endsWith('.d.ts')) {\n results.push(full);\n }\n }\n\n return results;\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAgB,YAAY,MAAc,UAAmC;CAE3E,IACE,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,SAAS,iBAAiB,KAChC,CAAC,KAAK,SAAS,qBAAqB,GAEpC,OAAO,CAAC;CAEV,MAAM,EAAE,YAAY,SAAS,UAAU,IAAI;CAC3C,MAAM,UAA2B,CAAC;CAElC,gBAAgB,QAAQ,MAAM,UAAU,OAAO;CAC/C,OAAO;AACT;;;;;;;;AASA,SAAgB,eACd,aACA,UACA,SACiB;CAIjB,IAAI,SAAS;CACb,IAAI,aAAa;CACjB,OAAO,eAAe,OAAK,QAAQ,UAAU,GAAG;EAC9C,MAAM,YAAY,OAAK,KAAK,YAAY,gBAAgB,WAAW;EACnE,IAAI,GAAG,WAAW,SAAS,GAAG;GAC5B,SAAS;GACT;EACF;EACA,aAAa,OAAK,QAAQ,UAAU;CACtC;CACA,IAAI,CAAC,QAAQ,OAAO,CAAC;CAKrB,MAAM,oBAAoB,sBAAsB,aAAa,MAAM;CAInE,MAAM,WAAW,O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AAgB,IAAI,CAAC;OAChC,IAAI,MAAM,OAAO,KAAK,MAAM,KAAK,SAAS,OAAO,GACtD,QAAQ,KAAK,IAAI;CAErB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"dts-reader.js","names":[],"sources":["../../../../src/lib/compiler/dts-reader.ts"],"sourcesContent":["import type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { RegistryEntry, RegistryInput } from './registry.js';\n\n/**\n * Scan a single .d.ts file and extract Angular directive/component/pipe\n * metadata from the static ɵdir / ɵcmp / ɵpipe type declarations.\n *\n * This mirrors what ngtsc's DtsMetadataReader does: it reads the type\n * parameters of ɵɵDirectiveDeclaration / ɵɵComponentDeclaration /\n * ɵɵPipeDeclaration to discover selectors, inputs, and outputs for\n * pre-compiled Angular packages.\n */\nexport function scanDtsFile(code: string, fileName: string): RegistryEntry[] {\n // Fast pre-filter — skip files that can't contain Angular declarations\n if (\n !code.includes('DirectiveDeclaration') &&\n !code.includes('ComponentDeclaration') &&\n !code.includes('PipeDeclaration') &&\n !code.includes('NgModuleDeclaration')\n )\n return [];\n\n const { program } = parseOxc(fileName, code);\n const entries: RegistryEntry[] = [];\n\n visitStatements(program.body, fileName, entries);\n return entries;\n}\n\n/**\n * Resolve a package's directory in node_modules, scan all its .d.ts files,\n * and return RegistryEntry[] for every Angular declaration found.\n *\n * @param packageName e.g. \"@angular/router\"\n * @param basePath project root (where node_modules lives)\n */\nexport function scanPackageDts(\n packageName: string,\n basePath: string,\n visited?: Set<string>,\n): RegistryEntry[] {\n // Walk up from basePath to find the nearest node_modules containing the package.\n // This handles monorepos where node_modules is at the workspace root,\n // not in the project subdirectory.\n let pkgDir = '';\n let searchBase = basePath;\n while (searchBase !== path.dirname(searchBase)) {\n const candidate = path.join(searchBase, 'node_modules', packageName);\n if (fs.existsSync(candidate)) {\n pkgDir = candidate;\n break;\n }\n searchBase = path.dirname(searchBase);\n }\n if (!pkgDir) return [];\n\n // Build a map from className → correct import path using package.json exports.\n // This handles packages with sub-entry points (e.g. @angular/material/tabs)\n // where re-exported classes must be imported from their origin entry point.\n const classToImportPath = buildClassToImportMap(packageName, pkgDir);\n\n // Check for a \"types\" directory first (Angular packages use this),\n // then fall back to the package root.\n const typesDir = path.join(pkgDir, 'types');\n const searchDir = fs.existsSync(typesDir) ? typesDir : pkgDir;\n\n const dtsFiles = collectDtsFiles(searchDir);\n const entries: RegistryEntry[] = [];\n // Packages re-exported by this package's NgModule declarations. A library\n // NgModule can re-export another package's module (e.g. BrowserModule exports\n // CommonModule), so those packages must be scanned too or their directives\n // (NgIf, NgForOf, …) never reach the registry.\n const referencedPackages = new Set<string>();\n\n for (const file of dtsFiles) {\n try {\n const code = fs.readFileSync(file, 'utf-8');\n const fileEntries = scanDtsFile(code, file);\n for (const entry of fileEntries) {\n entry.sourcePackage =\n classToImportPath.get(entry.className) ||\n subEntryFromFilePath(packageName, pkgDir, file) ||\n packageName;\n }\n entries.push(...fileEntries);\n // Only follow cross-package imports of declaration files that actually\n // contain an NgModule — those are the ones whose exports can pull in\n // another package's directives/pipes. This keeps the walk bounded.\n if (visited && fileEntries.some((e) => e.kind === 'ngmodule')) {\n for (const p of collectImportedPackages(code, file)) {\n referencedPackages.add(p);\n }\n }\n } catch {\n // Skip unreadable files\n }\n }\n\n if (visited) {\n for (const p of referencedPackages) {\n if (p === packageName || visited.has(p)) continue;\n visited.add(p);\n try {\n entries.push(...scanPackageDts(p, basePath, visited));\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n }\n\n return entries;\n}\n\n/**\n * Read package.json exports to build a map from class name to the correct\n * sub-entry import path (e.g. \"MatTabNav\" → \"@angular/material/tabs\").\n *\n * For each sub-entry that has a \"types\" field, the corresponding .d.ts file\n * is read to collect declared class names and re-exported names.\n */\nfunction buildClassToImportMap(\n packageName: string,\n pkgDir: string,\n): Map<string, string> {\n const map = new Map<string, string>();\n try {\n const pkgJson = JSON.parse(\n fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8'),\n );\n if (!pkgJson.exports) return map;\n\n for (const [key, value] of Object.entries(pkgJson.exports) as [\n string,\n any,\n ][]) {\n if (key !== '.' && !key.startsWith('./')) continue;\n // Resolve types from the export entry. Some packages declare\n // `types` only at the package root (top-level package.json `types`\n // field) rather than per-export, so fall back to that for `.`.\n let typesFile: string | undefined =\n typeof value === 'object' && value !== null && value.types;\n if (!typesFile && key === '.' && typeof pkgJson.types === 'string') {\n typesFile = pkgJson.types;\n }\n if (!typesFile) continue;\n\n // Root entry (`.`) maps classes to the bare package name; sub-entries\n // (`./tabs`) map to `${packageName}/tabs`. Mapping root-exported\n // classes prevents `subEntryFromFilePath` from deriving an invalid\n // subpath like `ngx-scrollbar/lib` for files that physically live in\n // a `lib/` subdirectory but are only re-exported from the root entry.\n const importPath =\n key === '.' ? packageName : packageName + '/' + key.slice(2);\n const fullTypesPath = path.resolve(pkgDir, typesFile);\n if (!fs.existsSync(fullTypesPath)) continue;\n\n collectExportedClassesFromDts(fullTypesPath, importPath, map);\n }\n } catch {\n // No package.json or no exports — fall back to packageName\n }\n return map;\n}\n\n/**\n * Read a `.d.ts` entry file and add every class it exports to `map`,\n * following `export * from './rel'` chains so re-exported classes from\n * physically nested files (e.g. `lib/foo.d.ts`) are still mapped to the\n * exporting entry's import path.\n *\n * Without this, packages whose root `index.d.ts` is just a barrel of\n * `export * from './lib/...'` would never get their classes mapped, and the\n * `subEntryFromFilePath` fallback would derive an invalid `${pkg}/lib`\n * import for files living under `lib/`.\n */\nfunction collectExportedClassesFromDts(\n filePath: string,\n importPath: string,\n map: Map<string, string>,\n visited: Set<string> = new Set(),\n): void {\n if (visited.has(filePath)) return;\n visited.add(filePath);\n let code: string;\n try {\n code = fs.readFileSync(filePath, 'utf-8');\n } catch {\n return;\n }\n\n let program: any;\n try {\n program = parseOxc(filePath, code).program;\n } catch {\n return;\n }\n\n const dir = path.dirname(filePath);\n for (const stmt of program.body || []) {\n // `declare class Foo` (top-level)\n if (stmt.type === 'ClassDeclaration' && stmt.id?.name) {\n map.set(stmt.id.name, importPath);\n continue;\n }\n\n // `export declare class Foo` / `export class Foo` /\n // `export { A, B as C } from '...'` / `export { A, B }`\n if (stmt.type === 'ExportNamedDeclaration') {\n if (\n stmt.declaration?.type === 'ClassDeclaration' &&\n stmt.declaration.id?.name\n ) {\n map.set(stmt.declaration.id.name, importPath);\n }\n for (const spec of stmt.specifiers || []) {\n // ExportSpecifier: { local, exported }\n const exportedNode = spec.exported;\n const exportedName =\n exportedNode?.type === 'Identifier'\n ? exportedNode.name\n : exportedNode?.type === 'Literal'\n ? exportedNode.value\n : undefined;\n if (typeof exportedName === 'string') {\n map.set(exportedName, importPath);\n }\n }\n continue;\n }\n\n // `export * from './rel'` and `export * as Ns from './rel'`\n if (stmt.type === 'ExportAllDeclaration') {\n const rel: string | undefined = stmt.source?.value;\n if (!rel || !rel.startsWith('.')) continue;\n // TypeScript preserves the original specifier text in emitted\n // `.d.ts` files, so NodeNext-style packages keep their `.js`\n // (or `.mjs`) extensions in re-exports — but the actual\n // declaration is at `foo.d.ts` / `foo/index.d.ts`. Strip the\n // ESM extension before probing.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const candidates = [\n path.resolve(dir, normalizedRel + '.d.ts'),\n path.resolve(dir, normalizedRel, 'index.d.ts'),\n ];\n for (const candidate of candidates) {\n if (fs.existsSync(candidate)) {\n collectExportedClassesFromDts(candidate, importPath, map, visited);\n break;\n }\n }\n continue;\n }\n }\n}\n\n/**\n * Derive a sub-entry import path from a .d.ts file's location relative to the\n * package root. This handles older Angular packages that keep .d.ts files in\n * subdirectories (e.g. `@angular/material/tabs/index.d.ts`) instead of a\n * top-level `types/` folder.\n *\n * Returns `undefined` when no sub-entry can be determined (e.g. file is at the\n * package root, inside `types/`, or in a non-entry directory).\n */\nfunction subEntryFromFilePath(\n packageName: string,\n pkgDir: string,\n filePath: string,\n): string | undefined {\n const NON_ENTRY_DIRS = new Set([\n 'types',\n 'fesm2022',\n 'fesm2020',\n 'fesm2015',\n 'esm2022',\n 'esm2020',\n 'esm2015',\n 'bundles',\n 'schematics',\n 'node_modules',\n ]);\n const rel = path.relative(pkgDir, filePath);\n const segments = rel.split(path.sep);\n // File directly in pkgDir (no subdirectory) → no sub-entry\n if (segments.length < 2) return undefined;\n const firstDir = segments[0];\n // Skip internal/build directories and chunk files\n if (NON_ENTRY_DIRS.has(firstDir) || firstDir.startsWith('_'))\n return undefined;\n return packageName + '/' + firstDir;\n}\n\n/**\n * Parse a source file with OXC and return the set of bare-specifier package\n * names it imports (e.g. \"@angular/router\", \"rxjs\"). Relative imports are\n * skipped.\n */\nexport function collectImportedPackages(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): Set<string> {\n const packages = new Set<string>();\n program ??= parseOxc(fileName, code).program;\n\n for (const stmt of program.body) {\n if (stmt.type !== 'ImportDeclaration') continue;\n const specifier: string = stmt.source?.value;\n if (!specifier || specifier.startsWith('.')) continue;\n\n const parts = specifier.split('/');\n packages.add(\n specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0],\n );\n }\n\n return packages;\n}\n\n/**\n * Parse a source file with OXC and return the relative-path specifiers it\n * re-exports via `export * from './x'`, `export * as Ns from './x'`, or\n * `export { … } from './x'`. Bare-specifier re-exports are skipped.\n *\n * Used by the analog Vite plugin to walk library entry barrels at startup\n * (e.g. `helm/select/src/index.ts` → `./lib/hlm-select`) so the underlying\n * directive classes land in the registry before any consumer is compiled.\n */\nexport function collectRelativeReExports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n return collectReExports(code, fileName, program).filter((specifier) =>\n specifier.startsWith('.'),\n );\n}\n\n/**\n * Parse a source file with OXC and return every specifier it re-exports from\n * (relative AND bare) via `export * from` or `export { … } from`.\n */\nexport function collectReExports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseOxc(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type !== 'ExportAllDeclaration' &&\n stmt.type !== 'ExportNamedDeclaration'\n ) {\n continue;\n }\n // ExportNamedDeclaration without `source` is `export { x }` (no\n // re-export), which we don't care about here.\n const specifier: string | undefined = stmt.source?.value;\n if (specifier && !isTypeOnly(stmt)) result.push(specifier);\n }\n return result;\n}\n\n/**\n * Parse a source file with OXC and return every module specifier it imports or\n * re-exports from (relative AND bare), including `import`, `export * from`, and\n * `export { … } from`. Used to walk the transitive import graph at startup so\n * the registry contains components/directives/pipes/modules from files not\n * directly listed in tsconfig `files`/`include` (transitively-imported app\n * sources) or behind wildcard `paths` (workspace libraries).\n */\nexport function collectAllImports(\n code: string,\n fileName: string,\n program?: ReturnType<typeof parseSync>['program'],\n): string[] {\n if (!program) {\n try {\n program = parseOxc(fileName, code).program;\n } catch {\n return [];\n }\n }\n const result: string[] = [];\n for (const stmt of program.body || []) {\n if (\n stmt.type === 'ImportDeclaration' ||\n stmt.type === 'ExportAllDeclaration' ||\n stmt.type === 'ExportNamedDeclaration'\n ) {\n const specifier: string | undefined = stmt.source?.value;\n if (specifier && !isTypeOnly(stmt)) result.push(specifier);\n }\n }\n return result;\n}\n\nfunction isTypeOnly(stmt: any): boolean {\n return stmt.importKind === 'type' || stmt.exportKind === 'type';\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\nfunction visitStatements(\n stmts: any[],\n fileName: string,\n entries: RegistryEntry[],\n) {\n for (const stmt of stmts) {\n // Unwrap exports: `export declare class ...` / `export default class ...`\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? stmt.declaration\n : stmt;\n\n if (!decl) continue;\n\n // Recurse into `declare module \"...\" { ... }` blocks\n if (decl.type === 'TSModuleDeclaration' && decl.body?.body) {\n visitStatements(decl.body.body, fileName, entries);\n continue;\n }\n\n if (decl.type !== 'ClassDeclaration' || !decl.id?.name) continue;\n const className: string = decl.id.name;\n const members: any[] = decl.body?.body || [];\n\n for (const member of members) {\n if (member.type !== 'PropertyDefinition' || !member.static) continue;\n const propName: string | undefined = member.key?.name;\n\n // Read the type annotation: e.g. `i0.ɵɵDirectiveDeclaration<...>`\n const typeRef = member.typeAnnotation?.typeAnnotation;\n if (!typeRef || typeRef.type !== 'TSTypeReference') continue;\n\n const typeName = qualifiedName(typeRef.typeName);\n const typeParams: any[] | undefined = typeRef.typeArguments?.params;\n\n if (\n (propName === 'ɵdir' || propName === 'ɵcmp') &&\n (typeName.includes('DirectiveDeclaration') ||\n typeName.includes('ComponentDeclaration')) &&\n typeParams &&\n typeParams.length >= 5\n ) {\n const selector = literalString(typeParams[1]);\n if (!selector) continue;\n\n const inputs = extractInputs(typeParams[3]);\n const outputs = extractOutputs(typeParams[4]);\n\n entries.push({\n selector: selector.split(',')[0].trim(),\n kind: propName === 'ɵcmp' ? 'component' : 'directive',\n fileName,\n className,\n ...(Object.keys(inputs).length > 0 ? { inputs } : {}),\n ...(Object.keys(outputs).length > 0 ? { outputs } : {}),\n });\n } else if (\n propName === 'ɵpipe' &&\n typeName.includes('PipeDeclaration') &&\n typeParams &&\n typeParams.length >= 2\n ) {\n const pipeName = literalString(typeParams[1]);\n if (!pipeName) continue;\n\n entries.push({\n selector: pipeName,\n kind: 'pipe',\n pipeName,\n fileName,\n className,\n });\n } else if (\n propName === 'ɵmod' &&\n typeName.includes('NgModuleDeclaration') &&\n typeParams &&\n typeParams.length >= 4\n ) {\n // ɵɵNgModuleDeclaration<Module, Declarations, Imports, Exports>\n // Extract exported class names from the 4th type param (index 3).\n const exportsParam = typeParams[3];\n const exportedNames: string[] = [];\n if (exportsParam?.type === 'TSTupleType' && exportsParam.elementTypes) {\n for (const el of exportsParam.elementTypes) {\n if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'Identifier'\n ) {\n exportedNames.push(el.exprName.name);\n } else if (\n el.type === 'TSTypeQuery' &&\n el.exprName?.type === 'TSQualifiedName'\n ) {\n // e.g. typeof i2.BidiModule → extract \"BidiModule\"\n const right = el.exprName.right;\n if (right?.type === 'Identifier') {\n exportedNames.push(right.name);\n }\n }\n }\n }\n entries.push({\n selector: className,\n kind: 'ngmodule',\n exports: exportedNames,\n fileName,\n className,\n });\n }\n }\n }\n}\n\n/**\n * Extract inputs from the type-argument at position [3].\n *\n * Handles two formats:\n * v16+: { \"prop\": { \"alias\": \"binding\"; \"required\": false; \"isSignal\"?: true } }\n * pre-v16: { \"prop\": \"binding\" }\n */\nfunction extractInputs(node: any): Record<string, RegistryInput> {\n const inputs: Record<string, RegistryInput> = {};\n if (node?.type !== 'TSTypeLiteral') return inputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const innerType = member.typeAnnotation?.typeAnnotation;\n if (!propName || !innerType) continue;\n\n if (innerType.type === 'TSTypeLiteral') {\n // v16+ object format\n let alias = propName;\n let required = false;\n let isSignal = false;\n\n for (const inner of innerType.members) {\n if (inner.type !== 'TSPropertySignature') continue;\n const key = keyName(inner.key);\n const val = inner.typeAnnotation?.typeAnnotation;\n if (!key || !val) continue;\n\n if (key === 'alias') {\n alias = literalString(val) ?? propName;\n } else if (key === 'required') {\n required = literalBoolean(val) === true;\n } else if (key === 'isSignal') {\n isSignal = literalBoolean(val) === true;\n }\n }\n\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal,\n required,\n };\n } else {\n // pre-v16 string format\n const alias = literalString(innerType);\n if (alias) {\n inputs[propName] = {\n classPropertyName: propName,\n bindingPropertyName: alias,\n isSignal: false,\n required: false,\n };\n }\n }\n }\n\n return inputs;\n}\n\n/**\n * Extract outputs from the type-argument at position [4].\n * Format: { \"propName\": \"eventName\" }\n */\nfunction extractOutputs(node: any): Record<string, string> {\n const outputs: Record<string, string> = {};\n if (node?.type !== 'TSTypeLiteral') return outputs;\n\n for (const member of node.members) {\n if (member.type !== 'TSPropertySignature') continue;\n const propName = keyName(member.key);\n const val = member.typeAnnotation?.typeAnnotation;\n if (!propName || !val) continue;\n\n const value = literalString(val);\n if (value) outputs[propName] = value;\n }\n\n return outputs;\n}\n\n/** Get the string name from a property key (Identifier or Literal). */\nfunction keyName(key: any): string | undefined {\n if (!key) return undefined;\n if (key.type === 'Identifier') return key.name;\n if (key.type === 'Literal' && typeof key.value === 'string') return key.value;\n return undefined;\n}\n\n/** Build a dotted name from an Identifier or TSQualifiedName. */\nfunction qualifiedName(node: any): string {\n if (!node) return '';\n if (node.type === 'Identifier') return node.name;\n if (node.type === 'TSQualifiedName')\n return qualifiedName(node.left) + '.' + qualifiedName(node.right);\n return '';\n}\n\n/** Extract a string value from a TSLiteralType node. */\nfunction literalString(node: any): string | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'string'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Extract a boolean value from a TSLiteralType node. */\nfunction literalBoolean(node: any): boolean | undefined {\n if (\n node?.type === 'TSLiteralType' &&\n node.literal?.type === 'Literal' &&\n typeof node.literal.value === 'boolean'\n ) {\n return node.literal.value;\n }\n return undefined;\n}\n\n/** Recursively collect all .d.ts files under a directory. */\nfunction collectDtsFiles(dir: string): string[] {\n const results: string[] = [];\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(dir, { withFileTypes: true });\n } catch {\n return results;\n }\n\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory() && entry.name !== 'node_modules') {\n results.push(...collectDtsFiles(full));\n } else if (entry.isFile() && entry.name.endsWith('.d.ts')) {\n results.push(full);\n }\n }\n\n return results;\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAgB,YAAY,MAAc,UAAmC;CAE3E,IACE,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,SAAS,sBAAsB,KACrC,CAAC,KAAK,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I,KAAK,SAAS,mBAChB,OAAO,cAAc,KAAK,IAAI,IAAI,MAAM,cAAc,KAAK,KAAK;CAClE,OAAO;AACT;;AAGA,SAAS,cAAc,MAA+B;CACpD,IACE,MAAM,SAAS,mBACf,KAAK,SAAS,SAAS,aACvB,OAAO,KAAK,QAAQ,UAAU,UAE9B,OAAO,KAAK,QAAQ;AAGxB;;AAGA,SAAS,eAAe,MAAgC;CACtD,IACE,MAAM,SAAS,mBACf,KAAK,SAAS,SAAS,aACvB,OAAO,KAAK,QAAQ,UAAU,WAE9B,OAAO,KAAK,QAAQ;AAGxB;;AAGA,SAAS,gBAAgB,KAAuB;CAC9C,MAAM,UAAoB,CAAC;CAC3B,IAAI;CACJ,IAAI;EACF,UAAU,GAAG,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC;CACvD,QAAQ;EACN,OAAO;CACT;CAEA,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,OAAK,KAAK,KAAK,MAAM,IAAI;EACtC,IAAI,MAAM,YAAY,KAAK,MAAM,SAAS,gBACxC,QAAQ,KAAK,GAAG,gBAAgB,IAAI,CAAC;OAChC,IAAI,MAAM,OAAO,KAAK,MAAM,KAAK,SAAS,OAAO,GACtD,QAAQ,KAAK,IAAI;CAErB;CAEA,OAAO;AACT"}
@@ -3,7 +3,7 @@ import { preprocessStylesheet } from "./stylesheet-registry.js";
3
3
  import { isIgnoredHmrFile } from "./utils/compilation-shared.js";
4
4
  import { isRolldown } from "./utils/rolldown.js";
5
5
  import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX, createDepOptimizerConfig, getTsConfigPath, isProdMode } from "./utils/plugin-config.js";
6
- import { warnStylesheetError } from "./utils/stylesheet-warning.js";
6
+ import { reportStylesheetError } from "./utils/stylesheet-warning.js";
7
7
  import { TsconfigResolver } from "./utils/tsconfig-resolver.js";
8
8
  import { createAngularBuildContext, isAngularBuildContext } from "./angular-build-context.js";
9
9
  import { releaseCssPreprocessorWorkers } from "./utils/css-preprocessor-workers.js";
@@ -377,7 +377,7 @@ function fastCompilePlugin(optionsOrCtx) {
377
377
  const processed = await preprocessCSS(preprocessed, stylePath, activeConfig);
378
378
  resolvedInlineStyles.set(i, processed.code);
379
379
  } catch (e) {
380
- warnStylesheetError(activeConfig?.logger, stylePath, e);
380
+ reportStylesheetError(activeConfig?.logger, stylePath, e, activeConfig?.command === "build");
381
381
  }
382
382
  }
383
383
  if (resolvedInlineStyles.size === 0) resolvedInlineStyles = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"fast-compile-plugin.js","names":[],"sources":["../../../src/lib/fast-compile-plugin.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './compiler/utils.js';\nimport * as vite from 'vite';\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n compile,\n scanFile,\n declaresNonStandaloneComponent,\n scanPackageDts,\n collectImportedPackages,\n collectRelativeReExports,\n collectReExports,\n collectAllImports,\n jitTransform,\n inlineResourceUrls,\n extractInlineStyles,\n generateHmrCode,\n debugRegistry,\n ANGULAR_DECORATOR_CALL_RE,\n type ComponentRegistry,\n} from './compiler/index.js';\nimport { warnStylesheetError } from './utils/stylesheet-warning.js';\n\nimport {\n TS_EXT_REGEX,\n EXCLUDED_TS_EXT_REGEX,\n getTsConfigPath,\n createDepOptimizerConfig,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport { TsconfigResolver } from './utils/tsconfig-resolver.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nexport interface FastCompilePluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n fastCompileMode?: 'full' | 'partial';\n disableTypeChecking?: boolean;\n typeChecker?: TypeCheckerOption;\n include?: string[];\n}\n\nfunction isFastCompilePluginOptions(\n value: unknown,\n): value is FastCompilePluginOptions {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isAngularBuildContext(value) &&\n 'tsconfigGetter' in value &&\n typeof (value as FastCompilePluginOptions).tsconfigGetter === 'function'\n );\n}\n\ntype ResolveImport = (spec: string, importer: string) => Promise<string | null>;\n\n/**\n * Directory that `compilerOptions.paths` targets resolve against. Mirrors\n * TypeScript: `baseUrl` when set, otherwise the directory of the config\n * that declares `paths` (`pathsBasePath`, since `baseUrl` is optional\n * from TS 4.1).\n */\nexport function getPathsBasePath(\n options: { baseUrl?: string; pathsBasePath?: string } | undefined,\n fallback: string,\n): string {\n return options?.baseUrl ?? options?.pathsBasePath ?? fallback;\n}\n\nexport function fastCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompilePluginOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n ...optionsOrCtx,\n compilationBackend: 'fast',\n });\n\n const pluginOptions: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n const tsconfigResolver =\n sharedCtx?.tsconfigResolver ??\n new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include ?? [],\n liveReload: pluginOptions.liveReload,\n isTest: pluginOptions.isTest,\n });\n\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // fast-compile plugin state\n const registry: ComponentRegistry = new Map();\n const resourceToSource = new Map<string, string>();\n const scannedDtsPackages = new Set<string>();\n const emittedMaps = new Map<string, string>();\n let projectRoot = '';\n let useDefineForClassFields = true;\n let tsConfig: ReturnType<typeof compilerCli.readConfiguration>;\n\n // Files scanned on demand (mapped to the barrel chain they pulled in), which\n // modules were compiled against each scanned file, and the one-time\n // whole-project scan non-standalone components fall back to.\n const lazyScans = new Map<string, Promise<Set<string>>>();\n const importersByFile = new Map<string, Set<string>>();\n let projectScan: Promise<void> | undefined;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code =\n fileContents?.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents?.set(file, code);\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: failed to read %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return;\n }\n // Single parse shared by scanFile and collectRelativeReExports. On a\n // parse error each consumer re-parses on its own, preserving their\n // individual failure semantics (scanFile throws past its pre-filter;\n // collectRelativeReExports swallows and returns []).\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults?.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults?.set(file, entries);\n }\n for (const entry of entries) {\n // At buildStart we want stable registry entries (don't overwrite\n // an earlier scan with a barrel re-scan); HMR explicitly asks\n // for overwrite so updated metadata replaces stale entries.\n if (overwrite || !registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n // Collect every relative re-export specifier via OXC AST so\n // recursive scans can't trip over each other (a shared `/g` regex\n // would have its `lastIndex` reset by each recursive call and\n // silently skip half of an outer barrel's re-exports, which\n // previously left directives like `HlmRadioGroup` unregistered).\n const dir = dirname(file);\n for (const rel of collectRelativeReExports(code, file, program)) {\n // NodeNext-style libraries write `export * from './foo.js'`\n // even though the source is `./foo.ts`. Strip the ESM\n // extension before probing or the candidates would be\n // `foo.js.ts` / `foo.js/index.ts`, which never exist.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const reExportCandidates = [\n resolve(dir, normalizedRel + '.ts'),\n resolve(dir, normalizedRel, 'index.ts'),\n ];\n let resolved = false;\n for (const candidate of reExportCandidates) {\n try {\n await fsPromises.access(candidate);\n await scanBarrelExports(\n candidate,\n visited,\n overwrite,\n fileContents,\n scanResults,\n );\n resolved = true;\n break;\n } catch {\n // try next candidate\n }\n }\n if (!resolved && debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: %s re-export %s did not resolve to %o',\n file,\n rel,\n reExportCandidates,\n );\n }\n }\n }\n\n async function initFastCompile(): Promise<void> {\n emittedMaps.clear();\n if (pluginOptions.jit) return; // JIT: no registry scan needed\n\n registry.clear();\n scannedDtsPackages.clear();\n lazyScans.clear();\n importersByFile.clear();\n projectScan = undefined;\n const resolvedTsConfigPath = resolveTsConfigPath();\n projectRoot = dirname(resolvedTsConfigPath);\n tsConfig = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = tsConfig.options?.useDefineForClassFields ?? true;\n }\n\n /** Scan all source files reachable from the tsconfig into the registry. */\n async function scanProject(): Promise<void> {\n const config = tsConfig;\n const extraIncludes = tsconfigResolver.ensureIncludeCache();\n // Collect candidate files: tsconfig rootNames PLUS explicit/integration\n // include globs PLUS the entry points named in `compilerOptions.paths`.\n // App tsconfigs typically only include the app's own sources, so workspace\n // library entry barrels (e.g. `HlmSelectImports = [HlmSelect,\n // HlmSelectContent, ...] as const`) live outside `rootNames` and would\n // otherwise miss the initial scan. The compiler then can't see that\n // `HlmSelectImports` is a tuple barrel and emits the bare identifier into\n // the parent component's `dependencies()` list, where Angular's runtime\n // silently drops it because arrays don't have a directive def.\n const candidates = new Set<string>([...config.rootNames, ...extraIncludes]);\n const tsPaths = config.options?.paths;\n const baseUrl = getPathsBasePath(config.options, projectRoot);\n // Cold-start dedup caches shared by the three scan phases below\n // (candidates scan, walkImports, scanBarrelExports). Scoped to this\n // init call only — HMR/watcher re-scans must hit disk fresh.\n const fileContents = new Map<string, string>();\n const scanResults = new Map<string, ReturnType<typeof scanFile>>();\n if (tsPaths) {\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n // Skip wildcard patterns — entry barrels are normally exact\n // file paths like \"libs/helm/select/src/index.ts\".\n if (target.includes('*')) continue;\n candidates.add(resolve(baseUrl, target));\n }\n }\n }\n const results = await Promise.all(\n Array.from(candidates).map(async (file) => {\n try {\n const code = await fsPromises.readFile(file, 'utf-8');\n fileContents.set(file, code);\n const entries = scanFile(code, file);\n scanResults.set(file, entries);\n return entries;\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'initFastCompile: skipping unreadable %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return []; // Skip unreadable files\n }\n }),\n );\n\n for (const entries of results) {\n for (const entry of entries) {\n registry.set(entry.className, entry);\n }\n }\n\n // Walk the transitive import graph from the root files so the registry also\n // contains declarations that live in files not directly in tsconfig\n // `files`/`include` (transitively-imported app sources) and in workspace\n // libraries reached through wildcard `paths` (e.g. `@bitwarden/*`). Without\n // this, a non-standalone component's owning module can't classify its\n // declarations and `ɵɵsetComponentScope` is never emitted for it. Only\n // relative imports and `paths`-mapped (project/workspace) bare specifiers are\n // followed; true `node_modules` packages are left to the lazy `.d.ts` scanner.\n // Return *all* candidate base paths a bare specifier maps to. A `paths`\n // entry can list several fallback targets (e.g. a built `dist` path first\n // and the workspace `src` second); the caller probes them in order.\n const resolvePathSpecifier = (spec: string): string[] => {\n if (!tsPaths) return [];\n for (const [key, targets] of Object.entries(tsPaths)) {\n const list = targets as string[];\n if (key.endsWith('/*')) {\n const prefix = key.slice(0, -1);\n if (spec.startsWith(prefix)) {\n // `split('*').join(...)` substitutes the single tsconfig `*`\n // wildcard without `String.replace`'s first-match-only behavior or\n // `$`-pattern interpretation of the replacement.\n return list.map((t) =>\n resolve(baseUrl, t.split('*').join(spec.slice(prefix.length))),\n );\n }\n } else if (key === spec) {\n return list.map((t) => resolve(baseUrl, t));\n }\n }\n return [];\n };\n const probeToSource = async (base: string): Promise<string | null> => {\n const candidates = base.endsWith('.ts')\n ? [base]\n : [base + '.ts', resolve(base, 'index.ts')];\n for (const candidate of candidates) {\n try {\n await fsPromises.access(candidate);\n return candidate;\n } catch {\n // try next candidate\n }\n }\n return null;\n };\n // Memoize fs probes per absolute base path. The cache stores the\n // Promise (not the settled value) so concurrent walks racing on the\n // same base collapse into a single probe.\n const baseResolveCache = new Map<string, Promise<string | null>>();\n const resolveToSource = (base: string): Promise<string | null> => {\n let probe = baseResolveCache.get(base);\n if (!probe) {\n probe = probeToSource(base);\n baseResolveCache.set(base, probe);\n }\n return probe;\n };\n // Probe each `paths` target in order; first one that resolves to source wins.\n const resolveFirstSource = async (\n bases: string[],\n ): Promise<string | null> => {\n for (const base of bases) {\n const resolved = await resolveToSource(base);\n if (resolved) return resolved;\n }\n return null;\n };\n const importWalkVisited = new Set<string>();\n // Paths-mapped resolution doesn't depend on the importer, so bare\n // specifiers can be memoized by their raw text. Relative specifiers\n // must NOT be — the same './foo' resolves differently per directory.\n const bareSpecResolveCache = new Map<string, Promise<string | null>>();\n const walkImports = async (file: string): Promise<void> => {\n if (importWalkVisited.has(file)) return;\n importWalkVisited.add(file);\n let code: string;\n try {\n code =\n fileContents.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents.set(file, code);\n } catch {\n return;\n }\n // Single parse shared by scanFile, collectImportedPackages, and\n // collectAllImports. On a parse error each consumer re-parses on\n // its own, preserving their individual failure semantics.\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults.set(file, entries);\n }\n for (const entry of entries) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n // Pre-scan the `.d.ts` of every external package this file imports (and,\n // transitively, packages those packages' NgModules re-export — e.g.\n // BrowserModule → CommonModule → NgIf). Doing this at buildStart means the\n // registry is complete before any component transforms, so non-standalone\n // component scope resolves regardless of file transform order.\n for (const pkg of collectImportedPackages(code, file, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n try {\n for (const entry of scanPackageDts(\n pkg,\n projectRoot,\n scannedDtsPackages,\n )) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n const dir = dirname(file);\n const targets = await Promise.all(\n collectAllImports(code, file, program).map((spec) => {\n if (spec.startsWith('.')) {\n return resolveToSource(\n resolve(dir, spec.replace(/\\.(?:js|mjs)$/u, '')),\n );\n }\n let resolved = bareSpecResolveCache.get(spec);\n if (!resolved) {\n resolved = resolveFirstSource(resolvePathSpecifier(spec));\n bareSpecResolveCache.set(spec, resolved);\n }\n return resolved;\n }),\n );\n await Promise.all(\n targets.filter((t): t is string => !!t).map((t) => walkImports(t)),\n );\n };\n const walkRoots = [...new Set([...config.rootNames, ...extraIncludes])];\n await Promise.all(walkRoots.map((file) => walkImports(file)));\n\n // Library barrels typically `export * from './lib/...'` rather than\n // declaring directives directly, so the entry file alone gives us\n // the tuple consts but not the directive classes they reference.\n // Walk the relative `export *` chain so the underlying classes also\n // land in the registry. Use a SHARED visited set across all\n // barrels so recursive walks don't double-scan a file that's\n // re-exported from multiple entry points.\n const buildStartVisited = new Set<string>();\n if (tsPaths) {\n const barrelCandidates: string[] = [];\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n if (target.includes('*')) continue;\n barrelCandidates.push(resolve(baseUrl, target));\n }\n }\n await Promise.all(\n barrelCandidates.map((c) =>\n scanBarrelExports(\n c,\n buildStartVisited,\n false,\n fileContents,\n scanResults,\n ),\n ),\n );\n }\n debugRegistry(\n 'initFastCompile done: %d entries from %d candidate files',\n registry.size,\n candidates.size,\n );\n }\n\n function ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: ReturnType<typeof parseSync>['program'],\n ): void {\n for (const pkg of collectImportedPackages(code, id, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n\n try {\n const dtsEntries = scanPackageDts(pkg, projectRoot, scannedDtsPackages);\n for (const entry of dtsEntries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n /**\n * Scan the source files `id` imports into the registry on demand and record\n * `id` as their importer, so a metadata change in any of them recompiles it.\n */\n async function resolveImportedDeclarations(\n code: string,\n id: string,\n program: ReturnType<typeof parseSync>['program'],\n resolveImport: ResolveImport,\n ): Promise<void> {\n await Promise.all(\n collectAllImports(code, id, program).map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await scanOnDemand(file, resolveImport)) {\n let importers = importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n function scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = lazyScans.get(file);\n if (!scan) {\n scan = scanWithReExports(file, resolveImport);\n lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n async function scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: ReturnType<typeof parseSync>['program'];\n try {\n code = await fsPromises.readFile(current, 'utf-8');\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n\n function registryEntriesOf(file: string) {\n return [...registry.values()].filter((e) => e.fileName === file);\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\n resolveImport: ResolveImport,\n ): Promise<{ code: string; map: any } | undefined> {\n if (!ANGULAR_DECORATOR_CALL_RE.test(code)) {\n // Non-Angular file — strip TS-only syntax ourselves so barrels\n // like `export { Foo, type Bar } from './x'` and other TS-only\n // forms don't leak unstripped to Rolldown. In rolldown-vite the\n // built-in `vite:oxc` strip is registered as a Rust-side native\n // plugin (`viteTransformPlugin` from `rolldown/experimental`); if\n // its hook-filter treats files our `transform.filter.id.include`\n // claimed as already-handled, no JS-side fallback runs and raw\n // TS reaches the parser → `SyntaxError: Unexpected identifier`.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(code, id, {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n })\n : await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n sourcemap: true,\n });\n return { code: stripped.code, map: stripped.map };\n }\n\n // JIT mode\n if (pluginOptions.jit) {\n const result = jitTransform(code, id);\n // Strip TypeScript-only syntax (e.g. `readonly`, parameter property\n // modifiers, type annotations on fields) so the output is valid JS\n // for Rolldown. `angularVitestSourcemapPlugin` normally runs this\n // strip downstream in tests, but it is intentionally skipped on\n // StackBlitz / WebContainer — and the production build pipeline\n // does not register it either — so the JIT path must self-strip\n // to stay safe across environments.\n //\n // Pass the jitTransform map as `inMap` so OXC/esbuild emit a map\n // composed with the original `.ts` source — without this, debug\n // stack traces and breakpoints land on the wrong lines once the\n // strip removes any TS-only token. `jitTransform` returns\n // `map: null` for files with no Angular class (no edits made);\n // passing that to OXC/esbuild as `inMap` throws, so coerce to\n // `undefined` in that case.\n const inMap = result.map ?? undefined;\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n inMap,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n inMap,\n );\n return { code: stripped.code, map: stripped.map };\n }\n\n // Inline external templateUrl/styleUrl(s) into the source before compilation.\n // `stylePaths` carries the source path of each inlined external style so\n // it is preprocessed as its own file (e.g. an external `.scss` styleUrl or\n // a relative `@import`) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { stylePaths } = inlined;\n\n // Track inlined resources for HMR. `compile()` only reports resources it\n // reads through its own fallback (a templateUrl/styleUrl the inliner did\n // NOT already inline), so files inlined here must be recorded here or a\n // later edit to them never invalidates the owning module.\n for (const dep of inlined.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Single OXC parse of the post-inline source, shared by every AST\n // consumer below. `inlineResourceUrls` parsed the PRE-inline string,\n // so its program can never be reused here.\n const { program: oxcProgram } = parseOxc(id, code);\n\n // Pre-resolve component styles through the registered style preprocessor\n // and Vite's CSS pipeline (Sass/Less, PostCSS, Tailwind), like ngtsc does.\n // External styleUrls are processed as their own file; truly inline\n // `styles: [...]` use `inlineStylesExtension`.\n let resolvedInlineStyles: Map<number, string> | undefined;\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n for (let i = 0; i < styleStrings.length; i++) {\n const stylePath =\n stylePaths.get(i) ??\n id.replace(\n /\\.ts$/,\n `.inline-${i}.${pluginOptions.inlineStylesExtension || 'css'}`,\n );\n try {\n const preprocessed = preprocessStylesheet(\n styleStrings[i],\n stylePath,\n activeStylePreprocessor,\n {\n filename: stylePath,\n containingFile: id,\n order: i,\n inline: !stylePaths.has(i),\n },\n );\n const processed = await preprocessCSS(\n preprocessed,\n stylePath,\n activeConfig,\n );\n resolvedInlineStyles.set(i, processed.code);\n } catch (e) {\n warnStylesheetError(activeConfig?.logger, stylePath, e);\n }\n }\n if (resolvedInlineStyles.size === 0) resolvedInlineStyles = undefined;\n }\n\n ensureDtsRegistryForSource(code, id, oxcProgram);\n\n for (const entry of scanFile(code, id, oxcProgram)) {\n registry.set(entry.className, entry);\n }\n await resolveImportedDeclarations(code, id, oxcProgram, resolveImport);\n if (declaresNonStandaloneComponent(oxcProgram)) {\n projectScan ??= scanProject();\n await projectScan;\n }\n\n // Merge registries contributed through `analog.setup()` into this\n // compile's lookup view. Out-of-tree compilers register directive\n // metadata for classes fastCompile can't reach through its\n // tsconfig-driven scan (e.g. `.tsrx` files compiled by `@tsrx/analog`).\n // Without this merge, a TS `@Component({ imports: [X] })` that\n // references such a class hits `_unresolved-${className}` as its\n // selector and the tag never matches at runtime.\n const activeComponentRegistries = sharedCtx\n ? sharedCtx.componentRegistries\n : componentRegistries;\n let compileRegistry: ComponentRegistry = registry;\n if (activeComponentRegistries.some((external) => external.size > 0)) {\n compileRegistry = new Map(registry);\n for (const external of activeComponentRegistries) {\n for (const [k, v] of external) compileRegistry.set(k, v);\n }\n }\n\n const result = compile(code, id, {\n registry: compileRegistry,\n resolvedInlineStyles,\n useDefineForClassFields,\n compilationMode: pluginOptions.fastCompileMode,\n oxcProgram,\n });\n\n // Track resource dependencies for HMR\n for (const dep of result.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Strip TypeScript-only syntax and compose the compiler map with the\n // final generated code so downstream breakpoints map back to the source.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n result.map,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n result.map,\n );\n let outputCode = stripped.code;\n\n // Append HMR code in dev mode\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (activeWatchMode && pluginOptions.liveReload) {\n const fileDeclarations = registryEntriesOf(id);\n if (fileDeclarations.length > 0) {\n const localDepClassNames = fileDeclarations.map((e) => e.className);\n outputCode += generateHmrCode(fileDeclarations, localDepClassNames);\n }\n }\n\n return { code: outputCode, map: stripped.map };\n }\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const resolution = tsConfigResolutionContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n pluginOptions.tsconfigGetter(),\n resolution.isProd,\n pluginOptions.isTest,\n resolution.isLib,\n pluginOptions.workspaceRoot,\n );\n }\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(normalizePath(id)),\n hasEmitted: (id: string): boolean => emittedMaps.has(normalizePath(id)),\n };\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-fast-compile',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n return {\n name: '@analogjs/vite-plugin-angular-fast-compile',\n api: compilerApi,\n enforce: 'pre' as const,\n async config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n }\n\n const preliminaryTsConfigPath = resolveTsConfigPath();\n\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: preliminaryTsConfigPath,\n isProd,\n jit: pluginOptions.jit,\n watchMode,\n isTest: pluginOptions.isTest,\n isAstroIntegration: pluginOptions.isAstroIntegration,\n });\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`.\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n if (sharedCtx) {\n const integrations = await sharedCtx.resolveConfig(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n } else {\n const integrations = await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n }\n },\n async buildStart() {\n await initFastCompile();\n },\n closeBundle() {\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (!activeWatchMode) {\n emittedMaps.clear();\n releaseCssPreprocessorWorkers();\n }\n },\n async handleHotUpdate(ctx) {\n if (\n sharedCtx\n ? sharedCtx.hmr.isIgnoredFile(ctx.file)\n : isIgnoredHmrFile(ctx.file)\n ) {\n return [];\n }\n\n // Resource file changes → invalidate parent .ts module\n if (resourceToSource.has(ctx.file)) {\n const parentSource = resourceToSource.get(ctx.file)!;\n const parentModule = ctx.server.moduleGraph.getModuleById(parentSource);\n if (parentModule) {\n return [parentModule];\n }\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n\n // Remove old entries from this file\n const oldEntries = registryEntriesOf(fileId);\n for (const entry of oldEntries) {\n registry.delete(entry.className);\n }\n\n // Rescan the changed file via the barrel-aware scanner so an\n // edited barrel re-export picks up newly-referenced files.\n // Pass overwrite=true so updated metadata replaces stale\n // entries from the previous scan.\n await scanBarrelExports(fileId, new Set(), true);\n\n // Importers compiled the old selector/inputs/outputs into their\n // templates, so recompile them when this file's metadata changed.\n // Cached scans that pulled in this file may now be incomplete.\n lazyScans.clear();\n const metadataChanged =\n JSON.stringify(oldEntries) !==\n JSON.stringify(registryEntriesOf(fileId));\n if (metadataChanged) {\n const importerModules = [\n ...(importersByFile.get(fileId) ?? []),\n ].flatMap((importer) => [\n ...(ctx.server.moduleGraph.getModulesByFile(importer) ?? []),\n ]);\n return [...ctx.modules, ...importerModules];\n }\n }\n\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: pluginOptions.jit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? resolvedConfig,\n );\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n // `?raw` ids already carry Vite's native raw-loader output\n // (`export default \"<source>\"`). Recompiling them as Angular/TS\n // would strip that default export, so leave them to Vite (#2356).\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n if (activeTransformFilter && !activeTransformFilter(code, id)) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n const transformed = await handleFastCompileTransform(\n code,\n id,\n async (spec, importer) => {\n const resolved = await this.resolve(spec, importer, {\n skipSelf: true,\n });\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n // Package declarations come from the lazy `.d.ts` scanner instead.\n return TS_EXT_REGEX.test(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n },\n );\n if (transformed?.map) {\n emittedMaps.set(\n normalizePath(id),\n typeof transformed.map === 'string'\n ? transformed.map\n : JSON.stringify(transformed.map),\n );\n }\n return transformed;\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAS,2BACP,OACmC;CACnC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,sBAAsB,KAAK,KAC5B,oBAAoB,SACpB,OAAQ,MAAmC,mBAAmB;AAElE;;;;;;;AAUA,SAAgB,iBACd,SACA,UACQ;CACR,OAAO,SAAS,WAAW,SAAS,iBAAiB;AACvD;AAEA,SAAgB,kBACd,cAIQ;CACR,MAAM,YAAY,sBAAsB,YAAY,IAChD,eACA,2BAA2B,YAAY,IACrC,KAAA,IACA,0BAA0B;EACxB,GAAG;EACH,oBAAoB;CACtB,CAAC;CAEP,MAAM,gBAA0C,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,IACA,OAAO,MAAM,aAAa;KACxB,MAAM,WAAW,MAAM,KAAK,QAAQ,MAAM,UAAU,EAClD,UAAU,KACZ,CAAC;KACD,IAAI,CAAC,YAAY,SAAS,UAAU,OAAO;KAC3C,MAAM,OAAO,cAAc,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE;KAEpD,OAAO,aAAa,KAAK,IAAI,KAC3B,CAAC,sBAAsB,KAAK,IAAI,KAChC,CAAC,KAAK,SAAS,gBAAgB,IAC7B,OACA;IACN,CACF;IACA,IAAI,aAAa,KACf,YAAY,IACV,cAAc,EAAE,GAChB,OAAO,YAAY,QAAQ,WACvB,YAAY,MACZ,KAAK,UAAU,YAAY,GAAG,CACpC;IAEF,OAAO;GACT;EACF;CACF;AACF"}
1
+ {"version":3,"file":"fast-compile-plugin.js","names":[],"sources":["../../../src/lib/fast-compile-plugin.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './compiler/utils.js';\nimport * as vite from 'vite';\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n compile,\n scanFile,\n declaresNonStandaloneComponent,\n scanPackageDts,\n collectImportedPackages,\n collectRelativeReExports,\n collectReExports,\n collectAllImports,\n jitTransform,\n inlineResourceUrls,\n extractInlineStyles,\n generateHmrCode,\n debugRegistry,\n ANGULAR_DECORATOR_CALL_RE,\n type ComponentRegistry,\n} from './compiler/index.js';\nimport { reportStylesheetError } from './utils/stylesheet-warning.js';\n\nimport {\n TS_EXT_REGEX,\n EXCLUDED_TS_EXT_REGEX,\n getTsConfigPath,\n createDepOptimizerConfig,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport { TsconfigResolver } from './utils/tsconfig-resolver.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nexport interface FastCompilePluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n fastCompileMode?: 'full' | 'partial';\n disableTypeChecking?: boolean;\n typeChecker?: TypeCheckerOption;\n include?: string[];\n}\n\nfunction isFastCompilePluginOptions(\n value: unknown,\n): value is FastCompilePluginOptions {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isAngularBuildContext(value) &&\n 'tsconfigGetter' in value &&\n typeof (value as FastCompilePluginOptions).tsconfigGetter === 'function'\n );\n}\n\ntype ResolveImport = (spec: string, importer: string) => Promise<string | null>;\n\n/**\n * Directory that `compilerOptions.paths` targets resolve against. Mirrors\n * TypeScript: `baseUrl` when set, otherwise the directory of the config\n * that declares `paths` (`pathsBasePath`, since `baseUrl` is optional\n * from TS 4.1).\n */\nexport function getPathsBasePath(\n options: { baseUrl?: string; pathsBasePath?: string } | undefined,\n fallback: string,\n): string {\n return options?.baseUrl ?? options?.pathsBasePath ?? fallback;\n}\n\nexport function fastCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompilePluginOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n ...optionsOrCtx,\n compilationBackend: 'fast',\n });\n\n const pluginOptions: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n const tsconfigResolver =\n sharedCtx?.tsconfigResolver ??\n new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include ?? [],\n liveReload: pluginOptions.liveReload,\n isTest: pluginOptions.isTest,\n });\n\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // fast-compile plugin state\n const registry: ComponentRegistry = new Map();\n const resourceToSource = new Map<string, string>();\n const scannedDtsPackages = new Set<string>();\n const emittedMaps = new Map<string, string>();\n let projectRoot = '';\n let useDefineForClassFields = true;\n let tsConfig: ReturnType<typeof compilerCli.readConfiguration>;\n\n // Files scanned on demand (mapped to the barrel chain they pulled in), which\n // modules were compiled against each scanned file, and the one-time\n // whole-project scan non-standalone components fall back to.\n const lazyScans = new Map<string, Promise<Set<string>>>();\n const importersByFile = new Map<string, Set<string>>();\n let projectScan: Promise<void> | undefined;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code =\n fileContents?.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents?.set(file, code);\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: failed to read %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return;\n }\n // Single parse shared by scanFile and collectRelativeReExports. On a\n // parse error each consumer re-parses on its own, preserving their\n // individual failure semantics (scanFile throws past its pre-filter;\n // collectRelativeReExports swallows and returns []).\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults?.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults?.set(file, entries);\n }\n for (const entry of entries) {\n // At buildStart we want stable registry entries (don't overwrite\n // an earlier scan with a barrel re-scan); HMR explicitly asks\n // for overwrite so updated metadata replaces stale entries.\n if (overwrite || !registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n // Collect every relative re-export specifier via OXC AST so\n // recursive scans can't trip over each other (a shared `/g` regex\n // would have its `lastIndex` reset by each recursive call and\n // silently skip half of an outer barrel's re-exports, which\n // previously left directives like `HlmRadioGroup` unregistered).\n const dir = dirname(file);\n for (const rel of collectRelativeReExports(code, file, program)) {\n // NodeNext-style libraries write `export * from './foo.js'`\n // even though the source is `./foo.ts`. Strip the ESM\n // extension before probing or the candidates would be\n // `foo.js.ts` / `foo.js/index.ts`, which never exist.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const reExportCandidates = [\n resolve(dir, normalizedRel + '.ts'),\n resolve(dir, normalizedRel, 'index.ts'),\n ];\n let resolved = false;\n for (const candidate of reExportCandidates) {\n try {\n await fsPromises.access(candidate);\n await scanBarrelExports(\n candidate,\n visited,\n overwrite,\n fileContents,\n scanResults,\n );\n resolved = true;\n break;\n } catch {\n // try next candidate\n }\n }\n if (!resolved && debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: %s re-export %s did not resolve to %o',\n file,\n rel,\n reExportCandidates,\n );\n }\n }\n }\n\n async function initFastCompile(): Promise<void> {\n emittedMaps.clear();\n if (pluginOptions.jit) return; // JIT: no registry scan needed\n\n registry.clear();\n scannedDtsPackages.clear();\n lazyScans.clear();\n importersByFile.clear();\n projectScan = undefined;\n const resolvedTsConfigPath = resolveTsConfigPath();\n projectRoot = dirname(resolvedTsConfigPath);\n tsConfig = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = tsConfig.options?.useDefineForClassFields ?? true;\n }\n\n /** Scan all source files reachable from the tsconfig into the registry. */\n async function scanProject(): Promise<void> {\n const config = tsConfig;\n const extraIncludes = tsconfigResolver.ensureIncludeCache();\n // Collect candidate files: tsconfig rootNames PLUS explicit/integration\n // include globs PLUS the entry points named in `compilerOptions.paths`.\n // App tsconfigs typically only include the app's own sources, so workspace\n // library entry barrels (e.g. `HlmSelectImports = [HlmSelect,\n // HlmSelectContent, ...] as const`) live outside `rootNames` and would\n // otherwise miss the initial scan. The compiler then can't see that\n // `HlmSelectImports` is a tuple barrel and emits the bare identifier into\n // the parent component's `dependencies()` list, where Angular's runtime\n // silently drops it because arrays don't have a directive def.\n const candidates = new Set<string>([...config.rootNames, ...extraIncludes]);\n const tsPaths = config.options?.paths;\n const baseUrl = getPathsBasePath(config.options, projectRoot);\n // Cold-start dedup caches shared by the three scan phases below\n // (candidates scan, walkImports, scanBarrelExports). Scoped to this\n // init call only — HMR/watcher re-scans must hit disk fresh.\n const fileContents = new Map<string, string>();\n const scanResults = new Map<string, ReturnType<typeof scanFile>>();\n if (tsPaths) {\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n // Skip wildcard patterns — entry barrels are normally exact\n // file paths like \"libs/helm/select/src/index.ts\".\n if (target.includes('*')) continue;\n candidates.add(resolve(baseUrl, target));\n }\n }\n }\n const results = await Promise.all(\n Array.from(candidates).map(async (file) => {\n try {\n const code = await fsPromises.readFile(file, 'utf-8');\n fileContents.set(file, code);\n const entries = scanFile(code, file);\n scanResults.set(file, entries);\n return entries;\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'initFastCompile: skipping unreadable %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return []; // Skip unreadable files\n }\n }),\n );\n\n for (const entries of results) {\n for (const entry of entries) {\n registry.set(entry.className, entry);\n }\n }\n\n // Walk the transitive import graph from the root files so the registry also\n // contains declarations that live in files not directly in tsconfig\n // `files`/`include` (transitively-imported app sources) and in workspace\n // libraries reached through wildcard `paths` (e.g. `@bitwarden/*`). Without\n // this, a non-standalone component's owning module can't classify its\n // declarations and `ɵɵsetComponentScope` is never emitted for it. Only\n // relative imports and `paths`-mapped (project/workspace) bare specifiers are\n // followed; true `node_modules` packages are left to the lazy `.d.ts` scanner.\n // Return *all* candidate base paths a bare specifier maps to. A `paths`\n // entry can list several fallback targets (e.g. a built `dist` path first\n // and the workspace `src` second); the caller probes them in order.\n const resolvePathSpecifier = (spec: string): string[] => {\n if (!tsPaths) return [];\n for (const [key, targets] of Object.entries(tsPaths)) {\n const list = targets as string[];\n if (key.endsWith('/*')) {\n const prefix = key.slice(0, -1);\n if (spec.startsWith(prefix)) {\n // `split('*').join(...)` substitutes the single tsconfig `*`\n // wildcard without `String.replace`'s first-match-only behavior or\n // `$`-pattern interpretation of the replacement.\n return list.map((t) =>\n resolve(baseUrl, t.split('*').join(spec.slice(prefix.length))),\n );\n }\n } else if (key === spec) {\n return list.map((t) => resolve(baseUrl, t));\n }\n }\n return [];\n };\n const probeToSource = async (base: string): Promise<string | null> => {\n const candidates = base.endsWith('.ts')\n ? [base]\n : [base + '.ts', resolve(base, 'index.ts')];\n for (const candidate of candidates) {\n try {\n await fsPromises.access(candidate);\n return candidate;\n } catch {\n // try next candidate\n }\n }\n return null;\n };\n // Memoize fs probes per absolute base path. The cache stores the\n // Promise (not the settled value) so concurrent walks racing on the\n // same base collapse into a single probe.\n const baseResolveCache = new Map<string, Promise<string | null>>();\n const resolveToSource = (base: string): Promise<string | null> => {\n let probe = baseResolveCache.get(base);\n if (!probe) {\n probe = probeToSource(base);\n baseResolveCache.set(base, probe);\n }\n return probe;\n };\n // Probe each `paths` target in order; first one that resolves to source wins.\n const resolveFirstSource = async (\n bases: string[],\n ): Promise<string | null> => {\n for (const base of bases) {\n const resolved = await resolveToSource(base);\n if (resolved) return resolved;\n }\n return null;\n };\n const importWalkVisited = new Set<string>();\n // Paths-mapped resolution doesn't depend on the importer, so bare\n // specifiers can be memoized by their raw text. Relative specifiers\n // must NOT be — the same './foo' resolves differently per directory.\n const bareSpecResolveCache = new Map<string, Promise<string | null>>();\n const walkImports = async (file: string): Promise<void> => {\n if (importWalkVisited.has(file)) return;\n importWalkVisited.add(file);\n let code: string;\n try {\n code =\n fileContents.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents.set(file, code);\n } catch {\n return;\n }\n // Single parse shared by scanFile, collectImportedPackages, and\n // collectAllImports. On a parse error each consumer re-parses on\n // its own, preserving their individual failure semantics.\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults.set(file, entries);\n }\n for (const entry of entries) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n // Pre-scan the `.d.ts` of every external package this file imports (and,\n // transitively, packages those packages' NgModules re-export — e.g.\n // BrowserModule → CommonModule → NgIf). Doing this at buildStart means the\n // registry is complete before any component transforms, so non-standalone\n // component scope resolves regardless of file transform order.\n for (const pkg of collectImportedPackages(code, file, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n try {\n for (const entry of scanPackageDts(\n pkg,\n projectRoot,\n scannedDtsPackages,\n )) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n const dir = dirname(file);\n const targets = await Promise.all(\n collectAllImports(code, file, program).map((spec) => {\n if (spec.startsWith('.')) {\n return resolveToSource(\n resolve(dir, spec.replace(/\\.(?:js|mjs)$/u, '')),\n );\n }\n let resolved = bareSpecResolveCache.get(spec);\n if (!resolved) {\n resolved = resolveFirstSource(resolvePathSpecifier(spec));\n bareSpecResolveCache.set(spec, resolved);\n }\n return resolved;\n }),\n );\n await Promise.all(\n targets.filter((t): t is string => !!t).map((t) => walkImports(t)),\n );\n };\n const walkRoots = [...new Set([...config.rootNames, ...extraIncludes])];\n await Promise.all(walkRoots.map((file) => walkImports(file)));\n\n // Library barrels typically `export * from './lib/...'` rather than\n // declaring directives directly, so the entry file alone gives us\n // the tuple consts but not the directive classes they reference.\n // Walk the relative `export *` chain so the underlying classes also\n // land in the registry. Use a SHARED visited set across all\n // barrels so recursive walks don't double-scan a file that's\n // re-exported from multiple entry points.\n const buildStartVisited = new Set<string>();\n if (tsPaths) {\n const barrelCandidates: string[] = [];\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n if (target.includes('*')) continue;\n barrelCandidates.push(resolve(baseUrl, target));\n }\n }\n await Promise.all(\n barrelCandidates.map((c) =>\n scanBarrelExports(\n c,\n buildStartVisited,\n false,\n fileContents,\n scanResults,\n ),\n ),\n );\n }\n debugRegistry(\n 'initFastCompile done: %d entries from %d candidate files',\n registry.size,\n candidates.size,\n );\n }\n\n function ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: ReturnType<typeof parseSync>['program'],\n ): void {\n for (const pkg of collectImportedPackages(code, id, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n\n try {\n const dtsEntries = scanPackageDts(pkg, projectRoot, scannedDtsPackages);\n for (const entry of dtsEntries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n /**\n * Scan the source files `id` imports into the registry on demand and record\n * `id` as their importer, so a metadata change in any of them recompiles it.\n */\n async function resolveImportedDeclarations(\n code: string,\n id: string,\n program: ReturnType<typeof parseSync>['program'],\n resolveImport: ResolveImport,\n ): Promise<void> {\n await Promise.all(\n collectAllImports(code, id, program).map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await scanOnDemand(file, resolveImport)) {\n let importers = importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n function scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = lazyScans.get(file);\n if (!scan) {\n scan = scanWithReExports(file, resolveImport);\n lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n async function scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: ReturnType<typeof parseSync>['program'];\n try {\n code = await fsPromises.readFile(current, 'utf-8');\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n\n function registryEntriesOf(file: string) {\n return [...registry.values()].filter((e) => e.fileName === file);\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\n resolveImport: ResolveImport,\n ): Promise<{ code: string; map: any } | undefined> {\n if (!ANGULAR_DECORATOR_CALL_RE.test(code)) {\n // Non-Angular file — strip TS-only syntax ourselves so barrels\n // like `export { Foo, type Bar } from './x'` and other TS-only\n // forms don't leak unstripped to Rolldown. In rolldown-vite the\n // built-in `vite:oxc` strip is registered as a Rust-side native\n // plugin (`viteTransformPlugin` from `rolldown/experimental`); if\n // its hook-filter treats files our `transform.filter.id.include`\n // claimed as already-handled, no JS-side fallback runs and raw\n // TS reaches the parser → `SyntaxError: Unexpected identifier`.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(code, id, {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n })\n : await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n sourcemap: true,\n });\n return { code: stripped.code, map: stripped.map };\n }\n\n // JIT mode\n if (pluginOptions.jit) {\n const result = jitTransform(code, id);\n // Strip TypeScript-only syntax (e.g. `readonly`, parameter property\n // modifiers, type annotations on fields) so the output is valid JS\n // for Rolldown. `angularVitestSourcemapPlugin` normally runs this\n // strip downstream in tests, but it is intentionally skipped on\n // StackBlitz / WebContainer — and the production build pipeline\n // does not register it either — so the JIT path must self-strip\n // to stay safe across environments.\n //\n // Pass the jitTransform map as `inMap` so OXC/esbuild emit a map\n // composed with the original `.ts` source — without this, debug\n // stack traces and breakpoints land on the wrong lines once the\n // strip removes any TS-only token. `jitTransform` returns\n // `map: null` for files with no Angular class (no edits made);\n // passing that to OXC/esbuild as `inMap` throws, so coerce to\n // `undefined` in that case.\n const inMap = result.map ?? undefined;\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n inMap,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n inMap,\n );\n return { code: stripped.code, map: stripped.map };\n }\n\n // Inline external templateUrl/styleUrl(s) into the source before compilation.\n // `stylePaths` carries the source path of each inlined external style so\n // it is preprocessed as its own file (e.g. an external `.scss` styleUrl or\n // a relative `@import`) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { stylePaths } = inlined;\n\n // Track inlined resources for HMR. `compile()` only reports resources it\n // reads through its own fallback (a templateUrl/styleUrl the inliner did\n // NOT already inline), so files inlined here must be recorded here or a\n // later edit to them never invalidates the owning module.\n for (const dep of inlined.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Single OXC parse of the post-inline source, shared by every AST\n // consumer below. `inlineResourceUrls` parsed the PRE-inline string,\n // so its program can never be reused here.\n const { program: oxcProgram } = parseOxc(id, code);\n\n // Pre-resolve component styles through the registered style preprocessor\n // and Vite's CSS pipeline (Sass/Less, PostCSS, Tailwind), like ngtsc does.\n // External styleUrls are processed as their own file; truly inline\n // `styles: [...]` use `inlineStylesExtension`.\n let resolvedInlineStyles: Map<number, string> | undefined;\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n for (let i = 0; i < styleStrings.length; i++) {\n const stylePath =\n stylePaths.get(i) ??\n id.replace(\n /\\.ts$/,\n `.inline-${i}.${pluginOptions.inlineStylesExtension || 'css'}`,\n );\n try {\n const preprocessed = preprocessStylesheet(\n styleStrings[i],\n stylePath,\n activeStylePreprocessor,\n {\n filename: stylePath,\n containingFile: id,\n order: i,\n inline: !stylePaths.has(i),\n },\n );\n const processed = await preprocessCSS(\n preprocessed,\n stylePath,\n activeConfig,\n );\n resolvedInlineStyles.set(i, processed.code);\n } catch (e) {\n reportStylesheetError(\n activeConfig?.logger,\n stylePath,\n e,\n activeConfig?.command === 'build',\n );\n }\n }\n if (resolvedInlineStyles.size === 0) resolvedInlineStyles = undefined;\n }\n\n ensureDtsRegistryForSource(code, id, oxcProgram);\n\n for (const entry of scanFile(code, id, oxcProgram)) {\n registry.set(entry.className, entry);\n }\n await resolveImportedDeclarations(code, id, oxcProgram, resolveImport);\n if (declaresNonStandaloneComponent(oxcProgram)) {\n projectScan ??= scanProject();\n await projectScan;\n }\n\n // Merge registries contributed through `analog.setup()` into this\n // compile's lookup view. Out-of-tree compilers register directive\n // metadata for classes fastCompile can't reach through its\n // tsconfig-driven scan (e.g. `.tsrx` files compiled by `@tsrx/analog`).\n // Without this merge, a TS `@Component({ imports: [X] })` that\n // references such a class hits `_unresolved-${className}` as its\n // selector and the tag never matches at runtime.\n const activeComponentRegistries = sharedCtx\n ? sharedCtx.componentRegistries\n : componentRegistries;\n let compileRegistry: ComponentRegistry = registry;\n if (activeComponentRegistries.some((external) => external.size > 0)) {\n compileRegistry = new Map(registry);\n for (const external of activeComponentRegistries) {\n for (const [k, v] of external) compileRegistry.set(k, v);\n }\n }\n\n const result = compile(code, id, {\n registry: compileRegistry,\n resolvedInlineStyles,\n useDefineForClassFields,\n compilationMode: pluginOptions.fastCompileMode,\n oxcProgram,\n });\n\n // Track resource dependencies for HMR\n for (const dep of result.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Strip TypeScript-only syntax and compose the compiler map with the\n // final generated code so downstream breakpoints map back to the source.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n result.map,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n result.map,\n );\n let outputCode = stripped.code;\n\n // Append HMR code in dev mode\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (activeWatchMode && pluginOptions.liveReload) {\n const fileDeclarations = registryEntriesOf(id);\n if (fileDeclarations.length > 0) {\n const localDepClassNames = fileDeclarations.map((e) => e.className);\n outputCode += generateHmrCode(fileDeclarations, localDepClassNames);\n }\n }\n\n return { code: outputCode, map: stripped.map };\n }\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const resolution = tsConfigResolutionContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n pluginOptions.tsconfigGetter(),\n resolution.isProd,\n pluginOptions.isTest,\n resolution.isLib,\n pluginOptions.workspaceRoot,\n );\n }\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(normalizePath(id)),\n hasEmitted: (id: string): boolean => emittedMaps.has(normalizePath(id)),\n };\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-fast-compile',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n return {\n name: '@analogjs/vite-plugin-angular-fast-compile',\n api: compilerApi,\n enforce: 'pre' as const,\n async config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n }\n\n const preliminaryTsConfigPath = resolveTsConfigPath();\n\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: preliminaryTsConfigPath,\n isProd,\n jit: pluginOptions.jit,\n watchMode,\n isTest: pluginOptions.isTest,\n isAstroIntegration: pluginOptions.isAstroIntegration,\n });\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`.\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n if (sharedCtx) {\n const integrations = await sharedCtx.resolveConfig(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n } else {\n const integrations = await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n }\n },\n async buildStart() {\n await initFastCompile();\n },\n closeBundle() {\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (!activeWatchMode) {\n emittedMaps.clear();\n releaseCssPreprocessorWorkers();\n }\n },\n async handleHotUpdate(ctx) {\n if (\n sharedCtx\n ? sharedCtx.hmr.isIgnoredFile(ctx.file)\n : isIgnoredHmrFile(ctx.file)\n ) {\n return [];\n }\n\n // Resource file changes → invalidate parent .ts module\n if (resourceToSource.has(ctx.file)) {\n const parentSource = resourceToSource.get(ctx.file)!;\n const parentModule = ctx.server.moduleGraph.getModuleById(parentSource);\n if (parentModule) {\n return [parentModule];\n }\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n\n // Remove old entries from this file\n const oldEntries = registryEntriesOf(fileId);\n for (const entry of oldEntries) {\n registry.delete(entry.className);\n }\n\n // Rescan the changed file via the barrel-aware scanner so an\n // edited barrel re-export picks up newly-referenced files.\n // Pass overwrite=true so updated metadata replaces stale\n // entries from the previous scan.\n await scanBarrelExports(fileId, new Set(), true);\n\n // Importers compiled the old selector/inputs/outputs into their\n // templates, so recompile them when this file's metadata changed.\n // Cached scans that pulled in this file may now be incomplete.\n lazyScans.clear();\n const metadataChanged =\n JSON.stringify(oldEntries) !==\n JSON.stringify(registryEntriesOf(fileId));\n if (metadataChanged) {\n const importerModules = [\n ...(importersByFile.get(fileId) ?? []),\n ].flatMap((importer) => [\n ...(ctx.server.moduleGraph.getModulesByFile(importer) ?? []),\n ]);\n return [...ctx.modules, ...importerModules];\n }\n }\n\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: pluginOptions.jit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? resolvedConfig,\n );\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n // `?raw` ids already carry Vite's native raw-loader output\n // (`export default \"<source>\"`). Recompiling them as Angular/TS\n // would strip that default export, so leave them to Vite (#2356).\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n if (activeTransformFilter && !activeTransformFilter(code, id)) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n const transformed = await handleFastCompileTransform(\n code,\n id,\n async (spec, importer) => {\n const resolved = await this.resolve(spec, importer, {\n skipSelf: true,\n });\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n // Package declarations come from the lazy `.d.ts` scanner instead.\n return TS_EXT_REGEX.test(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n },\n );\n if (transformed?.map) {\n emittedMaps.set(\n normalizePath(id),\n typeof transformed.map === 'string'\n ? transformed.map\n : JSON.stringify(transformed.map),\n );\n }\n return transformed;\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAS,2BACP,OACmC;CACnC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,sBAAsB,KAAK,KAC5B,oBAAoB,SACpB,OAAQ,MAAmC,mBAAmB;AAElE;;;;;;;AAUA,SAAgB,iBACd,SACA,UACQ;CACR,OAAO,SAAS,WAAW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,IAAI;IACtB,MAAM,wBACJ,WAAW,mBAAmB;IAChC,IAAI,yBAAyB,CAAC,sBAAsB,MAAM,EAAE,GAC1D;IAGF,IAAI,GAAG,SAAS,MAAM,GACpB,KAAK,GAAG,QAAQ,UAAU,EAAE;IAE9B,MAAM,cAAc,MAAM,2BACxB,MACA,IACA,OAAO,MAAM,aAAa;KACxB,MAAM,WAAW,MAAM,KAAK,QAAQ,MAAM,UAAU,EAClD,UAAU,KACZ,CAAC;KACD,IAAI,CAAC,YAAY,SAAS,UAAU,OAAO;KAC3C,MAAM,OAAO,cAAc,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE;KAEpD,OAAO,aAAa,KAAK,IAAI,KAC3B,CAAC,sBAAsB,KAAK,IAAI,KAChC,CAAC,KAAK,SAAS,gBAAgB,IAC7B,OACA;IACN,CACF;IACA,IAAI,aAAa,KACf,YAAY,IACV,cAAc,EAAE,GAChB,OAAO,YAAY,QAAQ,WACvB,YAAY,MACZ,KAAK,UAAU,YAAY,GAAG,CACpC;IAEF,OAAO;GACT;EACF;CACF;AACF"}
package/src/lib/host.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare function augmentHostWithResources(host: ts.CompilerHost, transfor
13
13
  sourceFileCache?: SourceFileCache;
14
14
  stylePreprocessor?: StylePreprocessor;
15
15
  logger?: Logger;
16
+ isBuild?: boolean;
16
17
  }): void;
17
18
  export declare function augmentProgramWithVersioning(program: ts.Program): void;
18
19
  export declare function augmentHostWithCaching(host: ts.CompilerHost, cache: Map<string, ts.SourceFile>): void;
package/src/lib/host.js CHANGED
@@ -2,7 +2,7 @@ import { normalizeStylesheetDependencies } from "./style-preprocessor.js";
2
2
  import { debugStyles } from "./utils/debug.js";
3
3
  import { preprocessStylesheetResult, registerStylesheetContent } from "./stylesheet-registry.js";
4
4
  import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
5
- import { warnStylesheetError } from "./utils/stylesheet-warning.js";
5
+ import { reportStylesheetError } from "./utils/stylesheet-warning.js";
6
6
  import { createHash } from "node:crypto";
7
7
  import path from "node:path";
8
8
  import { normalizePath } from "vite";
@@ -81,7 +81,7 @@ function augmentHostWithResources(host, transform, options) {
81
81
  resourceFile: context.resourceFile ?? "(inline)",
82
82
  error: String(e)
83
83
  });
84
- warnStylesheetError(options.logger, filename, e);
84
+ reportStylesheetError(options.logger, filename, e, !!options.isBuild);
85
85
  }
86
86
  if (!stylesheetResult?.code) return null;
87
87
  return { content: stylesheetResult.code };
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","names":[],"sources":["../../../src/lib/host.ts"],"sourcesContent":["import type { CompilerHost } from '@angular/compiler-cli';\nimport { normalizePath, type Logger } from 'vite';\n\nimport * as ts from 'typescript';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\nimport {\n normalizeStylesheetDependencies,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n} from './stylesheet-registry.js';\nimport { debugStyles } from './utils/debug.js';\nimport { warnStylesheetError } from './utils/stylesheet-warning.js';\nimport type { SourceFileCache } from './utils/source-file-cache.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\nexport function augmentHostWithModuleResolution(\n host: ts.CompilerHost,\n options: ts.CompilerOptions,\n): void {\n const resolutionCache = ts.createModuleResolutionCache(\n host.getCurrentDirectory(),\n host.getCanonicalFileName.bind(host),\n options,\n );\n host.getModuleResolutionCache = () => resolutionCache;\n host.resolveModuleNameLiterals = (\n literals,\n containingFile,\n redirectedReference,\n compilerOptions,\n containingSourceFile,\n ) =>\n literals.map((literal) => {\n const resolution: ts.ResolvedModuleWithFailedLookupLocations =\n ts.resolveModuleName(\n literal.text,\n containingFile,\n compilerOptions,\n host,\n resolutionCache,\n redirectedReference,\n ts.getModeForUsageLocation(\n containingSourceFile,\n literal,\n compilerOptions,\n ),\n );\n const resolvedModule = resolution.resolvedModule;\n if (\n resolvedModule?.isExternalLibraryImport &&\n TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !EXCLUDED_TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !normalizePath(resolvedModule.resolvedFileName).includes(\n '/node_modules/',\n )\n ) {\n // A workspace symlink resolves to source outside node_modules.\n // Classify it before program creation so TypeScript emits it.\n return {\n ...resolution,\n resolvedModule: {\n ...resolvedModule,\n isExternalLibraryImport: false,\n },\n };\n }\n return resolution;\n });\n}\n\nexport function augmentHostWithResources(\n host: ts.CompilerHost,\n transform: (\n code: string,\n id: string,\n options?: { ssr?: boolean },\n ) => ReturnType<any> | null,\n options: {\n inlineStylesExtension: string;\n isProd?: boolean;\n stylesheetRegistry?: AnalogStylesheetRegistry;\n sourceFileCache?: SourceFileCache;\n stylePreprocessor?: StylePreprocessor;\n logger?: Logger;\n },\n): void {\n const resourceHost = host as CompilerHost;\n\n resourceHost.readResource = async function (fileName: string) {\n const filePath = normalizePath(fileName);\n\n const content = (this as any).readFile(filePath);\n\n if (content === undefined) {\n throw new Error('Unable to locate component resource: ' + fileName);\n }\n\n return content;\n };\n\n resourceHost.getModifiedResourceFiles = function () {\n return options?.sourceFileCache?.modifiedFiles;\n };\n\n resourceHost.transformResource = async function (data, context) {\n // Only style resources are supported currently\n if (context.type !== 'style') {\n return null;\n }\n\n const filename =\n context.resourceFile ??\n context.containingFile.replace(\n '.ts',\n `.${options?.inlineStylesExtension}`,\n );\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n options.stylePreprocessor,\n {\n filename,\n containingFile: context.containingFile,\n resourceFile: context.resourceFile ?? undefined,\n className: context.className,\n order: context.order,\n inline: !context.resourceFile,\n },\n );\n\n // Externalized path: store preprocessed CSS for Vite's serve-time pipeline.\n // CSS must NOT be transformed here — the load hook returns it into\n // Vite's transform pipeline where PostCSS / Tailwind process it once.\n if (options.stylesheetRegistry) {\n const stylesheetId = registerStylesheetContent(\n options.stylesheetRegistry,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile: context.containingFile,\n className: context.className,\n order: context.order,\n inlineStylesExtension: options.inlineStylesExtension,\n resourceFile: context.resourceFile ?? undefined,\n },\n );\n debugStyles('NgtscProgram: stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: context.resourceFile ?? '(inline)',\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n });\n return { content: stylesheetId };\n }\n\n // Non-externalized: CSS is returned directly to the Angular compiler\n // and never re-enters Vite's pipeline, so transform eagerly.\n debugStyles('NgtscProgram: stylesheet processed inline via transform', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n let stylesheetResult;\n\n try {\n stylesheetResult = await transform(\n preprocessed.code,\n `${filename}?direct`,\n );\n } catch (e) {\n debugStyles('NgtscProgram: stylesheet transform error', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n error: String(e),\n });\n warnStylesheetError(options.logger, filename, e);\n }\n\n if (!stylesheetResult?.code) {\n return null;\n }\n\n return { content: stylesheetResult.code };\n };\n\n resourceHost.resourceNameToFileName = function (\n resourceName,\n containingFile,\n fallbackResolve,\n ) {\n // Angular's fallbackResolve callback expects (resourceUrl, containingFile),\n // NOT (directory, resourceName). Use it correctly or fall back to\n // path.join for simple relative paths.\n let resolved: string | null = null;\n if (fallbackResolve) {\n resolved = fallbackResolve(path.dirname(containingFile), resourceName);\n }\n const resolvedPath = normalizePath(\n resolved ?? path.join(path.dirname(containingFile), resourceName),\n );\n\n // All resource names that have template file extensions are assumed to be templates\n if (!options.stylesheetRegistry || !hasStyleExtension(resolvedPath)) {\n return resolvedPath;\n }\n\n // Register the hash-based external mapping so the resolveId hook can\n // resolve Angular's compiled stylesheet references back to the source.\n const externalId = createHash('sha256').update(resolvedPath).digest('hex');\n const filename = externalId + path.extname(resolvedPath);\n\n options.stylesheetRegistry.registerExternalRequest(filename, resolvedPath);\n debugStyles('NgtscProgram: external stylesheet ID mapped for resolveId', {\n resourceName,\n resolvedPath,\n filename,\n });\n\n // Return the real path so Angular can read the file during analysis.\n // Previously, returning the hash-based filename caused \"Could not find\n // stylesheet file\" errors because the hash doesn't exist on disk,\n // preventing AOT compilation for any component with styleUrls. (#2293)\n return resolvedPath;\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] =\n baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n file.version ??= createHash('sha256').update(file.text).digest('hex');\n }\n\n return files;\n };\n}\n\nexport function augmentHostWithCaching(\n host: ts.CompilerHost,\n cache: Map<string, ts.SourceFile>,\n): void {\n const baseGetSourceFile = host.getSourceFile;\n host.getSourceFile = function (\n fileName,\n languageVersion,\n onError,\n shouldCreateNewSourceFile,\n ...parameters\n ) {\n if (!shouldCreateNewSourceFile && cache.has(fileName)) {\n return cache.get(fileName);\n }\n\n const file = baseGetSourceFile.call(\n host,\n fileName,\n languageVersion,\n onError,\n true,\n ...parameters,\n );\n\n if (file) {\n cache.set(fileName, file);\n }\n\n return file;\n };\n}\n\nexport function mergeTransformers(\n first: ts.CustomTransformers,\n second: ts.CustomTransformers,\n): ts.CustomTransformers {\n const result: ts.CustomTransformers = {};\n\n if (first.before || second.before) {\n result.before = [...(first.before || []), ...(second.before || [])];\n }\n\n if (first.after || second.after) {\n result.after = [...(first.after || []), ...(second.after || [])];\n }\n\n if (first.afterDeclarations || second.afterDeclarations) {\n result.afterDeclarations = [\n ...(first.afterDeclarations || []),\n ...(second.afterDeclarations || []),\n ];\n }\n\n return result;\n}\n\nfunction hasStyleExtension(file: string): boolean {\n const extension = path.extname(file).toLowerCase();\n\n switch (extension) {\n case '.css':\n case '.scss':\n return true;\n default:\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ACL,KAAK,SACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
1
+ {"version":3,"file":"host.js","names":[],"sources":["../../../src/lib/host.ts"],"sourcesContent":["import type { CompilerHost } from '@angular/compiler-cli';\nimport { normalizePath, type Logger } from 'vite';\n\nimport * as ts from 'typescript';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\nimport {\n normalizeStylesheetDependencies,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n} from './stylesheet-registry.js';\nimport { debugStyles } from './utils/debug.js';\nimport { reportStylesheetError } from './utils/stylesheet-warning.js';\nimport type { SourceFileCache } from './utils/source-file-cache.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\nexport function augmentHostWithModuleResolution(\n host: ts.CompilerHost,\n options: ts.CompilerOptions,\n): void {\n const resolutionCache = ts.createModuleResolutionCache(\n host.getCurrentDirectory(),\n host.getCanonicalFileName.bind(host),\n options,\n );\n host.getModuleResolutionCache = () => resolutionCache;\n host.resolveModuleNameLiterals = (\n literals,\n containingFile,\n redirectedReference,\n compilerOptions,\n containingSourceFile,\n ) =>\n literals.map((literal) => {\n const resolution: ts.ResolvedModuleWithFailedLookupLocations =\n ts.resolveModuleName(\n literal.text,\n containingFile,\n compilerOptions,\n host,\n resolutionCache,\n redirectedReference,\n ts.getModeForUsageLocation(\n containingSourceFile,\n literal,\n compilerOptions,\n ),\n );\n const resolvedModule = resolution.resolvedModule;\n if (\n resolvedModule?.isExternalLibraryImport &&\n TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !EXCLUDED_TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !normalizePath(resolvedModule.resolvedFileName).includes(\n '/node_modules/',\n )\n ) {\n // A workspace symlink resolves to source outside node_modules.\n // Classify it before program creation so TypeScript emits it.\n return {\n ...resolution,\n resolvedModule: {\n ...resolvedModule,\n isExternalLibraryImport: false,\n },\n };\n }\n return resolution;\n });\n}\n\nexport function augmentHostWithResources(\n host: ts.CompilerHost,\n transform: (\n code: string,\n id: string,\n options?: { ssr?: boolean },\n ) => ReturnType<any> | null,\n options: {\n inlineStylesExtension: string;\n isProd?: boolean;\n stylesheetRegistry?: AnalogStylesheetRegistry;\n sourceFileCache?: SourceFileCache;\n stylePreprocessor?: StylePreprocessor;\n logger?: Logger;\n isBuild?: boolean;\n },\n): void {\n const resourceHost = host as CompilerHost;\n\n resourceHost.readResource = async function (fileName: string) {\n const filePath = normalizePath(fileName);\n\n const content = (this as any).readFile(filePath);\n\n if (content === undefined) {\n throw new Error('Unable to locate component resource: ' + fileName);\n }\n\n return content;\n };\n\n resourceHost.getModifiedResourceFiles = function () {\n return options?.sourceFileCache?.modifiedFiles;\n };\n\n resourceHost.transformResource = async function (data, context) {\n // Only style resources are supported currently\n if (context.type !== 'style') {\n return null;\n }\n\n const filename =\n context.resourceFile ??\n context.containingFile.replace(\n '.ts',\n `.${options?.inlineStylesExtension}`,\n );\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n options.stylePreprocessor,\n {\n filename,\n containingFile: context.containingFile,\n resourceFile: context.resourceFile ?? undefined,\n className: context.className,\n order: context.order,\n inline: !context.resourceFile,\n },\n );\n\n // Externalized path: store preprocessed CSS for Vite's serve-time pipeline.\n // CSS must NOT be transformed here — the load hook returns it into\n // Vite's transform pipeline where PostCSS / Tailwind process it once.\n if (options.stylesheetRegistry) {\n const stylesheetId = registerStylesheetContent(\n options.stylesheetRegistry,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile: context.containingFile,\n className: context.className,\n order: context.order,\n inlineStylesExtension: options.inlineStylesExtension,\n resourceFile: context.resourceFile ?? undefined,\n },\n );\n debugStyles('NgtscProgram: stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: context.resourceFile ?? '(inline)',\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n });\n return { content: stylesheetId };\n }\n\n // Non-externalized: CSS is returned directly to the Angular compiler\n // and never re-enters Vite's pipeline, so transform eagerly.\n debugStyles('NgtscProgram: stylesheet processed inline via transform', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n let stylesheetResult;\n\n try {\n stylesheetResult = await transform(\n preprocessed.code,\n `${filename}?direct`,\n );\n } catch (e) {\n debugStyles('NgtscProgram: stylesheet transform error', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n error: String(e),\n });\n reportStylesheetError(options.logger, filename, e, !!options.isBuild);\n }\n\n if (!stylesheetResult?.code) {\n return null;\n }\n\n return { content: stylesheetResult.code };\n };\n\n resourceHost.resourceNameToFileName = function (\n resourceName,\n containingFile,\n fallbackResolve,\n ) {\n // Angular's fallbackResolve callback expects (resourceUrl, containingFile),\n // NOT (directory, resourceName). Use it correctly or fall back to\n // path.join for simple relative paths.\n let resolved: string | null = null;\n if (fallbackResolve) {\n resolved = fallbackResolve(path.dirname(containingFile), resourceName);\n }\n const resolvedPath = normalizePath(\n resolved ?? path.join(path.dirname(containingFile), resourceName),\n );\n\n // All resource names that have template file extensions are assumed to be templates\n if (!options.stylesheetRegistry || !hasStyleExtension(resolvedPath)) {\n return resolvedPath;\n }\n\n // Register the hash-based external mapping so the resolveId hook can\n // resolve Angular's compiled stylesheet references back to the source.\n const externalId = createHash('sha256').update(resolvedPath).digest('hex');\n const filename = externalId + path.extname(resolvedPath);\n\n options.stylesheetRegistry.registerExternalRequest(filename, resolvedPath);\n debugStyles('NgtscProgram: external stylesheet ID mapped for resolveId', {\n resourceName,\n resolvedPath,\n filename,\n });\n\n // Return the real path so Angular can read the file during analysis.\n // Previously, returning the hash-based filename caused \"Could not find\n // stylesheet file\" errors because the hash doesn't exist on disk,\n // preventing AOT compilation for any component with styleUrls. (#2293)\n return resolvedPath;\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] =\n baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n file.version ??= createHash('sha256').update(file.text).digest('hex');\n }\n\n return files;\n };\n}\n\nexport function augmentHostWithCaching(\n host: ts.CompilerHost,\n cache: Map<string, ts.SourceFile>,\n): void {\n const baseGetSourceFile = host.getSourceFile;\n host.getSourceFile = function (\n fileName,\n languageVersion,\n onError,\n shouldCreateNewSourceFile,\n ...parameters\n ) {\n if (!shouldCreateNewSourceFile && cache.has(fileName)) {\n return cache.get(fileName);\n }\n\n const file = baseGetSourceFile.call(\n host,\n fileName,\n languageVersion,\n onError,\n true,\n ...parameters,\n );\n\n if (file) {\n cache.set(fileName, file);\n }\n\n return file;\n };\n}\n\nexport function mergeTransformers(\n first: ts.CustomTransformers,\n second: ts.CustomTransformers,\n): ts.CustomTransformers {\n const result: ts.CustomTransformers = {};\n\n if (first.before || second.before) {\n result.before = [...(first.before || []), ...(second.before || [])];\n }\n\n if (first.after || second.after) {\n result.after = [...(first.after || []), ...(second.after || [])];\n }\n\n if (first.afterDeclarations || second.afterDeclarations) {\n result.afterDeclarations = [\n ...(first.afterDeclarations || []),\n ...(second.afterDeclarations || []),\n ];\n }\n\n return result;\n}\n\nfunction hasStyleExtension(file: string): boolean {\n const extension = path.extname(file).toLowerCase();\n\n switch (extension) {\n case '.css':\n case '.scss':\n return true;\n default:\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;AAqBA,SAAgB,gCACd,MACA,SACM;CACN,MAAM,kBAAkB,GAAG,4BACzB,KAAK,oBAAoB,GACzB,KAAK,qBAAqB,KAAK,IAAI,GACnC,OACF;CACA,KAAK,iCAAiC;CACtC,KAAK,6BACH,UACA,gBACA,qBACA,iBACA,yBAEA,SAAS,KAAK,YAAY;EACxB,MAAM,aACJ,GA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,UAAU;EAElC,KAAK,MAAM,QAAQ,OACjB,KAAK,YAAY,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,OAAO,KAAK;EAGtE,OAAO;CACT;AACF;AAEA,SAAgB,uBACd,MACA,OACM;CACN,MAAM,oBAAoB,KAAK;CAC/B,KAAK,gBAAgB,SACnB,UACA,iBACA,SACA,2BACA,GAAG,YACH;EACA,IAAI,CAAC,6BAA6B,MAAM,IAAI,QAAQ,GAClD,OAAO,MAAM,IAAI,QAAQ;EAG3B,MAAM,OAAO,kBAAkB,KAC7B,MACA,UACA,iBACA,SACA,MACA,GAAG,UACL;EAEA,IAAI,MACF,MAAM,IAAI,UAAU,IAAI;EAG1B,OAAO;CACT;AACF;AAEA,SAAgB,kBACd,OACA,QACuB;CACvB,MAAM,SAAgC,CAAC;CAEvC,IAAI,MAAM,UAAU,OAAO,QACzB,OAAO,SAAS,CAAC,GAAI,MAAM,UAAU,CAAC,GAAI,GAAI,OAAO,UAAU,CAAC,CAAE;CAGpE,IAAI,MAAM,SAAS,OAAO,OACxB,OAAO,QAAQ,CAAC,GAAI,MAAM,SAAS,CAAC,GAAI,GAAI,OAAO,SAAS,CAAC,CAAE;CAGjE,IAAI,MAAM,qBAAqB,OAAO,mBACpC,OAAO,oBAAoB,CACzB,GAAI,MAAM,qBAAqB,CAAC,GAChC,GAAI,OAAO,qBAAqB,CAAC,CACnC;CAGF,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAuB;CAGhD,QAFkB,KAAK,QAAQ,IAAI,CAAC,CAAC,YAE7B,GAAR;EACE,KAAK;EACL,KAAK,SACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
@@ -241,7 +241,8 @@ function ngtscCompilePlugin(ctxOrOptions) {
241
241
  stylesheetRegistry,
242
242
  sourceFileCache,
243
243
  stylePreprocessor: ctx.stylePreprocessor,
244
- logger: ctx.resolvedConfig?.logger
244
+ logger: ctx.resolvedConfig?.logger,
245
+ isBuild: ctx.resolvedConfig?.command === "build"
245
246
  });
246
247
  }
247
248
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ngtsc-compile-plugin.js","names":[],"sources":["../../../src/lib/ngtsc-compile-plugin.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport {\n basename,\n dirname,\n isAbsolute,\n join,\n relative,\n resolve,\n} from 'node:path';\nimport { union } from 'es-toolkit';\nimport * as compilerCli from '@angular/compiler-cli';\nimport type { NgtscProgram } from '@angular/compiler-cli';\nimport type * as ts from 'typescript';\nimport type * as vite from 'vite';\nimport {\n normalizePath,\n preprocessCSS,\n type ModuleNode,\n type Plugin,\n type ResolvedConfig,\n type ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n StyleUrlsResolver,\n TemplateUrlsResolver,\n} from './component-resolvers.js';\nimport {\n findTemplateOwnerModules,\n getModulesForChangedFile,\n handleDirectComponentStyleHmr,\n isModuleForChangedResource,\n markModuleSelfAccepting,\n} from './component-styles-plugin.js';\nimport { isComponentStyleSheet } from './encapsulation-plugin.js';\nimport {\n augmentHostWithCaching,\n augmentHostWithModuleResolution,\n augmentHostWithResources,\n augmentProgramWithVersioning,\n mergeTransformers,\n} from './host.js';\nimport { createHotUpdateBatcher } from './hot-update-batch.js';\nimport type { EmitFileResult } from './models.js';\nimport type {\n FileReplacementSSR,\n FileReplacementWith,\n} from './plugins/file-replacements.plugin.js';\nimport {\n describeStylesheetContent,\n injectViteIgnoreForHmrMetadata,\n} from './utils/compilation-shared.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport {\n activateDeferredDebug,\n debugCompiler,\n debugCompilerV,\n debugEmit,\n debugEmitV,\n debugHmr,\n debugHmrV,\n debugStyles,\n} from './utils/debug.js';\nimport {\n createJitResourceTransformer,\n SourceFileCache,\n} from './utils/devkit.js';\nimport { toJitInlineStyleId } from './utils/jit-inline-styles.js';\nimport {\n createDepOptimizerConfig,\n EXCLUDED_TS_EXT_REGEX,\n TS_EXT_REGEX,\n} from './utils/plugin-config.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\nimport { markStylePathSafe } from './utils/safe-module-paths.js';\nimport type { SourceFileCache as SourceFileCacheType } from './utils/source-file-cache.js';\nimport { toVirtualRawId } from './utils/virtual-ids.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nconst require = createRequire(import.meta.url);\n\ninterface DeclarationFile {\n declarationFileDir: string;\n declarationPath: string;\n data: string;\n}\n\nexport interface FileMetadataResult {\n errors?: string[];\n warnings?: (string | ts.DiagnosticMessageChain)[];\n hmrUpdateCode?: string | null;\n hmrEligible?: boolean;\n}\n\nexport function evictDeletedFileMetadata(\n file: string,\n {\n classNamesMap,\n fileTransformMap,\n }: {\n classNamesMap: Map<string, string>;\n fileTransformMap: Map<string, string>;\n },\n): void {\n const normalizedFile = normalizePath(file.split('?')[0]);\n classNamesMap.delete(normalizedFile);\n fileTransformMap.delete(normalizedFile);\n}\n\nexport function createFsWatcherCacheInvalidator(\n invalidateFsCaches: () => void,\n invalidateTsconfigCaches: () => void,\n performCompilation: () => Promise<void>,\n): () => Promise<void> {\n return async (): Promise<void> => {\n invalidateFsCaches();\n invalidateTsconfigCaches();\n await performCompilation();\n };\n}\n\n/**\n * Compiles Angular TypeScript sources using `@angular/compiler-cli` (`NgtscProgram`).\n */\nexport function ngtscCompilePlugin(\n ctxOrOptions?: AngularBuildContext | AngularBuildContextOptions,\n): Plugin {\n const ctx = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions\n : createAngularBuildContext({\n ...ctxOrOptions,\n compilationBackend: 'ngtsc',\n });\n\n const ts = require('typescript') as typeof import('typescript');\n\n let cachedBuilder:\n | ts.BuilderProgram\n | ts.EmitAndSemanticDiagnosticsBuilderProgram\n | undefined;\n let nextProgram: NgtscProgram | undefined;\n let cachedHost: ts.CompilerHost | undefined;\n let cachedHostKey: string | undefined;\n\n function invalidateFsCaches(): void {\n ctx.tsconfigResolver.invalidateIncludeCache();\n }\n\n function invalidateTsconfigCaches(): void {\n ctx.tsconfigResolver.invalidateTsconfigCaches();\n cachedHost = undefined;\n cachedHostKey = undefined;\n }\n\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const tsSourceFileCache = new Map<string, ts.SourceFile>();\n\n function invalidateSourceFiles(files: Set<string>): void {\n for (const file of files) {\n tsSourceFileCache.delete(normalizePath(file));\n }\n sourceFileCache.invalidate(files);\n }\n\n const { jit, isTest } = ctx.options;\n let viteServer: ViteDevServer | undefined;\n\n const styleUrlsResolver = new StyleUrlsResolver();\n const templateUrlsResolver = new TemplateUrlsResolver();\n let outputFile: ((file: string) => void) | undefined;\n const outputFiles = new Map<string, EmitFileResult>();\n\n const normalizeEmitterLookupId = (file: string): string => {\n const normalizedFile = normalizePath(file);\n\n if (!normalizedFile.startsWith('/@fs/')) {\n return normalizedFile;\n }\n\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n\n return normalizePath(fsPath);\n };\n\n const describeEmitMarkers = (content: string) => ({\n contentLength: content.length,\n hasCmp: content.includes('ɵcmp'),\n hasFac: content.includes('ɵfac'),\n hasProv: content.includes('ɵprov'),\n hasDecorate: content.includes('__decorate'),\n hasMetadata: content.includes('__metadata'),\n });\n\n const fileEmitter = (file: string): EmitFileResult | undefined => {\n const normalizedFile = normalizeEmitterLookupId(file);\n const hadCachedEmit = outputFiles.has(normalizedFile);\n outputFile?.(normalizedFile);\n const emittedResult = outputFiles.get(normalizedFile);\n debugEmitV('fileEmitter lookup', {\n requestFile: file,\n normalizedFile,\n hadCachedEmit,\n hasOutputFileHook: !!outputFile,\n emitted: !!emittedResult,\n knownOutputCount: outputFiles.size,\n contentLength: emittedResult?.content?.length ?? 0,\n errorCount: emittedResult?.errors?.length ?? 0,\n warningCount: emittedResult?.warnings?.length ?? 0,\n });\n return emittedResult;\n };\n\n ctx.hmr.setFileEmitter((file) => fileEmitter(file));\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: (): string => ctx.resolveTsConfigPath(),\n getSourceMap: (id: string): string | undefined =>\n outputFiles.get(normalizeEmitterLookupId(id))?.map,\n hasEmitted: (id: string): boolean =>\n outputFiles.has(normalizeEmitterLookupId(id)),\n };\n\n ctx.registerCompiler({\n name: '@analogjs/vite-plugin-angular',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n let initialCompilation = false;\n let activeBuilds = 0;\n let closeRequested = false;\n const declarationFiles: DeclarationFile[] = [];\n const fileTransformMap = new Map<string, string>();\n let styleTransform: (\n code: string,\n filename: string,\n ) => Promise<vite.PreprocessCSSResult>;\n let pendingCompilation: Promise<void> | null = null;\n let compilationLock = Promise.resolve();\n const hotUpdates = createHotUpdateBatcher((ids) =>\n performCompilation(ctx.resolvedConfig!, ids),\n );\n\n function releaseCompilation(): void {\n cachedBuilder = undefined;\n nextProgram = undefined;\n cachedHost = undefined;\n cachedHostKey = undefined;\n outputFile = undefined;\n outputFiles.clear();\n fileTransformMap.clear();\n tsSourceFileCache.clear();\n sourceFileCache.clear();\n sourceFileCache.modifiedFiles.clear();\n sourceFileCache.babelFileCache?.clear();\n sourceFileCache.typeScriptFileCache?.clear();\n sourceFileCache.referencedFiles = undefined;\n ctx.tsconfigResolver.invalidateAll();\n releaseCssPreprocessorWorkers();\n ctx.styles.clear();\n }\n\n async function closeCompilation(): Promise<void> {\n closeRequested = false;\n hotUpdates.close();\n await compilationLock;\n declarationFiles.forEach(\n ({ declarationFileDir, declarationPath, data }) => {\n mkdirSync(declarationFileDir, { recursive: true });\n writeFileSync(declarationPath, data, 'utf-8');\n },\n );\n declarationFiles.length = 0;\n releaseCompilation();\n }\n\n function normalizeSourceMapSources(map: string, id: string): string {\n const sourceMap = JSON.parse(map) as {\n sources?: string[];\n sourceRoot?: string;\n };\n const sourceDirectory = dirname(id);\n const sourceRoot = sourceMap.sourceRoot ?? '';\n sourceMap.sources = sourceMap.sources?.map((source) => {\n if (isAbsolute(source) || /^[a-z][a-z\\d+.-]*:/i.test(source)) {\n return normalizePath(source);\n }\n return normalizePath(resolve(sourceDirectory, sourceRoot, source));\n });\n delete sourceMap.sourceRoot;\n return JSON.stringify(sourceMap);\n }\n\n async function performCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ): Promise<void> {\n let releaseLock: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n releaseLock = r;\n });\n try {\n await previousLock;\n await ctx.refreshIntegrations(config);\n await _doPerformCompilation(config, ids);\n } finally {\n releaseLock!();\n }\n }\n\n /**\n * This method shares mutable state and performs the actual compilation work.\n * It should not be called concurrently. Use `performCompilation` which wraps\n * this method in a lock to ensure only one compilation runs at a time.\n */\n async function _doPerformCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ): Promise<void> {\n const isProd = config.mode === 'production';\n const modifiedFiles = new Set<string>(ids ?? []);\n invalidateSourceFiles(modifiedFiles);\n\n if (ids?.length) {\n for (const id of ids) {\n fileTransformMap.delete(id);\n }\n }\n\n const resolvedTsConfigPath = ctx.resolveTsConfigPath();\n const cached = ctx.tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n\n // Clone options before mutation (preserve cache purity)\n const tsCompilerOptions = { ...cached.options };\n let rootNames = [...cached.rootNames];\n\n if (ctx.shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (ctx.shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n // Workaround for https://github.com/angular/angular/issues/59310\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (NgtscProgram path)', {\n liveReload: ctx.options.liveReload,\n viteHmr: ctx.hasViteHmrTransport(),\n externalizeStylesRequested: ctx.externalizeStylesRequested,\n shouldExternalize: ctx.shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n // These options can't be false in partial mode\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && config.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = ctx.watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n // Allow `TestBed.overrideXXX()` APIs.\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n const replacements = ctx.options.fileReplacements.map((rp) =>\n join(\n ctx.options.workspaceRoot,\n (rp as FileReplacementSSR).ssr || (rp as FileReplacementWith).with,\n ),\n );\n // Merge + dedupe root names\n rootNames = union(\n union(rootNames, ctx.tsconfigResolver.ensureIncludeCache()),\n replacements,\n );\n const hostKey = JSON.stringify(tsCompilerOptions);\n let host: ts.CompilerHost;\n\n if (cachedHost && cachedHostKey === hostKey) {\n host = cachedHost;\n } else {\n host = ts.createIncrementalCompilerHost(tsCompilerOptions, {\n ...ts.sys,\n readFile(path: string, encoding?: string) {\n if (fileTransformMap.has(path)) {\n return fileTransformMap.get(path);\n }\n\n const file = ts.sys.readFile.call(null, path, encoding);\n\n if (file) {\n fileTransformMap.set(path, file);\n }\n\n return file;\n },\n });\n augmentHostWithModuleResolution(host, tsCompilerOptions);\n cachedHost = host;\n cachedHostKey = hostKey;\n\n // Only store cache if in watch mode\n if (ctx.watchMode) {\n augmentHostWithCaching(host, tsSourceFileCache);\n }\n }\n\n if (!jit) {\n const externalizeStyles = !!tsCompilerOptions['externalRuntimeStyles'];\n const stylesheetRegistry = ctx.styles.resetRegistry(externalizeStyles);\n debugStyles('stylesheet registry initialized (NgtscProgram path)', {\n externalizeStyles,\n });\n augmentHostWithResources(host, styleTransform, {\n inlineStylesExtension: ctx.options.inlineStylesExtension,\n isProd,\n stylesheetRegistry,\n sourceFileCache,\n stylePreprocessor: ctx.stylePreprocessor,\n logger: ctx.resolvedConfig?.logger,\n });\n }\n\n /**\n * Creates a new NgtscProgram to analyze/re-analyze\n * the source files and create a file emitter.\n * This is shared between an initial build and a hot update.\n */\n let typeScriptProgram: ts.Program;\n let angularCompiler: NgtscProgram['compiler'] | undefined;\n // Declaration changes can invalidate diagnostics in unchanged consumers.\n let builder:\n | ts.BuilderProgram\n | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n const oldBuilder = ids?.some((id) => EXCLUDED_TS_EXT_REGEX.test(id))\n ? undefined\n : (cachedBuilder ?? ts.readBuilderProgram(tsCompilerOptions, host));\n\n if (!jit) {\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram: NgtscProgram = new compilerCli.NgtscProgram(\n rootNames,\n tsCompilerOptions,\n host,\n nextProgram,\n );\n angularCompiler = angularProgram.compiler;\n typeScriptProgram = angularProgram.compiler.getCurrentProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n host,\n oldBuilder as ts.EmitAndSemanticDiagnosticsBuilderProgram,\n );\n\n nextProgram = angularProgram;\n } else {\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n rootNames,\n tsCompilerOptions,\n host,\n oldBuilder as ts.EmitAndSemanticDiagnosticsBuilderProgram,\n );\n\n typeScriptProgram = builder.getProgram();\n }\n\n if (!ctx.watchMode) {\n // When not in watch mode, the startup cost of the incremental analysis can be avoided by\n // using an abstract builder that only wraps a TypeScript program.\n builder = ts.createAbstractBuilder(typeScriptProgram, host, oldBuilder);\n }\n cachedBuilder = builder;\n\n if (angularCompiler) {\n await angularCompiler.analyzeAsync();\n\n if (!ctx.options.disableTypeChecking) {\n // TypeScript builds the program diagnostics lazily and records why each\n // file is in the program as an index into `referencedFiles`, which\n // includes the shim references Angular tags onto every source file.\n // `prepareEmit()` below removes those tags, so a diagnostic that\n // explains a file (e.g. TS6059 for a file outside `rootDir`) would\n // otherwise throw while it is built for the first file's diagnostics.\n typeScriptProgram.getOptionsDiagnostics();\n }\n }\n\n const beforeTransformers = jit\n ? [\n compilerCli.constructorParametersDownlevelTransform(\n builder.getProgram(),\n ),\n createJitResourceTransformer(() =>\n builder.getProgram().getTypeChecker(),\n ),\n ]\n : [];\n\n const transformers = mergeTransformers(\n { before: beforeTransformers },\n jit ? {} : angularCompiler!.prepareEmit().transformers,\n );\n\n const fileMetadata = getFileMetadata(\n builder,\n angularCompiler,\n ctx.options.liveReload,\n ctx.options.disableTypeChecking,\n ctx.hmr.classNames,\n );\n\n const writeFileCallback: ts.WriteFileCallback = (\n _filename,\n content,\n _a,\n _b,\n sourceFiles,\n ) => {\n if (!sourceFiles?.length) {\n return;\n }\n\n const filename = normalizePath(sourceFiles[0].fileName);\n\n // Skip declaration outputs and declaration source files.\n if (\n filename.includes('ngtypecheck.ts') ||\n filename.includes('.d.') ||\n _filename.endsWith('.d.ts') ||\n _filename.endsWith('.d.mts') ||\n _filename.endsWith('.d.cts')\n ) {\n return;\n }\n\n // TS emits the .js.map file separately — attach it to the entry for\n // the same source file so the transform hook can return the map and\n // coverage tools can chain maps back to the original TS. The .map can\n // arrive before or after the .js, so upsert in either order. Match\n // only `.js.map` (not `.d.ts.map`) so a future `declarationMap: true`\n // doesn't clobber the JS source map with the declaration map.\n if (/\\.[cm]?js\\.map$/.test(_filename)) {\n const existing = outputFiles.get(filename);\n outputFiles.set(filename, {\n ...(existing ?? { dependencies: [] }),\n map: content,\n });\n return;\n }\n\n const metadata = ctx.watchMode ? fileMetadata(filename) : {};\n const existing = outputFiles.get(filename);\n\n outputFiles.set(filename, {\n ...(existing ?? {}),\n content,\n dependencies: [],\n errors: metadata.errors,\n warnings: metadata.warnings,\n hmrUpdateCode: metadata.hmrUpdateCode,\n hmrEligible: metadata.hmrEligible,\n });\n debugEmitV('registered ngtsc output', {\n filename,\n ...describeEmitMarkers(content),\n errorCount: metadata.errors?.length ?? 0,\n warningCount: metadata.warnings?.length ?? 0,\n hmrEligible: !!metadata.hmrEligible,\n knownOutputCount: outputFiles.size,\n });\n };\n\n const writeOutputFile = (id: string): void => {\n const sourceFile = builder.getSourceFile(id);\n if (!sourceFile) {\n return;\n }\n\n let content = '';\n let map: string | undefined;\n let mapFilename: string | undefined;\n builder.emit(\n sourceFile,\n (filename, data) => {\n if (/\\.[cm]?js$/.test(filename)) {\n content = data;\n }\n\n if (/\\.[cm]?js\\.map$/.test(filename)) {\n map = data;\n mapFilename = filename;\n }\n\n if (\n !ctx.watchMode &&\n !isTest &&\n /\\.d\\.ts/.test(filename) &&\n !filename.includes('.ngtypecheck.')\n ) {\n // output to library root instead /src\n const declarationPath = resolve(\n config.root,\n config.build.outDir,\n relative(config.root, filename),\n ).replace('/src/', '/');\n\n const declarationFileDir = declarationPath\n .replace(basename(filename), '')\n .replace('/src/', '/');\n\n declarationFiles.push({\n declarationFileDir,\n declarationPath,\n data,\n });\n }\n },\n undefined /* cancellationToken */,\n undefined /* emitOnlyDtsFiles */,\n transformers,\n );\n\n writeFileCallback(id, content, false, undefined, [sourceFile]);\n if (map !== undefined && mapFilename !== undefined) {\n // Use the filename TypeScript emitted (handles `.cts`/`.mts` as well\n // as `.ts`) instead of regex-replacing the source `.ts` extension.\n writeFileCallback(mapFilename, map, false, undefined, [sourceFile]);\n }\n\n if (angularCompiler) {\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n };\n\n if (ctx.watchMode) {\n if (ids && ids.length > 0) {\n ids.forEach((id) => writeOutputFile(id));\n } else if (isTest) {\n /**\n * Only block the server from starting up\n * during testing.\n */\n while (\n (\n builder as ts.EmitAndSemanticDiagnosticsBuilderProgram\n ).emitNextAffectedFile(\n writeFileCallback,\n undefined,\n undefined,\n transformers,\n )\n ) {\n /* empty */\n }\n }\n }\n\n if (!isTest) {\n /**\n * Perf: Output files on demand so the dev server\n * isn't blocked when emitting files.\n */\n outputFile = writeOutputFile;\n }\n }\n\n return {\n name: '@analogjs/vite-plugin-angular',\n api: compilerApi,\n async config(config, { command, mode }) {\n activateDeferredDebug(command);\n const resolution = ctx.initConfig(config, { command, mode });\n\n // Do a preliminary resolution for dep optimizer (before configResolved)\n const preliminaryTsConfigPath = ctx.resolveTsConfigPath();\n\n const esbuild = config.esbuild ?? false;\n const oxc = config.oxc ?? false;\n const jsTransformConfigKey = getJsTransformConfigKey();\n const jsTransformConfigValue =\n jsTransformConfigKey === 'oxc' ? oxc : esbuild;\n\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: preliminaryTsConfigPath,\n isProd: resolution.isProd,\n jit: ctx.options.jit,\n watchMode: ctx.watchMode,\n isTest: ctx.options.isTest,\n isAstroIntegration: ctx.options.isAstroIntegration,\n });\n\n return {\n [jsTransformConfigKey]: jsTransformConfigValue,\n ...depOptimizer,\n };\n },\n configResolved(config) {\n ctx.setResolvedConfig(config);\n\n if (!jit) {\n styleTransform = (code: string, filename: string) =>\n preprocessCSS(code, filename, config);\n }\n },\n configureServer(server) {\n viteServer = server;\n hotUpdates.configureServer(server);\n\n // Add/unlink changes the TypeScript program shape, not just file\n // contents, so we need to invalidate both include discovery and the\n // cached tsconfig root names before recompiling.\n const invalidateCompilationOnFsChange = createFsWatcherCacheInvalidator(\n invalidateFsCaches,\n invalidateTsconfigCaches,\n () => performCompilation(ctx.resolvedConfig!),\n );\n server.watcher.on('add', (file) => {\n if (EXCLUDED_TS_EXT_REGEX.test(file)) {\n invalidateSourceFiles(new Set([normalizePath(file)]));\n }\n return invalidateCompilationOnFsChange();\n });\n server.watcher.on('unlink', (file) => {\n const id = normalizePath(file);\n outputFiles.delete(id);\n tsSourceFileCache.delete(id);\n sourceFileCache.invalidate(new Set([id]));\n evictDeletedFileMetadata(file, {\n classNamesMap: ctx.hmr.classNames,\n fileTransformMap,\n });\n return invalidateCompilationOnFsChange();\n });\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n activeBuilds++;\n // Vite keys its CSS preprocessor worker cache by the top-level resolved\n // config object. Passing `this.environment.config` misses that cache\n // and falls back to a worker Vite never closes, which keeps Vitest\n // from exiting after AOT tests with `.scss` styleUrls. (#2556)\n if (!jit) {\n styleTransform = (code: string, filename: string) =>\n preprocessCSS(code, filename, ctx.resolvedConfig!);\n }\n\n // Browser mode also creates a server that may never transform TypeScript.\n if (!ctx.deferInitialCompilation) {\n pendingCompilation = performCompilation(\n (this.environment?.config as unknown as ResolvedConfig | undefined) ??\n ctx.resolvedConfig!,\n );\n await pendingCompilation;\n pendingCompilation = null;\n\n initialCompilation = true;\n }\n },\n async buildEnd(): Promise<void> {\n // Environments (e.g. client and ssr) build in parallel and share this\n // plugin's compilation state, so only reset after the last one ends.\n activeBuilds = Math.max(0, activeBuilds - 1);\n if (activeBuilds > 0) return;\n if (closeRequested) {\n await closeCompilation();\n return;\n }\n if (!ctx.watchMode) releaseCompilation();\n },\n async handleHotUpdate(hmrCtx) {\n if (ctx.hmr.isIgnoredFile(hmrCtx.file)) {\n debugHmr('ignored file change', { file: hmrCtx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(hmrCtx.file)) {\n const [fileId] = hmrCtx.file.split('?');\n debugHmr('TS file changed', { file: hmrCtx.file, fileId });\n\n await hotUpdates.schedule(hmrCtx.file, [fileId]);\n\n if (EXCLUDED_TS_EXT_REGEX.test(fileId)) {\n // Declaration dependencies have no runtime modules for Vite to invalidate.\n hmrCtx.server.moduleGraph.invalidateAll();\n hmrCtx.server.ws.send({ type: 'full-reload', triggeredBy: fileId });\n return [];\n }\n\n let result: EmitFileResult | undefined;\n\n if (ctx.shouldEnableLiveReload()) {\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!ctx.hmr.classNames.get(fileId),\n });\n debugHmrV('ts hmr evaluation', {\n file: hmrCtx.file,\n fileId,\n hasResult: !!result,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!ctx.hmr.classNames.get(fileId),\n className: ctx.hmr.classNames.get(fileId),\n updateCode: result?.hmrUpdateCode\n ? describeStylesheetContent(result.hmrUpdateCode)\n : undefined,\n errors: result?.errors?.length ?? 0,\n warnings: result?.warnings?.length ?? 0,\n hint: result?.hmrEligible\n ? 'A TS-side component change, including inline template edits, produced an Angular HMR payload.'\n : 'No Angular HMR payload was emitted for this TS change; the change may not affect component template state.',\n });\n }\n\n if (\n ctx.shouldEnableLiveReload() &&\n result?.hmrEligible &&\n ctx.hmr.classNames.get(fileId)\n ) {\n const relativeFileId = ctx.hmr.toComponentUpdateId(fileId);\n\n debugHmr('sending component update', { relativeFileId });\n debugHmrV('ts hmr component update payload', {\n file: hmrCtx.file,\n fileId,\n relativeFileId,\n className: ctx.hmr.classNames.get(fileId),\n });\n ctx.hmr.sendComponentUpdate(hmrCtx.server, relativeFileId);\n\n return hmrCtx.modules.map((mod) => {\n if (mod.id === hmrCtx.file) {\n return markModuleSelfAccepting(mod);\n }\n\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm|css|less|sass|scss)$/.test(hmrCtx.file)) {\n debugHmr('resource file changed', { file: hmrCtx.file });\n fileTransformMap.delete(hmrCtx.file.split('?')[0]);\n // Angular component resources frequently enter HMR with incomplete\n // watcher context. In practice `ctx.modules` may only contain the\n // source file, only the `?direct` module, or nothing at all after a\n // TS-driven component refresh. Resolve the full live module set from\n // Vite's module graph and our stylesheet registry before deciding how\n // to hot update the resource.\n const stylesheetRegistry = ctx.styles.registry;\n const fileModules = await getModulesForChangedFile(\n hmrCtx.server,\n hmrCtx.file,\n hmrCtx.modules,\n stylesheetRegistry,\n );\n /**\n * Check to see if this was a direct request\n * for an external resource (styles, html).\n */\n const isDirect = fileModules.find(\n (mod) =>\n !!mod.id &&\n mod.id.includes('?direct') &&\n isModuleForChangedResource(mod, hmrCtx.file, stylesheetRegistry),\n );\n const isInline = fileModules.find(\n (mod) =>\n !!mod.id &&\n mod.id.includes('?inline') &&\n isModuleForChangedResource(mod, hmrCtx.file, stylesheetRegistry),\n );\n debugHmrV('resource direct/inline detection', {\n file: hmrCtx.file,\n hasDirect: !!isDirect,\n directId: isDirect?.id,\n hasInline: !!isInline,\n inlineId: isInline?.id,\n });\n\n if (isDirect || isInline) {\n if (ctx.shouldExternalizeStyles() && isDirect?.id && isDirect.file) {\n const isComponentStyle =\n isDirect.type === 'css' && isComponentStyleSheet(isDirect.id);\n debugHmrV('resource direct branch', {\n file: hmrCtx.file,\n directId: isDirect.id,\n directType: isDirect.type,\n shouldExternalize: ctx.shouldExternalizeStyles(),\n isComponentStyle,\n });\n if (isComponentStyle) {\n return handleDirectComponentStyleHmr({\n server: hmrCtx.server,\n file: hmrCtx.file,\n directModule: isDirect,\n fileModules,\n stylesheetRegistry,\n stylePreprocessor: ctx.stylePreprocessor,\n });\n }\n }\n return fileModules;\n }\n\n if (\n ctx.shouldEnableLiveReload() &&\n /\\.(html|htm)$/.test(hmrCtx.file) &&\n fileModules.length === 0\n ) {\n const ownerModules = findTemplateOwnerModules(\n hmrCtx.server,\n hmrCtx.file,\n );\n debugHmrV('template owner lookup', {\n file: hmrCtx.file,\n ownerCount: ownerModules.length,\n ownerIds: ownerModules.map((mod) => mod.id),\n hint:\n ownerModules.length > 0\n ? 'The external template has candidate TS owner modules that can be recompiled for HMR.'\n : 'No TS owner modules were visible for this external template change; HMR will fall through to the generic importer path.',\n });\n if (ownerModules.length > 0) {\n const ownerIds = ownerModules\n .map((mod) => mod.id)\n .filter(Boolean) as string[];\n\n ownerModules.forEach((mod) =>\n hmrCtx.server.moduleGraph.invalidateModule(mod),\n );\n\n await hotUpdates.schedule(hmrCtx.file, ownerIds);\n\n const updates = ownerIds.filter((id) => ctx.hmr.classNames.get(id));\n debugHmrV('template owner recompilation result', {\n file: hmrCtx.file,\n ownerIds,\n updates,\n updateClassNames: updates.map((id) => ({\n id,\n className: ctx.hmr.classNames.get(id),\n })),\n hint:\n updates.length > 0\n ? 'External template recompilation produced Angular component update targets.'\n : 'External template recompilation completed, but no Angular component update targets were surfaced.',\n });\n if (updates.length > 0) {\n debugHmr('template owner module invalidation', {\n file: hmrCtx.file,\n ownerIds,\n updateCount: updates.length,\n });\n updates.forEach((updateId) => {\n ctx.hmr.sendComponentUpdate(\n hmrCtx.server,\n ctx.hmr.toComponentUpdateId(updateId),\n );\n });\n\n return ownerModules.map((mod) => markModuleSelfAccepting(mod));\n }\n }\n }\n\n const mods: ModuleNode[] = [];\n const updates: string[] = [];\n fileModules.forEach((mod) => {\n mod.importers.forEach((imp) => {\n hmrCtx.server.moduleGraph.invalidateModule(imp);\n\n if (\n ctx.shouldExternalizeStyles() &&\n imp.id &&\n ctx.hmr.classNames.get(imp.id)\n ) {\n updates.push(imp.id);\n } else {\n mods.push(imp);\n }\n });\n });\n debugHmrV('resource importer analysis', {\n file: hmrCtx.file,\n fileModuleCount: fileModules.length,\n importerCount: fileModules.reduce(\n (count, mod) => count + mod.importers.size,\n 0,\n ),\n updates,\n mods: mods.map((mod) => mod.id),\n });\n\n if (mods.length === 0 && updates.length === 0) return mods;\n\n await hotUpdates.schedule(hmrCtx.file, [\n ...mods.map((mod) => mod.id as string),\n ...updates,\n ]);\n\n if (updates.length > 0) {\n debugHmr('resource importer component updates', {\n file: hmrCtx.file,\n updateCount: updates.length,\n });\n updates.forEach((updateId) => {\n ctx.hmr.sendComponentUpdate(\n hmrCtx.server,\n ctx.hmr.toComponentUpdateId(updateId),\n );\n });\n\n return fileModules.map((mod) => {\n if (mod.id === hmrCtx.file) {\n return markModuleSelfAccepting(mod);\n }\n\n return mod;\n });\n }\n\n return mods;\n }\n\n // clear HMR updates with a full reload\n debugHmr('full reload — unrecognized file type', { file: hmrCtx.file });\n ctx.hmr.clear();\n return hmrCtx.modules;\n },\n resolveId(id, importer) {\n const virtualId = resolveAngularVirtualId(id, importer, {\n jit,\n resolvedConfig: ctx.resolvedConfig,\n });\n if (virtualId !== undefined) {\n return virtualId;\n }\n\n return ctx.styles.resolveComponentStyleId(id);\n },\n async load(id) {\n const virtualModule = await loadAngularVirtualModule(\n this,\n id,\n ctx.resolvedConfig,\n );\n if (virtualModule !== undefined) {\n return virtualModule;\n }\n\n return ctx.styles.loadComponentStyle(id);\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 (ctx.transformFilter && !ctx.transformFilter(code, id)) {\n return;\n }\n\n // Encapsulation of component stylesheets is handled by the\n // separate '@analogjs/vite-plugin-angular:encapsulation' plugin\n // with enforce: 'post'. This ensures @tailwindcss/vite (enforce:\n // 'pre') fully resolves @apply directives — including those inside\n // :host {} — before Angular's ShadowCss rewrites selectors. (#2293)\n\n if (id.includes('.ts?')) {\n // Strip the query string off the ID\n // in case of a dynamically loaded file\n id = id.replace(/\\?(.*)/, '');\n }\n\n fileTransformMap.set(id, code);\n\n /**\n * Re-analyze on each transform\n * for test(Vitest)\n */\n if (isTest) {\n if (ctx.deferInitialCompilation && !initialCompilation) {\n // Do full initial compilation\n pendingCompilation = performCompilation(\n (this.environment?.config as unknown as\n | ResolvedConfig\n | undefined) ?? ctx.resolvedConfig!,\n );\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n\n if (ctx.testWatchMode && invalidated) {\n pendingCompilation = performCompilation(\n (this.environment?.config as unknown as\n | ResolvedConfig\n | undefined) ?? ctx.resolvedConfig!,\n [id],\n );\n }\n }\n }\n\n const hasComponent = code.includes('@Component');\n debugCompilerV('transform', {\n id,\n codeLength: code.length,\n hasComponent,\n });\n // Resource URLs are only consumed for watch-file registration and\n // JIT rewrites, so skip resolution entirely in prod AOT builds.\n const resolveResourceUrls = hasComponent && (ctx.watchMode || jit);\n const templateUrls = resolveResourceUrls\n ? templateUrlsResolver.resolve(code, id)\n : [];\n const styleUrls = resolveResourceUrls\n ? styleUrlsResolver.resolve(code, id)\n : [];\n\n if (resolveResourceUrls && ctx.watchMode) {\n for (const urlSet of [...templateUrls, ...styleUrls]) {\n // `urlSet` is a string where a relative path is joined with an\n // absolute path using the `|` symbol.\n // For example: `./app.component.html|/home/projects/analog/src/app/app.component.html`.\n const [, absoluteFileUrl] = urlSet.split('|');\n this.addWatchFile(absoluteFileUrl);\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n await hotUpdates.wait();\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilerV('transform skip (file not emitted by Angular)', {\n id,\n });\n // File not in the Angular program — skip and let other plugins\n // or Vite's built-in transform handle it. Warn if it looks like\n // an Angular file that should have been compiled.\n const isAngular =\n !id.includes('@ng/component') &&\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n debugEmit('transform emit miss', {\n id,\n normalizedId: normalizeEmitterLookupId(id),\n knownOutputCount: outputFiles.size,\n hasOutputFileHook: !!outputFile,\n isAngular,\n });\n\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\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 debugEmitV('transform emit hit', {\n id,\n normalizedId: normalizeEmitterLookupId(id),\n ...describeEmitMarkers(data),\n errorCount: typescriptResult.errors?.length ?? 0,\n warningCount: typescriptResult.warnings?.length ?? 0,\n });\n\n if (jit && data.includes('angular:jit:')) {\n // The emitted id carries the base64 of the entire stylesheet,\n // and the bundler derives chunk names from it — hash it so a\n // large inline style can't produce an over-long filename (#2459).\n data = data.replace(\n /angular:jit:style:inline;([A-Za-z0-9+/=]*)/g,\n (_match, encodedStyles) =>\n toJitInlineStyleId(encodedStyles, isTest),\n );\n\n // Templates use virtual ids (no extension) so Vite's asset/CSS\n // plugins don't interfere. (#2263)\n templateUrls.forEach((templateUrlSet) => {\n const [templateFile, resolvedTemplateUrl] =\n templateUrlSet.split('|');\n data = data.replace(\n `angular:jit:template:file;${templateFile}`,\n toVirtualRawId(resolvedTemplateUrl),\n );\n });\n\n // External styles use native ?inline imports. We mark each\n // path as safe in Vite's safeModulePaths so the Denied ID\n // security check passes, and Vite's CSS pipeline handles\n // preprocessing, test.css, and browser/node differences\n // natively. (#2263, #2310)\n styleUrls.forEach((styleUrlSet) => {\n const [styleFile, resolvedStyleUrl] = styleUrlSet.split('|');\n markStylePathSafe(ctx.resolvedConfig, resolvedStyleUrl);\n data = data.replace(\n `angular:jit:style:file;${styleFile}`,\n resolvedStyleUrl + '?inline',\n );\n });\n }\n\n // Angular's HMR initializer emits dynamic import() calls that Vite's\n // import-analysis plugin cannot statically analyze, producing SSR\n // warnings. The Angular compiler's IR includes a @vite-ignore comment\n // but it can be lost during TypeScript emit. Re-inject it here so the\n // warning is suppressed regardless of the compilation path used.\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n debugHmrV('vite-ignore injection', {\n id,\n dataLength: data.length,\n hasMetaUrl,\n });\n if (hasMetaUrl) {\n const patched = injectViteIgnoreForHmrMetadata(data);\n if (patched !== data && !patched.includes('@vite-ignore')) {\n debugHmrV('vite-ignore regex fallback', { id });\n }\n data = patched;\n }\n }\n if (typescriptResult.map) {\n // TS emits `//# sourceMappingURL=foo.js.map` at the end of the\n // .js content, but the .map file isn't served by Vite — we\n // return the map object directly. Strip the stale reference so\n // downstream tools don't see two sourceMappingURL comments.\n data = data.replace(/\\s*\\/\\/# sourceMappingURL=[^\\r\\n]*\\s*$/, '');\n }\n\n return {\n code: data,\n map: typescriptResult.map\n ? normalizeSourceMapSources(typescriptResult.map, id)\n : null,\n };\n },\n },\n async closeBundle(): Promise<void> {\n closeRequested = true;\n if (activeBuilds === 0) {\n await closeCompilation();\n }\n },\n };\n}\n\n/**\n * @internal\n */\nexport function getFileMetadata(\n program: ts.BuilderProgram,\n angularCompiler?: NgtscProgram['compiler'],\n hmrEnabled?: boolean,\n disableTypeChecking?: boolean,\n classNamesMap: Map<string, string> = new Map(),\n): (file: string) => FileMetadataResult {\n const ts = require('typescript') as typeof import('typescript');\n return (file: string): FileMetadataResult => {\n const sourceFile = program.getSourceFile(file);\n if (!sourceFile) {\n return {};\n }\n\n const diagnostics = getDiagnosticsForSourceFile(\n sourceFile,\n !!disableTypeChecking,\n program,\n angularCompiler,\n );\n\n const errors = diagnostics\n .filter((d) => d.category === ts.DiagnosticCategory?.Error)\n .map((d) =>\n typeof d.messageText === 'object'\n ? d.messageText.messageText\n : d.messageText,\n );\n\n const warnings = diagnostics\n .filter((d) => d.category === ts.DiagnosticCategory?.Warning)\n .map((d) => d.messageText);\n\n let hmrUpdateCode: string | null | undefined = undefined;\n\n let hmrEligible = false;\n if (hmrEnabled) {\n for (const node of sourceFile.statements) {\n if (ts.isClassDeclaration(node) && node.name != null) {\n hmrUpdateCode = angularCompiler?.emitHmrUpdateModule(node);\n if (hmrUpdateCode) {\n const className = node.name.getText();\n classNamesMap.set(file, className);\n hmrEligible = true;\n debugHmr('NgtscProgram emitHmrUpdateModule', { file, className });\n }\n }\n }\n }\n\n return { errors, warnings, hmrUpdateCode, hmrEligible };\n };\n}\n\nfunction getDiagnosticsForSourceFile(\n sourceFile: ts.SourceFile,\n disableTypeChecking: boolean,\n program: ts.BuilderProgram,\n angularCompiler?: NgtscProgram['compiler'],\n): readonly ts.Diagnostic[] {\n const syntacticDiagnostics = program.getSyntacticDiagnostics(sourceFile);\n\n if (disableTypeChecking) {\n // Syntax errors are cheap to compute and the app will not run if there are any\n // So always show these types of errors regardless if type checking is disabled\n return syntacticDiagnostics;\n }\n\n const semanticDiagnostics = program.getSemanticDiagnostics(sourceFile);\n const angularDiagnostics = angularCompiler\n ? angularCompiler.getDiagnosticsForFile(sourceFile, 1)\n : [];\n return [\n ...syntacticDiagnostics,\n ...semanticDiagnostics,\n ...angularDiagnostics,\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyFA,IAAM,UAAU,cAAc,YAAY,GAAG;AAe7C,SAAgB,yBACd,MACA,EACE,eACA,oBAKI;CACN,MAAM,iBAAiB,cAAc,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE;CACvD,cAAc,OAAO,cAAc;CACnC,iBAAiB,OAAO,cAAc;AACxC;AAEA,SAAgB,gCACd,oBACA,0BACA,oBACqB;CACrB,OAAO,YAA2B;EAChC,mBAAmB;EACnB,yBAAyB;EACzB,MAAM,mBAAmB;CAC3B;AACF;;;;AAKA,SAAgB,mBACd,cACQ;CACR,MAAM,MAAM,sBAAsB,YAAY,IAC1C,eACA,0BAA0B;EACxB,GAAG;EACH,oBAAoB;CACtB,CAAC;CAEL,MAAM,KAAK,QAAQ,YAAY;CAE/B,IAAI;CAIJ,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,SAAS,qBAA2B;EAClC,IAAI,iBAAiB,uBAAuB;CAC9C;CAEA,SAAS,2BAAiC;EACxC,IAAI,iBAAiB,yBAAyB;EAC9C,aAAa,KAAA;EACb,gBAAgB,KAAA;CAClB;CAEA,MAAM,kBAAuC,IAAI,gBAAgB;CACjE,MAAM,oCAAoB,IAAI,IAA2B;CAEzD,SAAS,sBAAsB,OAA0B;EACvD,KAAK,MAAM,QAAQ,OACjB,kBAAkB,OAAO,cAAc,IAAI,CAAC;EAE9C,gBAAgB,WAAW,KAAK;CAClC;CAEA,MAAM,EAAE,KAAK,WAAW,IAAI;CAC5B,IAAI;CAEJ,MAAM,oBAAoB,IAAI,kBAAkB;CAChD,MAAM,uBAAuB,IAAI,qBAAqB;CACtD,IAA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,KAAK,QAAQ,YAAY;CAC/B,QAAQ,SAAqC;EAC3C,MAAM,aAAa,QAAQ,cAAc,IAAI;EAC7C,IAAI,CAAC,YACH,OAAO,CAAC;EAGV,MAAM,cAAc,4BAClB,YACA,CAAC,CAAC,qBACF,SACA,eACF;EAEA,MAAM,SAAS,YACZ,QAAQ,MAAM,EAAE,aAAa,GAAG,oBAAoB,KAAK,CAAC,CAC1D,KAAK,MACJ,OAAO,EAAE,gBAAgB,WACrB,EAAE,YAAY,cACd,EAAE,WACR;EAEF,MAAM,WAAW,YACd,QAAQ,MAAM,EAAE,aAAa,GAAG,oBAAoB,OAAO,CAAC,CAC5D,KAAK,MAAM,EAAE,WAAW;EAE3B,IAAI,gBAA2C,KAAA;EAE/C,IAAI,cAAc;EAClB,IAAI,YACG;QAAA,MAAM,QAAQ,WAAW,YAC5B,IAAI,GAAG,mBAAmB,IAAI,KAAK,KAAK,QAAQ,MAAM;IACpD,gBAAgB,iBAAiB,oBAAoB,IAAI;IACzD,IAAI,eAAe;KACjB,MAAM,YAAY,KAAK,KAAK,QAAQ;KACpC,cAAc,IAAI,MAAM,SAAS;KACjC,cAAc;KACd,SAAS,oCAAoC;MAAE;MAAM;KAAU,CAAC;IAClE;GACF;;EAIJ,OAAO;GAAE;GAAQ;GAAU;GAAe;EAAY;CACxD;AACF;AAEA,SAAS,4BACP,YACA,qBACA,SACA,iBAC0B;CAC1B,MAAM,uBAAuB,QAAQ,wBAAwB,UAAU;CAEvE,IAAI,qBAGF,OAAO;CAGT,MAAM,sBAAsB,QAAQ,uBAAuB,UAAU;CACrE,MAAM,qBAAqB,kBACvB,gBAAgB,sBAAsB,YAAY,CAAC,IACnD,CAAC;CACL,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;CACL;AACF"}
1
+ {"version":3,"file":"ngtsc-compile-plugin.js","names":[],"sources":["../../../src/lib/ngtsc-compile-plugin.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport {\n basename,\n dirname,\n isAbsolute,\n join,\n relative,\n resolve,\n} from 'node:path';\nimport { union } from 'es-toolkit';\nimport * as compilerCli from '@angular/compiler-cli';\nimport type { NgtscProgram } from '@angular/compiler-cli';\nimport type * as ts from 'typescript';\nimport type * as vite from 'vite';\nimport {\n normalizePath,\n preprocessCSS,\n type ModuleNode,\n type Plugin,\n type ResolvedConfig,\n type ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n StyleUrlsResolver,\n TemplateUrlsResolver,\n} from './component-resolvers.js';\nimport {\n findTemplateOwnerModules,\n getModulesForChangedFile,\n handleDirectComponentStyleHmr,\n isModuleForChangedResource,\n markModuleSelfAccepting,\n} from './component-styles-plugin.js';\nimport { isComponentStyleSheet } from './encapsulation-plugin.js';\nimport {\n augmentHostWithCaching,\n augmentHostWithModuleResolution,\n augmentHostWithResources,\n augmentProgramWithVersioning,\n mergeTransformers,\n} from './host.js';\nimport { createHotUpdateBatcher } from './hot-update-batch.js';\nimport type { EmitFileResult } from './models.js';\nimport type {\n FileReplacementSSR,\n FileReplacementWith,\n} from './plugins/file-replacements.plugin.js';\nimport {\n describeStylesheetContent,\n injectViteIgnoreForHmrMetadata,\n} from './utils/compilation-shared.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport {\n activateDeferredDebug,\n debugCompiler,\n debugCompilerV,\n debugEmit,\n debugEmitV,\n debugHmr,\n debugHmrV,\n debugStyles,\n} from './utils/debug.js';\nimport {\n createJitResourceTransformer,\n SourceFileCache,\n} from './utils/devkit.js';\nimport { toJitInlineStyleId } from './utils/jit-inline-styles.js';\nimport {\n createDepOptimizerConfig,\n EXCLUDED_TS_EXT_REGEX,\n TS_EXT_REGEX,\n} from './utils/plugin-config.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\nimport { markStylePathSafe } from './utils/safe-module-paths.js';\nimport type { SourceFileCache as SourceFileCacheType } from './utils/source-file-cache.js';\nimport { toVirtualRawId } from './utils/virtual-ids.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nconst require = createRequire(import.meta.url);\n\ninterface DeclarationFile {\n declarationFileDir: string;\n declarationPath: string;\n data: string;\n}\n\nexport interface FileMetadataResult {\n errors?: string[];\n warnings?: (string | ts.DiagnosticMessageChain)[];\n hmrUpdateCode?: string | null;\n hmrEligible?: boolean;\n}\n\nexport function evictDeletedFileMetadata(\n file: string,\n {\n classNamesMap,\n fileTransformMap,\n }: {\n classNamesMap: Map<string, string>;\n fileTransformMap: Map<string, string>;\n },\n): void {\n const normalizedFile = normalizePath(file.split('?')[0]);\n classNamesMap.delete(normalizedFile);\n fileTransformMap.delete(normalizedFile);\n}\n\nexport function createFsWatcherCacheInvalidator(\n invalidateFsCaches: () => void,\n invalidateTsconfigCaches: () => void,\n performCompilation: () => Promise<void>,\n): () => Promise<void> {\n return async (): Promise<void> => {\n invalidateFsCaches();\n invalidateTsconfigCaches();\n await performCompilation();\n };\n}\n\n/**\n * Compiles Angular TypeScript sources using `@angular/compiler-cli` (`NgtscProgram`).\n */\nexport function ngtscCompilePlugin(\n ctxOrOptions?: AngularBuildContext | AngularBuildContextOptions,\n): Plugin {\n const ctx = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions\n : createAngularBuildContext({\n ...ctxOrOptions,\n compilationBackend: 'ngtsc',\n });\n\n const ts = require('typescript') as typeof import('typescript');\n\n let cachedBuilder:\n | ts.BuilderProgram\n | ts.EmitAndSemanticDiagnosticsBuilderProgram\n | undefined;\n let nextProgram: NgtscProgram | undefined;\n let cachedHost: ts.CompilerHost | undefined;\n let cachedHostKey: string | undefined;\n\n function invalidateFsCaches(): void {\n ctx.tsconfigResolver.invalidateIncludeCache();\n }\n\n function invalidateTsconfigCaches(): void {\n ctx.tsconfigResolver.invalidateTsconfigCaches();\n cachedHost = undefined;\n cachedHostKey = undefined;\n }\n\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const tsSourceFileCache = new Map<string, ts.SourceFile>();\n\n function invalidateSourceFiles(files: Set<string>): void {\n for (const file of files) {\n tsSourceFileCache.delete(normalizePath(file));\n }\n sourceFileCache.invalidate(files);\n }\n\n const { jit, isTest } = ctx.options;\n let viteServer: ViteDevServer | undefined;\n\n const styleUrlsResolver = new StyleUrlsResolver();\n const templateUrlsResolver = new TemplateUrlsResolver();\n let outputFile: ((file: string) => void) | undefined;\n const outputFiles = new Map<string, EmitFileResult>();\n\n const normalizeEmitterLookupId = (file: string): string => {\n const normalizedFile = normalizePath(file);\n\n if (!normalizedFile.startsWith('/@fs/')) {\n return normalizedFile;\n }\n\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n\n return normalizePath(fsPath);\n };\n\n const describeEmitMarkers = (content: string) => ({\n contentLength: content.length,\n hasCmp: content.includes('ɵcmp'),\n hasFac: content.includes('ɵfac'),\n hasProv: content.includes('ɵprov'),\n hasDecorate: content.includes('__decorate'),\n hasMetadata: content.includes('__metadata'),\n });\n\n const fileEmitter = (file: string): EmitFileResult | undefined => {\n const normalizedFile = normalizeEmitterLookupId(file);\n const hadCachedEmit = outputFiles.has(normalizedFile);\n outputFile?.(normalizedFile);\n const emittedResult = outputFiles.get(normalizedFile);\n debugEmitV('fileEmitter lookup', {\n requestFile: file,\n normalizedFile,\n hadCachedEmit,\n hasOutputFileHook: !!outputFile,\n emitted: !!emittedResult,\n knownOutputCount: outputFiles.size,\n contentLength: emittedResult?.content?.length ?? 0,\n errorCount: emittedResult?.errors?.length ?? 0,\n warningCount: emittedResult?.warnings?.length ?? 0,\n });\n return emittedResult;\n };\n\n ctx.hmr.setFileEmitter((file) => fileEmitter(file));\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: (): string => ctx.resolveTsConfigPath(),\n getSourceMap: (id: string): string | undefined =>\n outputFiles.get(normalizeEmitterLookupId(id))?.map,\n hasEmitted: (id: string): boolean =>\n outputFiles.has(normalizeEmitterLookupId(id)),\n };\n\n ctx.registerCompiler({\n name: '@analogjs/vite-plugin-angular',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n let initialCompilation = false;\n let activeBuilds = 0;\n let closeRequested = false;\n const declarationFiles: DeclarationFile[] = [];\n const fileTransformMap = new Map<string, string>();\n let styleTransform: (\n code: string,\n filename: string,\n ) => Promise<vite.PreprocessCSSResult>;\n let pendingCompilation: Promise<void> | null = null;\n let compilationLock = Promise.resolve();\n const hotUpdates = createHotUpdateBatcher((ids) =>\n performCompilation(ctx.resolvedConfig!, ids),\n );\n\n function releaseCompilation(): void {\n cachedBuilder = undefined;\n nextProgram = undefined;\n cachedHost = undefined;\n cachedHostKey = undefined;\n outputFile = undefined;\n outputFiles.clear();\n fileTransformMap.clear();\n tsSourceFileCache.clear();\n sourceFileCache.clear();\n sourceFileCache.modifiedFiles.clear();\n sourceFileCache.babelFileCache?.clear();\n sourceFileCache.typeScriptFileCache?.clear();\n sourceFileCache.referencedFiles = undefined;\n ctx.tsconfigResolver.invalidateAll();\n releaseCssPreprocessorWorkers();\n ctx.styles.clear();\n }\n\n async function closeCompilation(): Promise<void> {\n closeRequested = false;\n hotUpdates.close();\n await compilationLock;\n declarationFiles.forEach(\n ({ declarationFileDir, declarationPath, data }) => {\n mkdirSync(declarationFileDir, { recursive: true });\n writeFileSync(declarationPath, data, 'utf-8');\n },\n );\n declarationFiles.length = 0;\n releaseCompilation();\n }\n\n function normalizeSourceMapSources(map: string, id: string): string {\n const sourceMap = JSON.parse(map) as {\n sources?: string[];\n sourceRoot?: string;\n };\n const sourceDirectory = dirname(id);\n const sourceRoot = sourceMap.sourceRoot ?? '';\n sourceMap.sources = sourceMap.sources?.map((source) => {\n if (isAbsolute(source) || /^[a-z][a-z\\d+.-]*:/i.test(source)) {\n return normalizePath(source);\n }\n return normalizePath(resolve(sourceDirectory, sourceRoot, source));\n });\n delete sourceMap.sourceRoot;\n return JSON.stringify(sourceMap);\n }\n\n async function performCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ): Promise<void> {\n let releaseLock: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n releaseLock = r;\n });\n try {\n await previousLock;\n await ctx.refreshIntegrations(config);\n await _doPerformCompilation(config, ids);\n } finally {\n releaseLock!();\n }\n }\n\n /**\n * This method shares mutable state and performs the actual compilation work.\n * It should not be called concurrently. Use `performCompilation` which wraps\n * this method in a lock to ensure only one compilation runs at a time.\n */\n async function _doPerformCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ): Promise<void> {\n const isProd = config.mode === 'production';\n const modifiedFiles = new Set<string>(ids ?? []);\n invalidateSourceFiles(modifiedFiles);\n\n if (ids?.length) {\n for (const id of ids) {\n fileTransformMap.delete(id);\n }\n }\n\n const resolvedTsConfigPath = ctx.resolveTsConfigPath();\n const cached = ctx.tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n\n // Clone options before mutation (preserve cache purity)\n const tsCompilerOptions = { ...cached.options };\n let rootNames = [...cached.rootNames];\n\n if (ctx.shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (ctx.shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n // Workaround for https://github.com/angular/angular/issues/59310\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (NgtscProgram path)', {\n liveReload: ctx.options.liveReload,\n viteHmr: ctx.hasViteHmrTransport(),\n externalizeStylesRequested: ctx.externalizeStylesRequested,\n shouldExternalize: ctx.shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n // These options can't be false in partial mode\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && config.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = ctx.watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n // Allow `TestBed.overrideXXX()` APIs.\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n const replacements = ctx.options.fileReplacements.map((rp) =>\n join(\n ctx.options.workspaceRoot,\n (rp as FileReplacementSSR).ssr || (rp as FileReplacementWith).with,\n ),\n );\n // Merge + dedupe root names\n rootNames = union(\n union(rootNames, ctx.tsconfigResolver.ensureIncludeCache()),\n replacements,\n );\n const hostKey = JSON.stringify(tsCompilerOptions);\n let host: ts.CompilerHost;\n\n if (cachedHost && cachedHostKey === hostKey) {\n host = cachedHost;\n } else {\n host = ts.createIncrementalCompilerHost(tsCompilerOptions, {\n ...ts.sys,\n readFile(path: string, encoding?: string) {\n if (fileTransformMap.has(path)) {\n return fileTransformMap.get(path);\n }\n\n const file = ts.sys.readFile.call(null, path, encoding);\n\n if (file) {\n fileTransformMap.set(path, file);\n }\n\n return file;\n },\n });\n augmentHostWithModuleResolution(host, tsCompilerOptions);\n cachedHost = host;\n cachedHostKey = hostKey;\n\n // Only store cache if in watch mode\n if (ctx.watchMode) {\n augmentHostWithCaching(host, tsSourceFileCache);\n }\n }\n\n if (!jit) {\n const externalizeStyles = !!tsCompilerOptions['externalRuntimeStyles'];\n const stylesheetRegistry = ctx.styles.resetRegistry(externalizeStyles);\n debugStyles('stylesheet registry initialized (NgtscProgram path)', {\n externalizeStyles,\n });\n augmentHostWithResources(host, styleTransform, {\n inlineStylesExtension: ctx.options.inlineStylesExtension,\n isProd,\n stylesheetRegistry,\n sourceFileCache,\n stylePreprocessor: ctx.stylePreprocessor,\n logger: ctx.resolvedConfig?.logger,\n isBuild: ctx.resolvedConfig?.command === 'build',\n });\n }\n\n /**\n * Creates a new NgtscProgram to analyze/re-analyze\n * the source files and create a file emitter.\n * This is shared between an initial build and a hot update.\n */\n let typeScriptProgram: ts.Program;\n let angularCompiler: NgtscProgram['compiler'] | undefined;\n // Declaration changes can invalidate diagnostics in unchanged consumers.\n let builder:\n | ts.BuilderProgram\n | ts.EmitAndSemanticDiagnosticsBuilderProgram;\n const oldBuilder = ids?.some((id) => EXCLUDED_TS_EXT_REGEX.test(id))\n ? undefined\n : (cachedBuilder ?? ts.readBuilderProgram(tsCompilerOptions, host));\n\n if (!jit) {\n // Create the Angular specific program that contains the Angular compiler\n const angularProgram: NgtscProgram = new compilerCli.NgtscProgram(\n rootNames,\n tsCompilerOptions,\n host,\n nextProgram,\n );\n angularCompiler = angularProgram.compiler;\n typeScriptProgram = angularProgram.compiler.getCurrentProgram();\n augmentProgramWithVersioning(typeScriptProgram);\n\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n typeScriptProgram,\n host,\n oldBuilder as ts.EmitAndSemanticDiagnosticsBuilderProgram,\n );\n\n nextProgram = angularProgram;\n } else {\n builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(\n rootNames,\n tsCompilerOptions,\n host,\n oldBuilder as ts.EmitAndSemanticDiagnosticsBuilderProgram,\n );\n\n typeScriptProgram = builder.getProgram();\n }\n\n if (!ctx.watchMode) {\n // When not in watch mode, the startup cost of the incremental analysis can be avoided by\n // using an abstract builder that only wraps a TypeScript program.\n builder = ts.createAbstractBuilder(typeScriptProgram, host, oldBuilder);\n }\n cachedBuilder = builder;\n\n if (angularCompiler) {\n await angularCompiler.analyzeAsync();\n\n if (!ctx.options.disableTypeChecking) {\n // TypeScript builds the program diagnostics lazily and records why each\n // file is in the program as an index into `referencedFiles`, which\n // includes the shim references Angular tags onto every source file.\n // `prepareEmit()` below removes those tags, so a diagnostic that\n // explains a file (e.g. TS6059 for a file outside `rootDir`) would\n // otherwise throw while it is built for the first file's diagnostics.\n typeScriptProgram.getOptionsDiagnostics();\n }\n }\n\n const beforeTransformers = jit\n ? [\n compilerCli.constructorParametersDownlevelTransform(\n builder.getProgram(),\n ),\n createJitResourceTransformer(() =>\n builder.getProgram().getTypeChecker(),\n ),\n ]\n : [];\n\n const transformers = mergeTransformers(\n { before: beforeTransformers },\n jit ? {} : angularCompiler!.prepareEmit().transformers,\n );\n\n const fileMetadata = getFileMetadata(\n builder,\n angularCompiler,\n ctx.options.liveReload,\n ctx.options.disableTypeChecking,\n ctx.hmr.classNames,\n );\n\n const writeFileCallback: ts.WriteFileCallback = (\n _filename,\n content,\n _a,\n _b,\n sourceFiles,\n ) => {\n if (!sourceFiles?.length) {\n return;\n }\n\n const filename = normalizePath(sourceFiles[0].fileName);\n\n // Skip declaration outputs and declaration source files.\n if (\n filename.includes('ngtypecheck.ts') ||\n filename.includes('.d.') ||\n _filename.endsWith('.d.ts') ||\n _filename.endsWith('.d.mts') ||\n _filename.endsWith('.d.cts')\n ) {\n return;\n }\n\n // TS emits the .js.map file separately — attach it to the entry for\n // the same source file so the transform hook can return the map and\n // coverage tools can chain maps back to the original TS. The .map can\n // arrive before or after the .js, so upsert in either order. Match\n // only `.js.map` (not `.d.ts.map`) so a future `declarationMap: true`\n // doesn't clobber the JS source map with the declaration map.\n if (/\\.[cm]?js\\.map$/.test(_filename)) {\n const existing = outputFiles.get(filename);\n outputFiles.set(filename, {\n ...(existing ?? { dependencies: [] }),\n map: content,\n });\n return;\n }\n\n const metadata = ctx.watchMode ? fileMetadata(filename) : {};\n const existing = outputFiles.get(filename);\n\n outputFiles.set(filename, {\n ...(existing ?? {}),\n content,\n dependencies: [],\n errors: metadata.errors,\n warnings: metadata.warnings,\n hmrUpdateCode: metadata.hmrUpdateCode,\n hmrEligible: metadata.hmrEligible,\n });\n debugEmitV('registered ngtsc output', {\n filename,\n ...describeEmitMarkers(content),\n errorCount: metadata.errors?.length ?? 0,\n warningCount: metadata.warnings?.length ?? 0,\n hmrEligible: !!metadata.hmrEligible,\n knownOutputCount: outputFiles.size,\n });\n };\n\n const writeOutputFile = (id: string): void => {\n const sourceFile = builder.getSourceFile(id);\n if (!sourceFile) {\n return;\n }\n\n let content = '';\n let map: string | undefined;\n let mapFilename: string | undefined;\n builder.emit(\n sourceFile,\n (filename, data) => {\n if (/\\.[cm]?js$/.test(filename)) {\n content = data;\n }\n\n if (/\\.[cm]?js\\.map$/.test(filename)) {\n map = data;\n mapFilename = filename;\n }\n\n if (\n !ctx.watchMode &&\n !isTest &&\n /\\.d\\.ts/.test(filename) &&\n !filename.includes('.ngtypecheck.')\n ) {\n // output to library root instead /src\n const declarationPath = resolve(\n config.root,\n config.build.outDir,\n relative(config.root, filename),\n ).replace('/src/', '/');\n\n const declarationFileDir = declarationPath\n .replace(basename(filename), '')\n .replace('/src/', '/');\n\n declarationFiles.push({\n declarationFileDir,\n declarationPath,\n data,\n });\n }\n },\n undefined /* cancellationToken */,\n undefined /* emitOnlyDtsFiles */,\n transformers,\n );\n\n writeFileCallback(id, content, false, undefined, [sourceFile]);\n if (map !== undefined && mapFilename !== undefined) {\n // Use the filename TypeScript emitted (handles `.cts`/`.mts` as well\n // as `.ts`) instead of regex-replacing the source `.ts` extension.\n writeFileCallback(mapFilename, map, false, undefined, [sourceFile]);\n }\n\n if (angularCompiler) {\n angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n }\n };\n\n if (ctx.watchMode) {\n if (ids && ids.length > 0) {\n ids.forEach((id) => writeOutputFile(id));\n } else if (isTest) {\n /**\n * Only block the server from starting up\n * during testing.\n */\n while (\n (\n builder as ts.EmitAndSemanticDiagnosticsBuilderProgram\n ).emitNextAffectedFile(\n writeFileCallback,\n undefined,\n undefined,\n transformers,\n )\n ) {\n /* empty */\n }\n }\n }\n\n if (!isTest) {\n /**\n * Perf: Output files on demand so the dev server\n * isn't blocked when emitting files.\n */\n outputFile = writeOutputFile;\n }\n }\n\n return {\n name: '@analogjs/vite-plugin-angular',\n api: compilerApi,\n async config(config, { command, mode }) {\n activateDeferredDebug(command);\n const resolution = ctx.initConfig(config, { command, mode });\n\n // Do a preliminary resolution for dep optimizer (before configResolved)\n const preliminaryTsConfigPath = ctx.resolveTsConfigPath();\n\n const esbuild = config.esbuild ?? false;\n const oxc = config.oxc ?? false;\n const jsTransformConfigKey = getJsTransformConfigKey();\n const jsTransformConfigValue =\n jsTransformConfigKey === 'oxc' ? oxc : esbuild;\n\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: preliminaryTsConfigPath,\n isProd: resolution.isProd,\n jit: ctx.options.jit,\n watchMode: ctx.watchMode,\n isTest: ctx.options.isTest,\n isAstroIntegration: ctx.options.isAstroIntegration,\n });\n\n return {\n [jsTransformConfigKey]: jsTransformConfigValue,\n ...depOptimizer,\n };\n },\n configResolved(config) {\n ctx.setResolvedConfig(config);\n\n if (!jit) {\n styleTransform = (code: string, filename: string) =>\n preprocessCSS(code, filename, config);\n }\n },\n configureServer(server) {\n viteServer = server;\n hotUpdates.configureServer(server);\n\n // Add/unlink changes the TypeScript program shape, not just file\n // contents, so we need to invalidate both include discovery and the\n // cached tsconfig root names before recompiling.\n const invalidateCompilationOnFsChange = createFsWatcherCacheInvalidator(\n invalidateFsCaches,\n invalidateTsconfigCaches,\n () => performCompilation(ctx.resolvedConfig!),\n );\n server.watcher.on('add', (file) => {\n if (EXCLUDED_TS_EXT_REGEX.test(file)) {\n invalidateSourceFiles(new Set([normalizePath(file)]));\n }\n return invalidateCompilationOnFsChange();\n });\n server.watcher.on('unlink', (file) => {\n const id = normalizePath(file);\n outputFiles.delete(id);\n tsSourceFileCache.delete(id);\n sourceFileCache.invalidate(new Set([id]));\n evictDeletedFileMetadata(file, {\n classNamesMap: ctx.hmr.classNames,\n fileTransformMap,\n });\n return invalidateCompilationOnFsChange();\n });\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n activeBuilds++;\n // Vite keys its CSS preprocessor worker cache by the top-level resolved\n // config object. Passing `this.environment.config` misses that cache\n // and falls back to a worker Vite never closes, which keeps Vitest\n // from exiting after AOT tests with `.scss` styleUrls. (#2556)\n if (!jit) {\n styleTransform = (code: string, filename: string) =>\n preprocessCSS(code, filename, ctx.resolvedConfig!);\n }\n\n // Browser mode also creates a server that may never transform TypeScript.\n if (!ctx.deferInitialCompilation) {\n pendingCompilation = performCompilation(\n (this.environment?.config as unknown as ResolvedConfig | undefined) ??\n ctx.resolvedConfig!,\n );\n await pendingCompilation;\n pendingCompilation = null;\n\n initialCompilation = true;\n }\n },\n async buildEnd(): Promise<void> {\n // Environments (e.g. client and ssr) build in parallel and share this\n // plugin's compilation state, so only reset after the last one ends.\n activeBuilds = Math.max(0, activeBuilds - 1);\n if (activeBuilds > 0) return;\n if (closeRequested) {\n await closeCompilation();\n return;\n }\n if (!ctx.watchMode) releaseCompilation();\n },\n async handleHotUpdate(hmrCtx) {\n if (ctx.hmr.isIgnoredFile(hmrCtx.file)) {\n debugHmr('ignored file change', { file: hmrCtx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(hmrCtx.file)) {\n const [fileId] = hmrCtx.file.split('?');\n debugHmr('TS file changed', { file: hmrCtx.file, fileId });\n\n await hotUpdates.schedule(hmrCtx.file, [fileId]);\n\n if (EXCLUDED_TS_EXT_REGEX.test(fileId)) {\n // Declaration dependencies have no runtime modules for Vite to invalidate.\n hmrCtx.server.moduleGraph.invalidateAll();\n hmrCtx.server.ws.send({ type: 'full-reload', triggeredBy: fileId });\n return [];\n }\n\n let result: EmitFileResult | undefined;\n\n if (ctx.shouldEnableLiveReload()) {\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!ctx.hmr.classNames.get(fileId),\n });\n debugHmrV('ts hmr evaluation', {\n file: hmrCtx.file,\n fileId,\n hasResult: !!result,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!ctx.hmr.classNames.get(fileId),\n className: ctx.hmr.classNames.get(fileId),\n updateCode: result?.hmrUpdateCode\n ? describeStylesheetContent(result.hmrUpdateCode)\n : undefined,\n errors: result?.errors?.length ?? 0,\n warnings: result?.warnings?.length ?? 0,\n hint: result?.hmrEligible\n ? 'A TS-side component change, including inline template edits, produced an Angular HMR payload.'\n : 'No Angular HMR payload was emitted for this TS change; the change may not affect component template state.',\n });\n }\n\n if (\n ctx.shouldEnableLiveReload() &&\n result?.hmrEligible &&\n ctx.hmr.classNames.get(fileId)\n ) {\n const relativeFileId = ctx.hmr.toComponentUpdateId(fileId);\n\n debugHmr('sending component update', { relativeFileId });\n debugHmrV('ts hmr component update payload', {\n file: hmrCtx.file,\n fileId,\n relativeFileId,\n className: ctx.hmr.classNames.get(fileId),\n });\n ctx.hmr.sendComponentUpdate(hmrCtx.server, relativeFileId);\n\n return hmrCtx.modules.map((mod) => {\n if (mod.id === hmrCtx.file) {\n return markModuleSelfAccepting(mod);\n }\n\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm|css|less|sass|scss)$/.test(hmrCtx.file)) {\n debugHmr('resource file changed', { file: hmrCtx.file });\n fileTransformMap.delete(hmrCtx.file.split('?')[0]);\n // Angular component resources frequently enter HMR with incomplete\n // watcher context. In practice `ctx.modules` may only contain the\n // source file, only the `?direct` module, or nothing at all after a\n // TS-driven component refresh. Resolve the full live module set from\n // Vite's module graph and our stylesheet registry before deciding how\n // to hot update the resource.\n const stylesheetRegistry = ctx.styles.registry;\n const fileModules = await getModulesForChangedFile(\n hmrCtx.server,\n hmrCtx.file,\n hmrCtx.modules,\n stylesheetRegistry,\n );\n /**\n * Check to see if this was a direct request\n * for an external resource (styles, html).\n */\n const isDirect = fileModules.find(\n (mod) =>\n !!mod.id &&\n mod.id.includes('?direct') &&\n isModuleForChangedResource(mod, hmrCtx.file, stylesheetRegistry),\n );\n const isInline = fileModules.find(\n (mod) =>\n !!mod.id &&\n mod.id.includes('?inline') &&\n isModuleForChangedResource(mod, hmrCtx.file, stylesheetRegistry),\n );\n debugHmrV('resource direct/inline detection', {\n file: hmrCtx.file,\n hasDirect: !!isDirect,\n directId: isDirect?.id,\n hasInline: !!isInline,\n inlineId: isInline?.id,\n });\n\n if (isDirect || isInline) {\n if (ctx.shouldExternalizeStyles() && isDirect?.id && isDirect.file) {\n const isComponentStyle =\n isDirect.type === 'css' && isComponentStyleSheet(isDirect.id);\n debugHmrV('resource direct branch', {\n file: hmrCtx.file,\n directId: isDirect.id,\n directType: isDirect.type,\n shouldExternalize: ctx.shouldExternalizeStyles(),\n isComponentStyle,\n });\n if (isComponentStyle) {\n return handleDirectComponentStyleHmr({\n server: hmrCtx.server,\n file: hmrCtx.file,\n directModule: isDirect,\n fileModules,\n stylesheetRegistry,\n stylePreprocessor: ctx.stylePreprocessor,\n });\n }\n }\n return fileModules;\n }\n\n if (\n ctx.shouldEnableLiveReload() &&\n /\\.(html|htm)$/.test(hmrCtx.file) &&\n fileModules.length === 0\n ) {\n const ownerModules = findTemplateOwnerModules(\n hmrCtx.server,\n hmrCtx.file,\n );\n debugHmrV('template owner lookup', {\n file: hmrCtx.file,\n ownerCount: ownerModules.length,\n ownerIds: ownerModules.map((mod) => mod.id),\n hint:\n ownerModules.length > 0\n ? 'The external template has candidate TS owner modules that can be recompiled for HMR.'\n : 'No TS owner modules were visible for this external template change; HMR will fall through to the generic importer path.',\n });\n if (ownerModules.length > 0) {\n const ownerIds = ownerModules\n .map((mod) => mod.id)\n .filter(Boolean) as string[];\n\n ownerModules.forEach((mod) =>\n hmrCtx.server.moduleGraph.invalidateModule(mod),\n );\n\n await hotUpdates.schedule(hmrCtx.file, ownerIds);\n\n const updates = ownerIds.filter((id) => ctx.hmr.classNames.get(id));\n debugHmrV('template owner recompilation result', {\n file: hmrCtx.file,\n ownerIds,\n updates,\n updateClassNames: updates.map((id) => ({\n id,\n className: ctx.hmr.classNames.get(id),\n })),\n hint:\n updates.length > 0\n ? 'External template recompilation produced Angular component update targets.'\n : 'External template recompilation completed, but no Angular component update targets were surfaced.',\n });\n if (updates.length > 0) {\n debugHmr('template owner module invalidation', {\n file: hmrCtx.file,\n ownerIds,\n updateCount: updates.length,\n });\n updates.forEach((updateId) => {\n ctx.hmr.sendComponentUpdate(\n hmrCtx.server,\n ctx.hmr.toComponentUpdateId(updateId),\n );\n });\n\n return ownerModules.map((mod) => markModuleSelfAccepting(mod));\n }\n }\n }\n\n const mods: ModuleNode[] = [];\n const updates: string[] = [];\n fileModules.forEach((mod) => {\n mod.importers.forEach((imp) => {\n hmrCtx.server.moduleGraph.invalidateModule(imp);\n\n if (\n ctx.shouldExternalizeStyles() &&\n imp.id &&\n ctx.hmr.classNames.get(imp.id)\n ) {\n updates.push(imp.id);\n } else {\n mods.push(imp);\n }\n });\n });\n debugHmrV('resource importer analysis', {\n file: hmrCtx.file,\n fileModuleCount: fileModules.length,\n importerCount: fileModules.reduce(\n (count, mod) => count + mod.importers.size,\n 0,\n ),\n updates,\n mods: mods.map((mod) => mod.id),\n });\n\n if (mods.length === 0 && updates.length === 0) return mods;\n\n await hotUpdates.schedule(hmrCtx.file, [\n ...mods.map((mod) => mod.id as string),\n ...updates,\n ]);\n\n if (updates.length > 0) {\n debugHmr('resource importer component updates', {\n file: hmrCtx.file,\n updateCount: updates.length,\n });\n updates.forEach((updateId) => {\n ctx.hmr.sendComponentUpdate(\n hmrCtx.server,\n ctx.hmr.toComponentUpdateId(updateId),\n );\n });\n\n return fileModules.map((mod) => {\n if (mod.id === hmrCtx.file) {\n return markModuleSelfAccepting(mod);\n }\n\n return mod;\n });\n }\n\n return mods;\n }\n\n // clear HMR updates with a full reload\n debugHmr('full reload — unrecognized file type', { file: hmrCtx.file });\n ctx.hmr.clear();\n return hmrCtx.modules;\n },\n resolveId(id, importer) {\n const virtualId = resolveAngularVirtualId(id, importer, {\n jit,\n resolvedConfig: ctx.resolvedConfig,\n });\n if (virtualId !== undefined) {\n return virtualId;\n }\n\n return ctx.styles.resolveComponentStyleId(id);\n },\n async load(id) {\n const virtualModule = await loadAngularVirtualModule(\n this,\n id,\n ctx.resolvedConfig,\n );\n if (virtualModule !== undefined) {\n return virtualModule;\n }\n\n return ctx.styles.loadComponentStyle(id);\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 (ctx.transformFilter && !ctx.transformFilter(code, id)) {\n return;\n }\n\n // Encapsulation of component stylesheets is handled by the\n // separate '@analogjs/vite-plugin-angular:encapsulation' plugin\n // with enforce: 'post'. This ensures @tailwindcss/vite (enforce:\n // 'pre') fully resolves @apply directives — including those inside\n // :host {} — before Angular's ShadowCss rewrites selectors. (#2293)\n\n if (id.includes('.ts?')) {\n // Strip the query string off the ID\n // in case of a dynamically loaded file\n id = id.replace(/\\?(.*)/, '');\n }\n\n fileTransformMap.set(id, code);\n\n /**\n * Re-analyze on each transform\n * for test(Vitest)\n */\n if (isTest) {\n if (ctx.deferInitialCompilation && !initialCompilation) {\n // Do full initial compilation\n pendingCompilation = performCompilation(\n (this.environment?.config as unknown as\n | ResolvedConfig\n | undefined) ?? ctx.resolvedConfig!,\n );\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n\n if (ctx.testWatchMode && invalidated) {\n pendingCompilation = performCompilation(\n (this.environment?.config as unknown as\n | ResolvedConfig\n | undefined) ?? ctx.resolvedConfig!,\n [id],\n );\n }\n }\n }\n\n const hasComponent = code.includes('@Component');\n debugCompilerV('transform', {\n id,\n codeLength: code.length,\n hasComponent,\n });\n // Resource URLs are only consumed for watch-file registration and\n // JIT rewrites, so skip resolution entirely in prod AOT builds.\n const resolveResourceUrls = hasComponent && (ctx.watchMode || jit);\n const templateUrls = resolveResourceUrls\n ? templateUrlsResolver.resolve(code, id)\n : [];\n const styleUrls = resolveResourceUrls\n ? styleUrlsResolver.resolve(code, id)\n : [];\n\n if (resolveResourceUrls && ctx.watchMode) {\n for (const urlSet of [...templateUrls, ...styleUrls]) {\n // `urlSet` is a string where a relative path is joined with an\n // absolute path using the `|` symbol.\n // For example: `./app.component.html|/home/projects/analog/src/app/app.component.html`.\n const [, absoluteFileUrl] = urlSet.split('|');\n this.addWatchFile(absoluteFileUrl);\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n await hotUpdates.wait();\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilerV('transform skip (file not emitted by Angular)', {\n id,\n });\n // File not in the Angular program — skip and let other plugins\n // or Vite's built-in transform handle it. Warn if it looks like\n // an Angular file that should have been compiled.\n const isAngular =\n !id.includes('@ng/component') &&\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n debugEmit('transform emit miss', {\n id,\n normalizedId: normalizeEmitterLookupId(id),\n knownOutputCount: outputFiles.size,\n hasOutputFileHook: !!outputFile,\n isAngular,\n });\n\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\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 debugEmitV('transform emit hit', {\n id,\n normalizedId: normalizeEmitterLookupId(id),\n ...describeEmitMarkers(data),\n errorCount: typescriptResult.errors?.length ?? 0,\n warningCount: typescriptResult.warnings?.length ?? 0,\n });\n\n if (jit && data.includes('angular:jit:')) {\n // The emitted id carries the base64 of the entire stylesheet,\n // and the bundler derives chunk names from it — hash it so a\n // large inline style can't produce an over-long filename (#2459).\n data = data.replace(\n /angular:jit:style:inline;([A-Za-z0-9+/=]*)/g,\n (_match, encodedStyles) =>\n toJitInlineStyleId(encodedStyles, isTest),\n );\n\n // Templates use virtual ids (no extension) so Vite's asset/CSS\n // plugins don't interfere. (#2263)\n templateUrls.forEach((templateUrlSet) => {\n const [templateFile, resolvedTemplateUrl] =\n templateUrlSet.split('|');\n data = data.replace(\n `angular:jit:template:file;${templateFile}`,\n toVirtualRawId(resolvedTemplateUrl),\n );\n });\n\n // External styles use native ?inline imports. We mark each\n // path as safe in Vite's safeModulePaths so the Denied ID\n // security check passes, and Vite's CSS pipeline handles\n // preprocessing, test.css, and browser/node differences\n // natively. (#2263, #2310)\n styleUrls.forEach((styleUrlSet) => {\n const [styleFile, resolvedStyleUrl] = styleUrlSet.split('|');\n markStylePathSafe(ctx.resolvedConfig, resolvedStyleUrl);\n data = data.replace(\n `angular:jit:style:file;${styleFile}`,\n resolvedStyleUrl + '?inline',\n );\n });\n }\n\n // Angular's HMR initializer emits dynamic import() calls that Vite's\n // import-analysis plugin cannot statically analyze, producing SSR\n // warnings. The Angular compiler's IR includes a @vite-ignore comment\n // but it can be lost during TypeScript emit. Re-inject it here so the\n // warning is suppressed regardless of the compilation path used.\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n debugHmrV('vite-ignore injection', {\n id,\n dataLength: data.length,\n hasMetaUrl,\n });\n if (hasMetaUrl) {\n const patched = injectViteIgnoreForHmrMetadata(data);\n if (patched !== data && !patched.includes('@vite-ignore')) {\n debugHmrV('vite-ignore regex fallback', { id });\n }\n data = patched;\n }\n }\n if (typescriptResult.map) {\n // TS emits `//# sourceMappingURL=foo.js.map` at the end of the\n // .js content, but the .map file isn't served by Vite — we\n // return the map object directly. Strip the stale reference so\n // downstream tools don't see two sourceMappingURL comments.\n data = data.replace(/\\s*\\/\\/# sourceMappingURL=[^\\r\\n]*\\s*$/, '');\n }\n\n return {\n code: data,\n map: typescriptResult.map\n ? normalizeSourceMapSources(typescriptResult.map, id)\n : null,\n };\n },\n },\n async closeBundle(): Promise<void> {\n closeRequested = true;\n if (activeBuilds === 0) {\n await closeCompilation();\n }\n },\n };\n}\n\n/**\n * @internal\n */\nexport function getFileMetadata(\n program: ts.BuilderProgram,\n angularCompiler?: NgtscProgram['compiler'],\n hmrEnabled?: boolean,\n disableTypeChecking?: boolean,\n classNamesMap: Map<string, string> = new Map(),\n): (file: string) => FileMetadataResult {\n const ts = require('typescript') as typeof import('typescript');\n return (file: string): FileMetadataResult => {\n const sourceFile = program.getSourceFile(file);\n if (!sourceFile) {\n return {};\n }\n\n const diagnostics = getDiagnosticsForSourceFile(\n sourceFile,\n !!disableTypeChecking,\n program,\n angularCompiler,\n );\n\n const errors = diagnostics\n .filter((d) => d.category === ts.DiagnosticCategory?.Error)\n .map((d) =>\n typeof d.messageText === 'object'\n ? d.messageText.messageText\n : d.messageText,\n );\n\n const warnings = diagnostics\n .filter((d) => d.category === ts.DiagnosticCategory?.Warning)\n .map((d) => d.messageText);\n\n let hmrUpdateCode: string | null | undefined = undefined;\n\n let hmrEligible = false;\n if (hmrEnabled) {\n for (const node of sourceFile.statements) {\n if (ts.isClassDeclaration(node) && node.name != null) {\n hmrUpdateCode = angularCompiler?.emitHmrUpdateModule(node);\n if (hmrUpdateCode) {\n const className = node.name.getText();\n classNamesMap.set(file, className);\n hmrEligible = true;\n debugHmr('NgtscProgram emitHmrUpdateModule', { file, className });\n }\n }\n }\n }\n\n return { errors, warnings, hmrUpdateCode, hmrEligible };\n };\n}\n\nfunction getDiagnosticsForSourceFile(\n sourceFile: ts.SourceFile,\n disableTypeChecking: boolean,\n program: ts.BuilderProgram,\n angularCompiler?: NgtscProgram['compiler'],\n): readonly ts.Diagnostic[] {\n const syntacticDiagnostics = program.getSyntacticDiagnostics(sourceFile);\n\n if (disableTypeChecking) {\n // Syntax errors are cheap to compute and the app will not run if there are any\n // So always show these types of errors regardless if type checking is disabled\n return syntacticDiagnostics;\n }\n\n const semanticDiagnostics = program.getSemanticDiagnostics(sourceFile);\n const angularDiagnostics = angularCompiler\n ? angularCompiler.getDiagnosticsForFile(sourceFile, 1)\n : [];\n return [\n ...syntacticDiagnost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AAM,cAAc,4BAClB,YACA,CAAC,CAAC,qBACF,SACA,eACF;EAEA,MAAM,SAAS,YACZ,QAAQ,MAAM,EAAE,aAAa,GAAG,oBAAoB,KAAK,CAAC,CAC1D,KAAK,MACJ,OAAO,EAAE,gBAAgB,WACrB,EAAE,YAAY,cACd,EAAE,WACR;EAEF,MAAM,WAAW,YACd,QAAQ,MAAM,EAAE,aAAa,GAAG,oBAAoB,OAAO,CAAC,CAC5D,KAAK,MAAM,EAAE,WAAW;EAE3B,IAAI,gBAA2C,KAAA;EAE/C,IAAI,cAAc;EAClB,IAAI,YACG;QAAA,MAAM,QAAQ,WAAW,YAC5B,IAAI,GAAG,mBAAmB,IAAI,KAAK,KAAK,QAAQ,MAAM;IACpD,gBAAgB,iBAAiB,oBAAoB,IAAI;IACzD,IAAI,eAAe;KACjB,MAAM,YAAY,KAAK,KAAK,QAAQ;KACpC,cAAc,IAAI,MAAM,SAAS;KACjC,cAAc;KACd,SAAS,oCAAoC;MAAE;MAAM;KAAU,CAAC;IAClE;GACF;;EAIJ,OAAO;GAAE;GAAQ;GAAU;GAAe;EAAY;CACxD;AACF;AAEA,SAAS,4BACP,YACA,qBACA,SACA,iBAC0B;CAC1B,MAAM,uBAAuB,QAAQ,wBAAwB,UAAU;CAEvE,IAAI,qBAGF,OAAO;CAGT,MAAM,sBAAsB,QAAQ,uBAAuB,UAAU;CACrE,MAAM,qBAAqB,kBACvB,gBAAgB,sBAAsB,YAAY,CAAC,IACnD,CAAC;CACL,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;CACL;AACF"}
@@ -1,2 +1,2 @@
1
1
  import type { Logger } from "vite";
2
- export declare function warnStylesheetError(logger: Logger | undefined, filename: string, error: unknown): void;
2
+ export declare function reportStylesheetError(logger: Logger | undefined, filename: string, error: unknown, isBuild: boolean): void;
@@ -1,8 +1,11 @@
1
1
  //#region packages/vite-plugin-angular/src/lib/utils/stylesheet-warning.ts
2
- function warnStylesheetError(logger, filename, error) {
3
- logger?.warn(`[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}; it was left unprocessed. ${error instanceof Error ? error.message : String(error)}`, { timestamp: true });
2
+ function reportStylesheetError(logger, filename, error, isBuild) {
3
+ const message = `[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}`;
4
+ const detail = error instanceof Error ? error.message : String(error);
5
+ if (isBuild) throw new Error(`${message}. ${detail}`, { cause: error });
6
+ logger?.warn(`${message}; it was left unprocessed. ${detail}`, { timestamp: true });
4
7
  }
5
8
  //#endregion
6
- export { warnStylesheetError };
9
+ export { reportStylesheetError };
7
10
 
8
11
  //# sourceMappingURL=stylesheet-warning.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stylesheet-warning.js","names":[],"sources":["../../../../src/lib/utils/stylesheet-warning.ts"],"sourcesContent":["import type { Logger } from 'vite';\n\nexport function warnStylesheetError(\n logger: Logger | undefined,\n filename: string,\n error: unknown,\n): void {\n logger?.warn(\n `[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}; ` +\n `it was left unprocessed. ${error instanceof Error ? error.message : String(error)}`,\n { timestamp: true },\n );\n}\n"],"mappings":";AAEA,SAAgB,oBACd,QACA,UACA,OACM;CACN,QAAQ,KACN,gEAAgE,SAAS,6BAC3C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KACnF,EAAE,WAAW,KAAK,CACpB;AACF"}
1
+ {"version":3,"file":"stylesheet-warning.js","names":[],"sources":["../../../../src/lib/utils/stylesheet-warning.ts"],"sourcesContent":["import type { Logger } from 'vite';\n\nexport function reportStylesheetError(\n logger: Logger | undefined,\n filename: string,\n error: unknown,\n isBuild: boolean,\n): void {\n const message = `[@analogjs/vite-plugin-angular] Failed to process stylesheet ${filename}`;\n const detail = error instanceof Error ? error.message : String(error);\n if (isBuild) {\n throw new Error(`${message}. ${detail}`, { cause: error });\n }\n logger?.warn(`${message}; it was left unprocessed. ${detail}`, {\n timestamp: true,\n });\n}\n"],"mappings":";AAEA,SAAgB,sBACd,QACA,UACA,OACA,SACM;CACN,MAAM,UAAU,gEAAgE;CAChF,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACpE,IAAI,SACF,MAAM,IAAI,MAAM,GAAG,QAAQ,IAAI,UAAU,EAAE,OAAO,MAAM,CAAC;CAE3D,QAAQ,KAAK,GAAG,QAAQ,6BAA6B,UAAU,EAC7D,WAAW,KACb,CAAC;AACH"}