@analogjs/vite-plugin-angular 3.0.0-beta.43 → 3.0.0-beta.45

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.43",
3
+ "version": "3.0.0-beta.45",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -5,14 +5,14 @@ import { detectTypeOnlyImportNames, elideTypeOnlyImportsMagicString } from "./ty
5
5
  import { emitAngularExpr, emitAngularStmt, setEmitterSourceCode } from "./js-emitter.js";
6
6
  import { lowerClassFields } from "./class-field-lowering.js";
7
7
  import { collectStringConstants, detectFieldDecorators, detectSignals, extractConstructorDeps, extractMetadata } from "./metadata.js";
8
- import { buildDeferDependencyMap } from "./defer.js";
8
+ import { buildDeferDependencyMap, buildImportMap } from "./defer.js";
9
9
  import { buildCtorParameters, buildPropDecorators } from "./jit-metadata.js";
10
10
  import { debugCompile } from "./debug.js";
11
11
  import { inlineStyleRanges } from "./style-ast.js";
12
12
  import * as fs from "node:fs";
13
13
  import * as path$1 from "node:path";
14
14
  import * as o from "@angular/compiler";
15
- import { ConstantPool, FactoryTarget, ParseLocation, ParseSourceFile, ParseSourceSpan, R3NgModuleMetadataKind, R3SelectorScopeMode, compileClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDirectiveFromMetadata, compileFactoryFunction, compileInjector, compileNgModule, compilePipeFromMetadata, makeBindingParser, parseHostBindings, parseTemplate } from "@angular/compiler";
15
+ import { ConstantPool, FactoryTarget, ParseLocation, ParseSourceFile, ParseSourceSpan, R3NgModuleMetadataKind, R3SelectorScopeMode, compileClassMetadata, compileComponentClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDirectiveFromMetadata, compileFactoryFunction, compileInjector, compileNgModule, compilePipeFromMetadata, makeBindingParser, parseHostBindings, parseTemplate } from "@angular/compiler";
16
16
  import MagicString from "magic-string";
17
17
  //#region packages/vite-plugin-angular/src/lib/compiler/compile.ts
18
18
  function toTopLevelStatement(stmt) {
@@ -143,6 +143,11 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
143
143
  }
144
144
  }
145
145
  const localSelectors = /* @__PURE__ */ new Map();
146
+ /**
147
+ * Per component class: the dependencies only its @defer blocks use, which
148
+ * its class metadata must load lazily (`ɵsetClassMetadataAsync`).
149
+ */
150
+ const deferredMetadataDeps = /* @__PURE__ */ new Map();
146
151
  if (!registry) for (const [clsName, oxcNode] of oxcClassMap) {
147
152
  const decs = oxcNode.decorators || [];
148
153
  if (decs.length > 0) {
@@ -405,6 +410,23 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
405
410
  classCompileError = /* @__PURE__ */ new Error(`[fast-compile] Template parse error in ${fileName} (${className}): ${firstError.msg}`);
406
411
  return;
407
412
  }
413
+ const deferDependencies = buildDeferDependencyMap(parsedTemplate, oxcProgram, registry, localSelectors);
414
+ if (!isPartial && deferDependencies.deferredImports.size > 0) {
415
+ const importMap = buildImportMap(oxcProgram);
416
+ const metadataDeps = [];
417
+ for (let i = declarations.length - 1; i >= 0; i--) {
418
+ const name = declarationName(declarations[i]);
419
+ const info = name !== null ? importMap.get(name) : void 0;
420
+ if (name === null || info === void 0 || !deferDependencies.deferredImports.has(name)) continue;
421
+ declarations.splice(i, 1);
422
+ metadataDeps.unshift({
423
+ symbolName: name,
424
+ importPath: info.path,
425
+ isDefaultImport: info.isDefault
426
+ });
427
+ }
428
+ if (metadataDeps.length > 0) deferredMetadataDeps.set(className, metadataDeps);
429
+ }
408
430
  const componentMeta = {
409
431
  ...meta,
410
432
  name: className,
@@ -442,7 +464,7 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
442
464
  usesInheritance,
443
465
  defer: {
444
466
  mode: 0,
445
- blocks: buildDeferDependencyMap(parsedTemplate, oxcProgram, registry, localSelectors).blocks
467
+ blocks: deferDependencies.blocks
446
468
  },
447
469
  declarationListEmitMode: 1,
448
470
  i18nUseExternalIds: opts.i18nUseExternalIds ?? false,
@@ -704,7 +726,8 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
704
726
  ctorParameters: ctorParameters ? new o.WrappedNodeExpr(`() => [${ctorParameters}]`) : null,
705
727
  propDecorators: propDecorators ? new o.WrappedNodeExpr(propDecorators) : null
706
728
  };
707
- const classMetadataExpr = isPartial ? compileDeclareClassMetadata(classMetaInput) : compileClassMetadata(classMetaInput);
729
+ const deferredDeps = decName === "Component" ? deferredMetadataDeps.get(className) : void 0;
730
+ const classMetadataExpr = isPartial ? compileDeclareClassMetadata(classMetaInput) : deferredDeps ? compileComponentClassMetadata(classMetaInput, deferredDeps) : compileClassMetadata(classMetaInput);
708
731
  const metadataStmt = new o.ExpressionStatement(classMetadataExpr);
709
732
  if (topLevelClasses.has(node)) constantPool.statements.push(metadataStmt);
710
733
  else scopedMetadata.push(metadataStmt);
@@ -815,6 +838,13 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
815
838
  resourceDependencies
816
839
  };
817
840
  }
841
+ /** The local class name an `imports` entry declares, when it is a plain identifier. */
842
+ function declarationName(declaration) {
843
+ const node = declaration.type.node;
844
+ if (typeof node === "string") return node;
845
+ if (node?.type === "Identifier" && typeof node.name === "string") return node.name;
846
+ return declaration.className ?? null;
847
+ }
818
848
  //#endregion
819
849
  export { compile };
820
850
 
@@ -1 +1 @@
1
- {"version":3,"file":"compile.js","names":[],"sources":["../../../../src/lib/compiler/compile.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as o from '@angular/compiler';\nimport MagicString from 'magic-string';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport {\n ConstantPool,\n compileComponentFromMetadata,\n compileDirectiveFromMetadata,\n compilePipeFromMetadata,\n compileNgModule,\n compileInjector,\n R3NgModuleMetadataKind,\n R3SelectorScopeMode,\n FactoryTarget,\n compileFactoryFunction,\n parseTemplate,\n makeBindingParser,\n parseHostBindings,\n ParseSourceFile,\n ParseLocation,\n ParseSourceSpan,\n compileClassMetadata,\n compileDeclareComponentFromMetadata,\n compileDeclareDirectiveFromMetadata,\n compileDeclarePipeFromMetadata,\n compileDeclareNgModuleFromMetadata,\n compileDeclareInjectorFromMetadata,\n compileDeclareInjectableFromMetadata,\n compileDeclareFactoryFunction,\n compileDeclareClassMetadata,\n} from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\nimport {\n findAllClasses,\n resolveSyntheticImportSpecifier,\n walkOxc,\n} from './utils.js';\nimport { ANGULAR_DECORATORS, FIELD_DECORATORS } from './constants.js';\nimport { angularVersionAtLeast } from './angular-version.js';\nimport {\n detectTypeOnlyImportNames,\n elideTypeOnlyImportsMagicString,\n} from './type-elision.js';\n\nimport {\n emitAngularExpr,\n emitAngularStmt,\n setEmitterSourceCode,\n} from './js-emitter.js';\nimport { lowerClassFields } from './class-field-lowering.js';\nimport {\n extractMetadata,\n collectStringConstants,\n detectSignals,\n detectFieldDecorators,\n extractConstructorDeps,\n} from './metadata.js';\nimport { buildDeferDependencyMap } from './defer.js';\nimport { buildCtorParameters, buildPropDecorators } from './jit-metadata.js';\nimport { debugCompile, debugEmit } from './debug.js';\nimport { inlineStyleRanges } from './style-ast.js';\n\n/**\n * COMPLETE EXHAUSTIVE ANGULAR LITE COMPILER\n * Translates Angular Decorators + Signals to Ivy Static Definitions.\n *\n * @param registry - Optional external registry from the global analysis plugin.\n * When provided, used to resolve component/directive selectors for template compilation.\n */\nexport interface CompileResult {\n code: string;\n /** Source map for the transformation */\n map: ReturnType<MagicString['generateMap']>;\n /** Absolute paths of external resources (templateUrl, styleUrl) read during compilation */\n resourceDependencies: string[];\n}\n\nexport interface CompileOptions {\n registry?: ComponentRegistry;\n /** Pre-resolved style contents keyed by absolute file path (e.g. SCSS already compiled to CSS). */\n resolvedStyles?: Map<string, string>;\n /** Pre-processed inline styles (index in styles array → compiled CSS). */\n resolvedInlineStyles?: Map<number, string>;\n /**\n * When `false` (default), instance class field initializers are lowered to\n * constructor assignments (matching TypeScript's `useDefineForClassFields: false`\n * behavior). This is required for Angular's `inject()` and constructor DI to\n * work correctly with the standard Angular tsconfig.\n */\n useDefineForClassFields?: boolean;\n /** Enable legacy i18n message ID format (default: true). */\n enableI18nLegacyMessageIdFormat?: boolean;\n /** Normalize line endings in ICU expressions (default: true). */\n i18nNormalizeLineEndingsInICUs?: boolean;\n /** Use external IDs in `$localize` calls (for Closure Compiler compatibility). */\n i18nUseExternalIds?: boolean;\n /**\n * Compilation output mode.\n * - `'full'` (default): Emit final Ivy definitions (`ɵɵdefineComponent`) for application builds.\n * - `'partial'`: Emit partial declarations (`ɵɵngDeclareComponent`) for library publishing.\n * Partial output is version-stable and linked at application build time.\n */\n compilationMode?: 'full' | 'partial';\n /**\n * Pre-parsed OXC program of `sourceCode`, so callers that already parsed\n * the identical string can avoid a re-parse. Treated as read-only.\n */\n oxcProgram?: ReturnType<typeof parseSync>['program'];\n}\n\ntype CompileMetadata = ReturnType<typeof extractMetadata>;\n\ntype CompileDeclaration = {\n type: o.Expression;\n selector: string | null;\n className?: string;\n kind: number;\n name?: string;\n inputs?: string[];\n outputs?: string[];\n exportAs?: string[];\n isComponent?: boolean;\n};\n\n/** A top-level statement with any `export` wrapper unwrapped. */\ninterface TopLevelStatement {\n /** The declaration (or the statement itself when not exported). */\n decl: any;\n exported: boolean;\n /** Start of the whole statement, including leading class decorators. */\n start: number;\n end: number;\n}\n\nfunction toTopLevelStatement(stmt: any): TopLevelStatement {\n const isExport =\n (stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration') &&\n stmt.declaration;\n const decl = isExport ? stmt.declaration : stmt;\n return {\n decl,\n exported: !!isExport,\n start: Math.min(stmt.start, decl.decorators?.[0]?.start ?? stmt.start),\n end: stmt.end,\n };\n}\n\n/** Get the callee name of a decorator call, e.g. `Component` for `@Component(...)`. */\nfunction decoratorCallName(dec: any, sourceCode: string): string | undefined {\n const callee = dec.expression;\n if (callee?.type !== 'CallExpression') return undefined;\n return sourceCode.slice(callee.callee.start, callee.callee.end);\n}\n\n/**\n * Normalize a `providers` / `viewProviders` metadata value into the single\n * `o.Expression` Angular's injector/host emitters expect.\n *\n * `extractMetadata` stores these as an array of `WrappedNodeExpr` when the\n * source used an inline array literal (`providers: [A, B]`) — those get\n * wrapped in a `LiteralArrayExpr`. When the source referenced a const,\n * spread, or call instead (`providers: safeProviders`), it stores the raw\n * expression, which is emitted by value. Returns `null` when there is\n * nothing to emit so callers skip the feature entirely.\n */\nfunction providersToExpr(\n value: o.Expression[] | o.Expression | undefined | null,\n): o.Expression | null {\n if (!value) return null;\n if (Array.isArray(value)) {\n return value.length ? new o.LiteralArrayExpr(value) : null;\n }\n return value;\n}\n\nconst LAZY_SCOPE_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n 'ClassDeclaration',\n 'ClassExpression',\n 'TSFunctionType',\n 'TSConstructorType',\n 'TSMethodSignature',\n 'TSCallSignatureDeclaration',\n 'TSConstructSignatureDeclaration',\n]);\n\n/**\n * Collect identifier names referenced in eagerly-evaluated code only.\n * Skips function/arrow/class bodies so that lazy references\n * (e.g. `const TOKEN = () => LaterClass`) are not treated as dependencies.\n * The root node's own children are always walked.\n */\nfunction collectIdentifiers(root: any): Set<string> {\n const ids = new Set<string>();\n walkOxc(root, (n) => {\n if (n.type === 'Identifier') ids.add(n.name);\n return n === root || !LAZY_SCOPE_TYPES.has(n.type);\n });\n return ids;\n}\n\n/** Extract the names defined by a top-level declaration. */\nfunction getDefinedNames(decl: any): string[] {\n if (decl.type === 'VariableDeclaration') {\n const names: string[] = [];\n for (const d of decl.declarations) {\n collectBindingNames(d.id, names);\n }\n return names;\n }\n if (\n (decl.type === 'FunctionDeclaration' || decl.type === 'ClassDeclaration') &&\n decl.id\n ) {\n return [decl.id.name];\n }\n return [];\n}\n\n/** Recursively collect all bound identifiers from a binding pattern. */\nfunction collectBindingNames(pattern: any, out: string[]): void {\n if (!pattern) return;\n switch (pattern.type) {\n case 'Identifier':\n out.push(pattern.name);\n break;\n case 'ObjectPattern':\n for (const prop of pattern.properties) {\n collectBindingNames(\n prop.type === 'RestElement' ? prop.argument : prop.value,\n out,\n );\n }\n break;\n case 'ArrayPattern':\n for (const el of pattern.elements) collectBindingNames(el, out);\n break;\n case 'RestElement':\n collectBindingNames(pattern.argument, out);\n break;\n case 'AssignmentPattern':\n collectBindingNames(pattern.left, out);\n break;\n }\n}\n\nexport function compile(\n sourceCode: string,\n fileName: string,\n optionsOrRegistry?: CompileOptions | ComponentRegistry,\n): CompileResult {\n // Backward compat: accept ComponentRegistry directly\n const opts: CompileOptions =\n optionsOrRegistry instanceof Map\n ? { registry: optionsOrRegistry }\n : optionsOrRegistry || {};\n const registry = opts.registry;\n const resolvedStyles = opts.resolvedStyles;\n const resolvedInlineStyles = opts.resolvedInlineStyles;\n const useDefineForClassFields = opts.useDefineForClassFields ?? false;\n const isPartial = opts.compilationMode === 'partial';\n const startTimeMs = debugCompile.enabled ? performance.now() : 0;\n debugCompile(\n 'compile %s (mode=%s, registry=%d entries)',\n fileName,\n isPartial ? 'partial' : 'full',\n registry?.size ?? 0,\n );\n const oxcProgram = opts.oxcProgram ?? parseOxc(fileName, sourceCode).program;\n const styleRanges = resolvedInlineStyles && inlineStyleRanges(oxcProgram);\n const oxcClassMap = new Map<string, any>();\n for (const stmt of oxcProgram.body) {\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? (stmt as any).declaration\n : stmt;\n if (\n decl &&\n (decl.type === 'ClassDeclaration' || decl.type === 'ClassExpression') &&\n decl.id?.name\n ) {\n oxcClassMap.set(decl.id.name, decl);\n }\n }\n\n // Collect module-level string constants so decorator metadata can resolve\n // template-literal interpolations like `template: \\`<div class=\"${tw}\">x</div>\\``.\n const stringConsts = collectStringConstants(oxcProgram);\n\n const constantPool = new ConstantPool();\n const resourceDependencies: string[] = [];\n const parseFile = new ParseSourceFile(sourceCode, fileName);\n const parseLoc = new ParseLocation(parseFile, 0, 0, 0);\n const typeSourceSpan = new ParseSourceSpan(parseLoc, parseLoc);\n const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, oxcProgram);\n const importSpecifierByName = new Map<string, string>();\n const importedNames = new Set<string>();\n const typeOnlyImportedNames = new Set<string>();\n\n for (const stmt of oxcProgram.body as any[]) {\n if (stmt.type !== 'ImportDeclaration') continue;\n\n const moduleSpecifier: string = stmt.source.value;\n // Explicit `import type { X }` — declaration-level type-only import\n const isDeclarationTypeOnly = stmt.importKind === 'type';\n for (const element of stmt.specifiers) {\n if (element.type !== 'ImportSpecifier') continue;\n const localName: string = element.local.name;\n importSpecifierByName.set(localName, moduleSpecifier);\n // Explicit `import { type X }` — specifier-level type-only import.\n // Both forms erase the symbol at runtime, so they cannot be used as\n // DI tokens. Add them to typeOnlyImports so extractConstructorDeps\n // surfaces ɵɵinvalidFactory() instead of emitting a broken\n // ɵɵdirectiveInject(X) referring to a non-existent value.\n if (isDeclarationTypeOnly || element.importKind === 'type') {\n typeOnlyImports.add(localName);\n typeOnlyImportedNames.add(localName);\n } else {\n importedNames.add(localName);\n }\n }\n }\n\n // Build a file-local selector map as fallback when no external registry is provided.\n // Skip the expensive extractMetadata scan when a registry covers all classes.\n const localSelectors = new Map<string, string>();\n if (!registry) {\n for (const [clsName, oxcNode] of oxcClassMap) {\n const decs: any[] = oxcNode.decorators || [];\n if (decs.length > 0) {\n const meta = extractMetadata(decs[0], sourceCode, stringConsts);\n if (meta?.selector) {\n localSelectors.set(clsName, meta.selector.split(',')[0].trim());\n }\n }\n }\n }\n\n const bindingParser = isPartial ? undefined : makeBindingParser();\n setEmitterSourceCode(sourceCode);\n\n // --- Direct walk: compile each Angular-decorated class and collect string outputs ---\n interface ClassCompileResult {\n ivyCode: string[]; // \"static ɵfac = ...\", \"static ɵcmp = ...\", etc.\n decorators: any[]; // Angular decorators to remove (OXC nodes)\n classEnd: number; // Position of closing } in original source\n // setClassMetadata calls for classes nested in a function scope, which\n // must be emitted next to the class rather than at module scope.\n scopedMetadata: o.Statement[];\n }\n const classResults: ClassCompileResult[] = [];\n const topLevelClasses = new Set(\n (oxcProgram.body as any[]).map((stmt) => toTopLevelStatement(stmt).decl),\n );\n // Track synthetic imports needed for NgModule export expansion.\n // Maps exported class name → import specifier.\n const syntheticImports = new Map<string, string>();\n // A type-only import is erased at runtime, so its synthetic value import\n // needs an alias to avoid redeclaring the type-only binding.\n const dependencyLocalName = (name: string) =>\n typeOnlyImportedNames.has(name) ? `ɵngDep_${name}` : name;\n\n // ANGULAR_DECORATORS imported from utils\n\n for (const node of findAllClasses(oxcProgram)) {\n const decorators: any[] = node.decorators;\n if (!decorators || decorators.length === 0) continue;\n\n const className: string | undefined = node.id?.name;\n if (!className) continue;\n\n const angularDecorators = decorators.filter((dec) =>\n ANGULAR_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? ''),\n );\n if (angularDecorators.length === 0) continue;\n\n const ivyCode: string[] = [];\n let targetType: FactoryTarget = FactoryTarget.Injectable;\n // Store resolved resources per decorator for metadata inlining\n const resolvedResources = new Map<\n any,\n { template?: string; styles?: string[] }\n >();\n\n const classRef: o.R3Reference = {\n value: new o.WrappedNodeExpr(className),\n type: new o.WrappedNodeExpr(className),\n };\n\n // Detect `class Foo extends Bar` so the directive/component def\n // gets `usesInheritance: true`. Angular's compiler turns that into\n // `features: [InheritDefinitionFeature]`, which is what causes the\n // runtime to merge inputs/outputs/queries/host bindings from the\n // base class. Without it, derived directives like\n // `BrnPopover extends BrnDialog` lose every input declared on the\n // base, and any host directive that references those inputs by\n // public name fails at runtime with NG0311.\n const usesInheritance = !!node.superClass;\n\n let classCompileError: Error | null = null;\n\n angularDecorators.forEach((dec) => {\n const decoratorName = decoratorCallName(dec, sourceCode)!;\n const meta = extractMetadata(dec, sourceCode, stringConsts);\n const sigs = detectSignals(node, sourceCode);\n const fields = detectFieldDecorators(node, sourceCode);\n const hostBindings = parseHostBindings(meta.hostRaw || {});\n\n const hostMetadata: o.R3HostMetadata = {\n attributes: hostBindings.attributes,\n listeners: { ...hostBindings.listeners, ...fields.hostListeners },\n properties: { ...hostBindings.properties, ...fields.hostProperties },\n specialAttributes: hostBindings.specialAttributes,\n };\n\n switch (decoratorName) {\n case 'Component': {\n targetType = FactoryTarget.Component;\n if (!meta.selector) {\n meta.selector = `ng-component-${className.toLowerCase()}`;\n }\n\n const declarations: CompileDeclaration[] = [];\n // Dedupe by class name across direct imports, tuple-barrel\n // expansion, and NgModule export expansion so the final\n // `dependencies: () => [...]` list never contains the same\n // class twice. Otherwise Angular's runtime throws NG0300\n // (\"Multiple components match …\") when a file lists both\n // `NgIcon` and a barrel like `HlmIconImports = [HlmIcon, NgIcon]`\n // that re-exports it, or when two NgModules re-export the same\n // directive (e.g. FormsModule + ReactiveFormsModule →\n // DefaultValueAccessor).\n const seenDeclarationNames = new Set<string>();\n\n // Expand `imports` entries that are not directives themselves\n // (e.g. NgModules and tuple barrels like `HlmSelectImports =\n // [HlmSelect, HlmSelectContent, ...] as const`) into the\n // underlying directive class names. Returns the original entry\n // when it doesn't match either expansion case.\n const collectExpandedImports = (\n depClassName: string,\n visited: Set<string>,\n ): string[] => {\n if (visited.has(depClassName)) return [];\n visited.add(depClassName);\n const entry = registry?.get(depClassName);\n if (!entry) return [depClassName];\n if (entry.kind === 'ngmodule' && entry.exports) {\n const out: string[] = [];\n for (const name of entry.exports) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n if (entry.kind === 'tuple' && entry.members) {\n const out: string[] = [];\n for (const name of entry.members) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n return [depClassName];\n };\n\n for (const dep of Array.isArray(meta.imports) ? meta.imports : []) {\n const depNode = dep.node;\n const depClassName: string =\n typeof depNode === 'string'\n ? depNode\n : (depNode?.name ?? depNode?.type === 'Identifier')\n ? depNode.name\n : sourceCode.slice(depNode?.start ?? 0, depNode?.end ?? 0);\n const registryEntry = registry?.get(depClassName);\n\n // Tuple barrel: `imports: [HlmSelectImports]` where the\n // const is `[HlmSelect, HlmSelectContent, ...] as const`.\n // Expand into the underlying directive declarations and\n // track synthetic imports for any classes not already\n // referenced in this file.\n if (registryEntry?.kind === 'tuple' && registryEntry.members) {\n const expanded = collectExpandedImports(depClassName, new Set());\n const tupleSpecifier = importSpecifierByName.get(depClassName);\n for (const memberName of expanded) {\n const memberEntry = registry?.get(memberName);\n if (!memberEntry || memberEntry.kind === 'tuple') continue;\n const memberRef = new o.WrappedNodeExpr(\n dependencyLocalName(memberName),\n );\n if (!importedNames.has(memberName)) {\n const memberSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n memberEntry,\n tupleSpecifier,\n );\n if (memberSpecifier) {\n syntheticImports.set(memberName, memberSpecifier);\n }\n }\n const kind = memberEntry.kind === 'pipe' ? 1 : 0;\n const memberDecl: CompileDeclaration = {\n type: memberRef,\n selector: memberEntry.selector,\n kind,\n ...(kind === 1 ? { name: memberEntry.pipeName } : {}),\n };\n if (memberEntry.inputs) {\n memberDecl.inputs = Object.values(memberEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (memberEntry.outputs) {\n memberDecl.outputs = Object.values(\n memberEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(memberName)) {\n seenDeclarationNames.add(memberName);\n declarations.push(memberDecl);\n }\n }\n continue;\n }\n\n if (registryEntry?.kind === 'ngmodule' && registryEntry.exports) {\n const moduleSpecifier = importSpecifierByName.get(depClassName);\n\n // Recursively collect all non-module exports (handles nested NgModules\n // like ReactiveFormsModule → ɵInternalFormsSharedModule → DefaultValueAccessor)\n const allExports: string[] = [];\n const expandModule = (\n moduleName: string,\n visited = new Set<string>(),\n ) => {\n if (visited.has(moduleName)) return;\n visited.add(moduleName);\n const mod = registry?.get(moduleName);\n if (!mod?.exports) return;\n for (const name of mod.exports) {\n const entry = registry?.get(name);\n if (!entry) continue;\n if (entry.kind === 'ngmodule') {\n expandModule(name, visited);\n } else {\n allExports.push(name);\n }\n }\n };\n expandModule(depClassName);\n\n for (const exportedName of allExports) {\n const exportedEntry = registry?.get(exportedName);\n if (exportedEntry) {\n const kind = exportedEntry.kind === 'pipe' ? 1 : 0;\n // Create a reference to the exported class. If it's not\n // already imported, track it for synthetic import injection.\n const exportedRef = new o.WrappedNodeExpr(\n dependencyLocalName(exportedName),\n );\n const exportedSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n exportedEntry,\n moduleSpecifier,\n );\n if (exportedSpecifier) {\n syntheticImports.set(exportedName, exportedSpecifier);\n }\n const decl: CompileDeclaration = {\n type: exportedRef,\n selector: exportedEntry.selector,\n kind,\n ...(kind === 1 ? { name: exportedEntry.pipeName } : {}),\n };\n if (exportedEntry.inputs) {\n decl.inputs = Object.values(exportedEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (exportedEntry.outputs) {\n decl.outputs = Object.values(\n exportedEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(exportedName)) {\n seenDeclarationNames.add(exportedName);\n declarations.push(decl);\n }\n }\n }\n continue;\n }\n\n const selector =\n registryEntry?.selector ?? localSelectors.get(depClassName);\n const kind = registryEntry?.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: dep,\n selector: selector || `_unresolved-${depClassName}`,\n kind,\n ...(kind === 1 ? { name: registryEntry?.pipeName } : {}),\n };\n // Pass inputs/outputs from registry so template bindings resolve.\n // R3DirectiveDependencyMetadata expects inputs/outputs as string[]\n // of binding property names.\n if (registryEntry?.inputs) {\n decl.inputs = Object.values(registryEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (registryEntry?.outputs) {\n decl.outputs = Object.values(registryEntry.outputs) as string[];\n }\n if (!seenDeclarationNames.has(depClassName)) {\n seenDeclarationNames.add(depClassName);\n declarations.push(decl);\n }\n }\n\n // Add self-reference so recursive components (e.g. tree views)\n // can use their own selector in their template.\n // Skip in partial mode — the linker handles self-resolution.\n if (!isPartial && !seenDeclarationNames.has(className)) {\n const selfInputs = Object.entries(sigs.inputs).map(\n ([, v]: [string, any]) => v.bindingPropertyName,\n );\n const selfOutputs = Object.values({\n ...meta.outputs,\n ...fields.outputs,\n ...sigs.outputs,\n }) as string[];\n seenDeclarationNames.add(className);\n declarations.push({\n type: classRef.value,\n selector: meta.selector,\n kind: 0,\n ...(selfInputs.length > 0 ? { inputs: selfInputs } : {}),\n ...(selfOutputs.length > 0 ? { outputs: selfOutputs } : {}),\n });\n }\n\n // Non-standalone components get their directive/pipe scope from the\n // @NgModule that declares them. Whole-program ngtsc resolves this; a\n // per-file engine can't read the module from the component file, but the\n // project-wide registry (populated at buildStart) records every module's\n // declarations + imports. We resolve the owning module's transitive scope\n // here and inline it into the component's own `dependencies` — matching\n // ngtsc, and surviving tree-shaking (unlike a separate, droppable\n // `ɵɵsetComponentScope` call).\n //\n // A component declared in an @NgModule must set\n // `standalone: false`, so only those need the owning-module lookup.\n if (!isPartial && meta.standalone === false && registry) {\n let owningModule:\n | { declarations?: string[]; imports?: string[] }\n | undefined;\n for (const entry of registry.values()) {\n if (\n entry.kind === 'ngmodule' &&\n entry.declarations?.includes(className)\n ) {\n owningModule = entry;\n break;\n }\n }\n if (owningModule) {\n // Transitive scope = the module's own declarations + the exported\n // declarations of every imported module (recursively) + tuple members.\n const scopeNames = new Set<string>();\n const addExportsOf = (modName: string, visited: Set<string>) => {\n if (visited.has(modName)) return;\n visited.add(modName);\n const e = registry.get(modName);\n if (!e) return;\n if (e.kind === 'ngmodule') {\n for (const exp of e.exports ?? []) addExportsOf(exp, visited);\n } else if (e.kind === 'tuple') {\n for (const m of e.members ?? []) scopeNames.add(m);\n } else {\n scopeNames.add(modName);\n }\n };\n for (const d of owningModule.declarations ?? [])\n scopeNames.add(d);\n for (const imp of owningModule.imports ?? [])\n addExportsOf(imp, new Set());\n\n for (const name of scopeNames) {\n if (seenDeclarationNames.has(name)) continue;\n const entry = registry.get(name);\n if (\n !entry ||\n entry.kind === 'ngmodule' ||\n entry.kind === 'tuple'\n )\n continue;\n if (!importedNames.has(name)) {\n const spec = resolveSyntheticImportSpecifier(\n fileName,\n entry,\n importSpecifierByName.get(name),\n );\n if (spec) syntheticImports.set(name, spec);\n }\n const kind = entry.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: new o.WrappedNodeExpr(dependencyLocalName(name)),\n selector: entry.selector || `_unresolved-${name}`,\n kind,\n ...(kind === 1 ? { name: entry.pipeName } : {}),\n };\n if (entry.inputs) {\n decl.inputs = Object.values(entry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (entry.outputs) {\n decl.outputs = Object.values(entry.outputs) as string[];\n }\n seenDeclarationNames.add(name);\n declarations.push(decl);\n }\n }\n }\n\n let templateContent = meta.template || '';\n if (!templateContent && meta.templateUrl) {\n try {\n const templatePath = path.resolve(\n path.dirname(fileName),\n meta.templateUrl,\n );\n templateContent = fs.readFileSync(templatePath, 'utf-8');\n resourceDependencies.push(templatePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read template file \"${meta.templateUrl}\" for ${className}`,\n );\n }\n }\n\n if (Array.isArray(meta.styleUrls)) {\n for (const url of meta.styleUrls) {\n try {\n const stylePath = path.resolve(path.dirname(fileName), url);\n const styleContent =\n resolvedStyles?.get(stylePath) ??\n fs.readFileSync(stylePath, 'utf-8');\n meta.styles.push(styleContent);\n resourceDependencies.push(stylePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read style file \"${url}\" for ${className}`,\n );\n }\n }\n }\n\n const styleRange = styleRanges?.get(dec);\n if (resolvedInlineStyles && styleRange) {\n for (let k = 0; k < styleRange.count; k++) {\n const css = resolvedInlineStyles.get(styleRange.start + k);\n if (css !== undefined) meta.styles[k] = css;\n }\n }\n\n // Store resolved resources for metadata inlining\n resolvedResources.set(dec, {\n template: templateContent || undefined,\n styles: meta.styles?.length > 0 ? [...meta.styles] : undefined,\n });\n\n const parsedTemplate = parseTemplate(templateContent, fileName, {\n preserveWhitespaces: meta.preserveWhitespaces,\n enableI18nLegacyMessageIdFormat:\n opts.enableI18nLegacyMessageIdFormat ?? true,\n i18nNormalizeLineEndingsInICUs:\n opts.i18nNormalizeLineEndingsInICUs ?? true,\n });\n\n const ivyInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (ivyInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(ivyInputs, meta.inputs);\n }\n Object.assign(ivyInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n ivyInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals\n // so `input(null, { alias: 'aria-label' })` registers with\n // the public name `aria-label`, not the class property name.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const templateErrors = parsedTemplate.errors ?? [];\n if (templateErrors.length > 0) {\n const firstError = templateErrors[0];\n classCompileError = new Error(\n `[fast-compile] Template parse error in ${fileName} (${className}): ${firstError.msg}`,\n );\n return;\n }\n\n const componentMeta: CompileMetadata & {\n name: string;\n type: o.R3Reference;\n typeSourceSpan: ParseSourceSpan;\n declarations: CompileDeclaration[];\n template: {\n nodes: o.Node[];\n ngContentSelectors: string[];\n preserveWhitespaces: boolean;\n };\n } = {\n ...meta,\n name: className,\n type: classRef,\n typeSourceSpan,\n declarations,\n template: {\n nodes: parsedTemplate.nodes,\n ngContentSelectors: parsedTemplate.ngContentSelectors,\n preserveWhitespaces: parsedTemplate.preserveWhitespaces,\n },\n styles: [...(meta.styles || []), ...(parsedTemplate.styles || [])],\n inputs: ivyInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n host: hostMetadata,\n changeDetection: meta.changeDetection ?? (isPartial ? null : 1),\n encapsulation: meta.encapsulation ?? 0,\n exportAs: meta.exportAs,\n providers: providersToExpr(meta.providers),\n viewProviders: providersToExpr(meta.viewProviders),\n animations: meta.animations?.length\n ? new o.LiteralArrayExpr(meta.animations)\n : null,\n isStandalone: meta.standalone,\n imports: meta.imports,\n lifecycle: { usesOnChanges: false },\n // Angular v19/v20's `createComponentDefinitionMap` reads\n // `meta.interpolation.start` and `meta.interpolation.end`\n // unconditionally (the `!== DEFAULT_INTERPOLATION_CONFIG` check\n // is reference-equality, so a missing field enters the block\n // and crashes with `Cannot read properties of undefined`). v21\n // dropped the field from `createComponentDefinitionMap`\n // entirely. Use the v19/v20 singleton when the Angular package\n // exports it (matches the reference-equality check, skipping\n // the partial-mode emission block) and fall back to a plain\n // shape on v21+ where the field is ignored anyway.\n interpolation: (\n o as {\n DEFAULT_INTERPOLATION_CONFIG?: { start: string; end: string };\n }\n ).DEFAULT_INTERPOLATION_CONFIG ?? { start: '{{', end: '}}' },\n usesInheritance,\n defer: {\n mode: 0,\n blocks: buildDeferDependencyMap(\n parsedTemplate,\n oxcProgram,\n registry,\n localSelectors,\n ).blocks,\n },\n declarationListEmitMode: 1,\n i18nUseExternalIds: opts.i18nUseExternalIds ?? false,\n relativeContextFilePath: fileName,\n controlCreate: null,\n hasDirectiveDependencies:\n declarations.length > 0 ||\n (Array.isArray(meta.imports) && meta.imports.length > 0),\n };\n\n if (isPartial) {\n // Partial compilation accesses .inputs, .outputs, .exportAs on\n // each declaration — ensure they are arrays (not undefined).\n componentMeta.declarations = declarations.map((d) => ({\n ...d,\n inputs: d.inputs ?? null,\n outputs: d.outputs ?? null,\n exportAs: d.exportAs ?? null,\n isComponent: d.isComponent ?? false,\n }));\n const cmp = compileDeclareComponentFromMetadata(\n componentMeta,\n parsedTemplate,\n {\n content: templateContent,\n sourceUrl: fileName,\n isInline: !meta.templateUrl,\n inlineTemplateLiteralExpression: null,\n },\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n } else {\n const cmp = compileComponentFromMetadata(\n componentMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n }\n break;\n }\n\n case 'Directive': {\n targetType = FactoryTarget.Directive;\n // Build proper input descriptors (same as Component path)\n const dirInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (dirInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(dirInputs, meta.inputs);\n }\n Object.assign(dirInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n dirInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const directiveMeta = {\n ...meta,\n // Abstract base directives are declared as `@Directive()` with\n // no metadata. Angular's R3DirectiveMetadata accepts\n // `selector: string | null`, but the downstream selector parser\n // calls `.replace()` on the value and crashes on `undefined`.\n // Coerce missing selectors to `null` so abstract base classes\n // compile correctly.\n selector: meta.selector ?? null,\n name: className,\n type: classRef,\n typeSourceSpan,\n host: hostMetadata,\n inputs: dirInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n // Angular's compiler treats `providers` as an Expression and\n // emits `ɵɵProvidersFeature(<expr>)` whenever it is truthy.\n // `providersToExpr` lowers an inline array literal to a\n // LiteralArrayExpr (matching the Component branch) and passes a\n // const/spread reference through by value — returning `null`\n // when there are no providers so Angular skips the feature\n // entirely. Passing the bare JS array would otherwise be lowered\n // to `null` and crash Angular at runtime in `resolveProvider`.\n providers: providersToExpr(meta.providers),\n exportAs: meta.exportAs,\n isStandalone: meta.standalone,\n lifecycle: { usesOnChanges: false },\n usesInheritance,\n controlCreate: null,\n };\n if (isPartial) {\n const dir = compileDeclareDirectiveFromMetadata(directiveMeta);\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n } else {\n const dir = compileDirectiveFromMetadata(\n directiveMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n }\n break;\n }\n\n case 'Pipe': {\n targetType = FactoryTarget.Pipe;\n const pipeMeta = {\n ...meta,\n name: className,\n pipeName: meta.name,\n type: classRef,\n isStandalone: meta.standalone,\n pure: meta.pure ?? true,\n };\n if (isPartial) {\n const pipe = compileDeclarePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n } else {\n const pipe = compilePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n }\n break;\n }\n\n case 'Injectable': {\n targetType = FactoryTarget.Injectable;\n const injectableMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n providedIn: {\n expression: new o.LiteralExpr(meta.providedIn ?? null),\n forwardRef: 0,\n },\n };\n // Forward provider configuration so `ɵprov` honors useFactory/\n // useClass/useExisting/useValue. Without this, an\n // `@Injectable({ useFactory: () => ... })` quietly falls back\n // to constructor instantiation.\n if (meta.useClass) injectableMeta.useClass = meta.useClass;\n if (meta.useFactory) injectableMeta.useFactory = meta.useFactory;\n if (meta.useExisting) injectableMeta.useExisting = meta.useExisting;\n if (meta.useValue) injectableMeta.useValue = meta.useValue;\n // Dependency list for `useFactory` / `useClass`; without it the\n // emitted factory is invoked with no arguments.\n if (meta.deps) injectableMeta.deps = meta.deps;\n if (isPartial) {\n const inj = compileDeclareInjectableFromMetadata(injectableMeta);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n } else {\n const inj = o.compileInjectable(injectableMeta, true);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n }\n break;\n }\n\n case 'Service': {\n // `@Service` (and the `compileService` compiler API) landed in\n // Angular 22. On older peers the decorator does not exist; fail\n // loudly rather than falling through and emitting a default\n // `Injectable`-target factory with no `ɵprov`.\n if (!angularVersionAtLeast(22)) {\n classCompileError = new Error(\n `[fast-compile] @Service on ${className} requires Angular 22 or later`,\n );\n break;\n }\n targetType = (FactoryTarget as any).Service;\n const serviceMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n };\n if (meta.autoProvided === false) serviceMeta.autoProvided = false;\n if (meta.factory) serviceMeta.factory = meta.factory;\n if (isPartial) {\n const svc = (o as any).compileDeclareServiceFromMetadata(\n serviceMeta,\n );\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n } else {\n const svc = (o as any).compileService(serviceMeta, false);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n }\n break;\n }\n\n case 'NgModule': {\n targetType = FactoryTarget.NgModule;\n const ngModuleImports = Array.isArray(meta.imports)\n ? meta.imports\n : [];\n const ngModuleDeclarations = Array.isArray(meta.declarations)\n ? meta.declarations\n : [];\n const ngModuleExports = Array.isArray(meta.exports)\n ? meta.exports\n : [];\n const ngModuleBootstrap = Array.isArray(meta.bootstrap)\n ? meta.bootstrap\n : [];\n\n const ngModuleMeta = {\n kind: R3NgModuleMetadataKind.Global as const,\n type: classRef,\n bootstrap: ngModuleBootstrap.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n declarations: ngModuleDeclarations.map(\n (e: o.WrappedNodeExpr<any>) => ({ value: e, type: e }),\n ),\n publicDeclarationTypes: null,\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n includeImportTypes: true,\n exports: ngModuleExports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n selectorScopeMode: R3SelectorScopeMode.Inline,\n containsForwardDecls: false,\n schemas: [],\n id: null,\n };\n const injectorMeta = {\n name: className,\n type: classRef,\n providers: providersToExpr(meta.providers),\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => e),\n };\n if (isPartial) {\n const ngMod = compileDeclareNgModuleFromMetadata(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileDeclareInjectorFromMetadata(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n } else {\n const ngMod = compileNgModule(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileInjector(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n }\n break;\n }\n }\n });\n\n if (classCompileError) {\n throw classCompileError;\n }\n\n // Generate factory\n const deps = extractConstructorDeps(node, sourceCode, typeOnlyImports);\n if (deps === null) {\n const baseVar = `ɵ${className}_BaseFactory`;\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ (() => { let ${baseVar}; return function ${className}_Factory(__ngFactoryType__) { return (${baseVar} || (${baseVar} = i0.ɵɵgetInheritedFactory(${className})))(__ngFactoryType__ || ${className}); }; })()`,\n );\n } else if (deps === 'invalid') {\n ivyCode.unshift(\n `static ɵfac = function ${className}_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); }`,\n );\n } else {\n const factoryMeta = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n deps,\n target: targetType,\n };\n if (isPartial) {\n const fac = compileDeclareFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n } else {\n const fac = compileFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n }\n }\n\n // Emit setClassMetadata for runtime decorator reflection (devMode only)\n const ctorParameters = buildCtorParameters(\n node,\n sourceCode,\n typeOnlyImports,\n );\n const propDecorators = buildPropDecorators(node, sourceCode, 'i0.');\n const scopedMetadata: o.Statement[] = [];\n angularDecorators.forEach((dec) => {\n const decName = decoratorCallName(dec, sourceCode)!;\n const decArgsNode = dec.expression.arguments[0];\n const textOf = (n: any) => sourceCode.slice(n.start, n.end);\n\n // Build the decorator args for setClassMetadata, inlining resources if needed.\n const resources = resolvedResources.get(dec);\n let metadataArgsExpr: string | null = null;\n if (decArgsNode) {\n if (resources && decArgsNode.type === 'ObjectExpression') {\n // Inline external templateUrl/styleUrl(s) into the metadata so Angular's\n // runtime doesn't try to fetch relative URLs (which fails during SSR).\n const rewrittenProps: string[] = [];\n let needsTransform = false;\n for (const prop of decArgsNode.properties) {\n if (\n prop.type !== 'Property' ||\n prop.shorthand ||\n prop.method ||\n prop.kind !== 'init'\n ) {\n rewrittenProps.push(textOf(prop));\n continue;\n }\n const propName = textOf(prop.key);\n\n if (propName === 'templateUrl' && resources.template) {\n rewrittenProps.push(\n `template: ${JSON.stringify(resources.template)}`,\n );\n needsTransform = true;\n } else if (\n (propName === 'styleUrl' || propName === 'styleUrls') &&\n resources.styles?.length\n ) {\n rewrittenProps.push(\n `styles: [${resources.styles.map((s) => JSON.stringify(s)).join(', ')}]`,\n );\n needsTransform = true;\n } else {\n rewrittenProps.push(textOf(prop));\n }\n }\n metadataArgsExpr = needsTransform\n ? `{${rewrittenProps.join(', ')}}`\n : textOf(decArgsNode);\n } else {\n metadataArgsExpr = textOf(decArgsNode);\n }\n }\n\n try {\n // `LiteralMapPropertyAssignment` was a class with a constructor in\n // Angular up through ~v19, removed-then-restored in later v20/v21\n // patches. The only stable shape across versions is the plain\n // `{ key, value, quoted }` object literal — Angular's own emitter\n // and Analog's `JSEmitter` both consume entries via duck typing\n // (`.key` / `.value` / `.quoted`), and `compileClassMetadata` does\n // not `instanceof`-check entries. The js-emitter has a matching\n // comment at the consumption site. Using `new o.LiteralMapProperty\n // Assignment(...)` would throw \"is not a constructor\" on Angular\n // versions where the class export is missing (e.g. 20.3.x), and\n // the surrounding try/catch would silently disable class metadata\n // emission for every class in the project.\n const classMetaInput = {\n type: new o.WrappedNodeExpr(className),\n decorators: new o.LiteralArrayExpr([\n new o.LiteralMapExpr([\n {\n key: 'type',\n value: new o.WrappedNodeExpr(decName),\n quoted: false,\n },\n ...(metadataArgsExpr\n ? [\n {\n key: 'args',\n value: new o.LiteralArrayExpr([\n new o.WrappedNodeExpr(metadataArgsExpr),\n ]),\n quoted: false,\n },\n ]\n : []),\n ] as unknown as o.LiteralMapPropertyAssignment[]),\n ]),\n ctorParameters: ctorParameters\n ? new o.WrappedNodeExpr(`() => [${ctorParameters}]`)\n : null,\n propDecorators: propDecorators\n ? new o.WrappedNodeExpr(propDecorators)\n : null,\n };\n const classMetadataExpr = isPartial\n ? compileDeclareClassMetadata(classMetaInput)\n : compileClassMetadata(classMetaInput);\n const metadataStmt = new o.ExpressionStatement(classMetadataExpr);\n if (topLevelClasses.has(node)) {\n constantPool.statements.push(metadataStmt);\n } else {\n scopedMetadata.push(metadataStmt);\n }\n } catch (e) {\n // Skip if compileClassMetadata fails — surfaced via DEBUG=analog-fast-compile\n if (debugCompile.enabled) {\n debugCompile(\n 'compileClassMetadata failed for %s in %s: %s',\n className,\n fileName,\n (e as Error)?.message,\n );\n }\n }\n });\n\n // Collect member decorators (@HostListener, @HostBinding, @Input, @Output,\n // @ViewChild, @ContentChild, etc.) so they are removed from the source.\n // The metadata has already been extracted by detectFieldDecorators().\n const memberDecorators: any[] = [];\n for (const member of node.body.body) {\n for (const dec of member.decorators ?? []) {\n if (FIELD_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? '')) {\n memberDecorators.push(dec);\n }\n }\n }\n\n classResults.push({\n ivyCode,\n decorators: [...angularDecorators, ...memberDecorators],\n classEnd: node.end,\n scopedMetadata,\n });\n }\n\n // Apply edits via MagicString\n const ms = new MagicString(sourceCode, { filename: fileName });\n\n // 1. Prepend i0 import (skip if already present)\n if (!sourceCode.includes('import * as i0 from')) {\n ms.prepend('import * as i0 from \"@angular/core\";\\n');\n }\n\n // 1b. Inject synthetic imports for NgModule-exported classes\n for (const [name, specifier] of syntheticImports) {\n const localName = dependencyLocalName(name);\n if (!importedNames.has(localName)) {\n const binding = localName === name ? name : `${name} as ${localName}`;\n ms.prepend(`import { ${binding} } from \"${specifier}\";\\n`);\n importedNames.add(localName);\n }\n }\n\n // 2a. Hoist non-exported variable/function declarations that appear after\n // a class to just before the first class. This avoids TDZ errors when\n // static ɵcmp references file-level constants declared after the class.\n //\n // We must NOT hoist a statement whose initializer references a name\n // (class, exported const/let) that is defined between firstClassPos and\n // the statement itself — doing so would move the reference before the\n // definition and cause a TDZ error at runtime.\n if (classResults.length > 0) {\n // Find the position right before the first class (any class, not just Angular-decorated)\n const statements = (oxcProgram.body as any[]).map(toTopLevelStatement);\n let firstClassPos = Infinity;\n const nonHoistableNames = new Set<string>();\n for (const { decl, start } of statements) {\n if (decl.type === 'ClassDeclaration') {\n firstClassPos = start;\n // The first class itself is non-hoistable — statements hoisted\n // before it must not reference it.\n if (decl.id) {\n nonHoistableNames.add(decl.id.name);\n }\n break;\n }\n }\n\n // Pass 1: collect names defined by statements that will NOT be hoisted\n // (classes, enums, exported vars/functions) and therefore remain after\n // firstClassPos.\n for (const { decl, exported, start } of statements) {\n if (start <= firstClassPos) continue;\n\n if (\n decl.type === 'ClassDeclaration' ||\n decl.type === 'TSEnumDeclaration'\n ) {\n if (decl.id) nonHoistableNames.add(decl.id.name);\n } else if (\n exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration')\n ) {\n for (const n of getDefinedNames(decl)) {\n nonHoistableNames.add(n);\n }\n }\n }\n\n // Pass 2: for each hoist candidate, check if it references any\n // non-hoistable name. If it does, skip it and add its own names to the\n // non-hoistable set (transitivity).\n for (const { decl, exported, start, end } of statements) {\n if (start <= firstClassPos) continue;\n\n const isCandidate =\n !exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration');\n if (!isCandidate) continue;\n\n const referencedIds = collectIdentifiers(decl);\n let referencesNonHoistable = false;\n for (const id of referencedIds) {\n if (nonHoistableNames.has(id)) {\n referencesNonHoistable = true;\n break;\n }\n }\n\n if (referencesNonHoistable) {\n // Don't hoist — mark this statement's names as non-hoistable too\n for (const name of getDefinedNames(decl)) {\n nonHoistableNames.add(name);\n }\n } else {\n // Move rather than re-insert so the statement keeps its source map.\n // The separating newline is attached to the moved chunk.\n ms.appendLeft(end, '\\n');\n ms.move(start, end, firstClassPos);\n }\n }\n }\n\n // 2. For each compiled class: remove decorators + insert Ivy definitions\n for (const cr of classResults) {\n // Remove Angular decorators from source\n for (const dec of cr.decorators) {\n const start = dec.start;\n const end = dec.end;\n let trimEnd = end;\n while (\n trimEnd < sourceCode.length &&\n (sourceCode[trimEnd] === ' ' ||\n sourceCode[trimEnd] === '\\n' ||\n sourceCode[trimEnd] === '\\r')\n ) {\n trimEnd++;\n }\n ms.remove(start, trimEnd);\n }\n\n // Insert static members before closing }\n if (cr.ivyCode.length > 0) {\n const memberCode = cr.ivyCode.map((c) => ' ' + c + ';').join('\\n');\n ms.appendLeft(cr.classEnd - 1, '\\n' + memberCode + '\\n');\n }\n\n for (const stmt of cr.scopedMetadata) {\n ms.appendLeft(cr.classEnd, `\\n/*@__PURE__*/ ${emitAngularStmt(stmt)}`);\n }\n }\n\n // 3. Emit constant pool statements.\n // Split into: helper declarations (const/function) that must appear before\n // the class (since static property initializers reference them), and\n // side-effect statements (setClassMetadata IIFEs) that go after.\n const helpers: string[] = [];\n const sideEffects: string[] = [];\n for (const s of constantPool.statements) {\n const code = emitAngularStmt(s);\n if (\n s instanceof o.ExpressionStatement &&\n s.expr instanceof o.InvokeFunctionExpr\n ) {\n // setClassMetadata is wrapped in `(() => { ... })()` — annotate\n // the IIFE call so bundlers can drop it when ngDevMode is folded\n // to false at production build time.\n sideEffects.push(`/*@__PURE__*/ ${code}`);\n } else {\n helpers.push(code);\n }\n }\n\n if (sideEffects.length > 0) {\n ms.append('\\n\\n' + sideEffects.join('\\n'));\n }\n\n // 4. Lower class field initializers to constructor assignments when\n // useDefineForClassFields is false (standard Angular tsconfig).\n // Uses the original OXC AST positions which are still valid for MagicString\n // since MagicString tracks edits relative to the original source.\n // Ivy static definitions (ɵcmp, ɵfac) are not in the original AST so they\n // are unaffected, and shouldLowerField skips static fields regardless.\n if (!useDefineForClassFields) {\n lowerClassFields(ms, sourceCode, oxcProgram);\n }\n\n // 5. Elide imports that are only used in type positions (type annotations,\n // implements, generics, etc.). Without this pass, single-file transpilers\n // like OXC / esbuild cannot tell that `import { SomeType }` is type-only\n // and will leave the import in the output, causing runtime errors.\n // Detection runs once on the final output; helpers are appended for\n // analysis only, since their position does not affect references.\n const helperCode = helpers.join('\\n');\n const willElide = detectTypeOnlyImportNames(\n ms.toString() + '\\n' + helperCode,\n );\n if (helpers.length > 0) {\n // Insert helpers after the last import / top-level non-class statement,\n // well before any class that references them. Skip imports that will be\n // fully removed by type elision (step 5): inserting inside a\n // soon-to-be-removed range would discard the helpers with the import.\n let insertPos = 0;\n for (const stmt of oxcProgram.body as any[]) {\n const { decl } = toTopLevelStatement(stmt);\n if (stmt.type === 'ImportDeclaration') {\n // Skip imports that will be entirely removed by type elision\n if (willElide.size > 0 && stmt.specifiers.length > 0) {\n const allElided = stmt.specifiers.every(\n (spec: any) =>\n spec.type === 'ImportNamespaceSpecifier' ||\n spec.importKind === 'type' ||\n willElide.has(spec.local.name),\n );\n if (allElided) continue;\n }\n insertPos = stmt.end;\n } else if (\n decl.type === 'VariableDeclaration' &&\n !sourceCode.slice(stmt.start, stmt.end).includes('class')\n ) {\n insertPos = stmt.end;\n } else if (\n stmt.type !== 'TSExportAssignment' &&\n !(\n stmt.type === 'ExportDefaultDeclaration' &&\n decl.type !== 'ClassDeclaration' &&\n decl.type !== 'FunctionDeclaration'\n )\n ) {\n // Stop at the first class or non-import/non-variable statement\n break;\n }\n }\n // Helpers must survive downstream `ms.overwrite()` / `ms.remove()` of\n // imports performed by the type-only specifier elision pass (step 5).\n //\n // Case `insertPos > 0`: a surviving import ends at `insertPos`. Use\n // `appendRight(insertPos, …)` so helpers bind to the `\\n` after the\n // import's `;` — outside any overwrite range `[node.start, node.end)`\n // of a preceding import. `appendLeft(insertPos, …)` would bind to the\n // `;` itself, which IS inside the overwrite range and would be wiped.\n //\n // Case `insertPos === 0`: no import survives — every import is going\n // to be elided, and `elideTypeOnlyImportsMagicString` will\n // `ms.remove(0, declEnd)` the first one. `appendRight(0, …)` anchors\n // to the character at position 0 (the first import's first char),\n // which is inside `[0, declEnd)` and gets wiped. Use `appendLeft(0, …)`\n // instead — it anchors to the LEFT of position 0, outside any range\n // starting at 0, so the helpers survive. Ordering is still correct\n // because the i0 import prepended in step 1 lives in MagicString's\n // `intro` (from `ms.prepend`), which always emits before any\n // `appendLeft` content at position 0.\n if (insertPos === 0) {\n ms.appendLeft(0, helperCode + '\\n');\n } else {\n ms.appendRight(insertPos, '\\n' + helperCode + '\\n');\n }\n }\n elideTypeOnlyImportsMagicString(ms, oxcProgram, willElide);\n\n const map = ms.generateMap({\n source: fileName,\n file: fileName + '.js',\n includeContent: true,\n hires: 'boundary',\n });\n\n if (debugCompile.enabled) {\n debugCompile(\n 'compile %s done (%dms, %d classes, %d resource deps)',\n fileName,\n Math.round(performance.now() - startTimeMs),\n classResults.length,\n resourceDependencies.length,\n );\n }\n return {\n code: ms.toString(),\n map,\n resourceDependencies,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwIA,SAAS,oBAAoB,MAA8B;CACzD,MAAM,YACH,KAAK,SAAS,4BACb,KAAK,SAAS,+BAChB,KAAK;CACP,MAAM,OAAO,WAAW,KAAK,cAAc;CAC3C,OAAO;EACL;EACA,UAAU,CAAC,CAAC;EACZ,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,aAAa,EAAE,EAAE,SAAS,KAAK,KAAK;EACrE,KAAK,KAAK;CACZ;AACF;;AAGA,SAAS,kBAAkB,KAAU,YAAwC;CAC3E,MAAM,SAAS,IAAI;CACnB,IAAI,QAAQ,SAAS,kBAAkB,OAAO,KAAA;CAC9C,OAAO,WAAW,MAAM,OAAO,OAAO,OAAO,OAAO,OAAO,GAAG;AAChE;;;;;;;;;;;;AAaA,SAAS,gBACP,OACqB;CACrB,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,SAAS,IAAI,EAAE,iBAAiB,KAAK,IAAI;CAExD,OAAO;AACT;AAEA,IAAM,mCAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;AAQD,SAAS,mBAAmB,MAAwB;CAClD,MAAM,sBAAM,IAAI,IAAY;CAC5B,QAAQ,OAAO,MAAM;EACnB,IAAI,EAAE,SAAS,cAAc,IAAI,IAAI,EAAE,IAAI;EAC3C,OAAO,MAAM,QAAQ,CAAC,iBAAiB,IAAI,EAAE,IAAI;CACnD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M,MAAM,GAAG,YAAY;EACzB,QAAQ;EACR,MAAM,WAAW;EACjB,gBAAgB;EAChB,OAAO;CACT,CAAC;CAED,IAAI,aAAa,SACf,aACE,wDACA,UACA,KAAK,MAAM,YAAY,IAAI,IAAI,WAAW,GAC1C,aAAa,QACb,qBAAqB,MACvB;CAEF,OAAO;EACL,MAAM,GAAG,SAAS;EAClB;EACA;CACF;AACF"}
1
+ {"version":3,"file":"compile.js","names":[],"sources":["../../../../src/lib/compiler/compile.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as o from '@angular/compiler';\nimport MagicString from 'magic-string';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './utils.js';\nimport {\n ConstantPool,\n compileComponentFromMetadata,\n compileDirectiveFromMetadata,\n compilePipeFromMetadata,\n compileNgModule,\n compileInjector,\n R3NgModuleMetadataKind,\n R3SelectorScopeMode,\n FactoryTarget,\n compileFactoryFunction,\n parseTemplate,\n makeBindingParser,\n parseHostBindings,\n ParseSourceFile,\n ParseLocation,\n ParseSourceSpan,\n compileClassMetadata,\n compileComponentClassMetadata,\n compileDeclareComponentFromMetadata,\n compileDeclareDirectiveFromMetadata,\n compileDeclarePipeFromMetadata,\n compileDeclareNgModuleFromMetadata,\n compileDeclareInjectorFromMetadata,\n compileDeclareInjectableFromMetadata,\n compileDeclareFactoryFunction,\n compileDeclareClassMetadata,\n} from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\nimport {\n findAllClasses,\n resolveSyntheticImportSpecifier,\n walkOxc,\n} from './utils.js';\nimport { ANGULAR_DECORATORS, FIELD_DECORATORS } from './constants.js';\nimport { angularVersionAtLeast } from './angular-version.js';\nimport {\n detectTypeOnlyImportNames,\n elideTypeOnlyImportsMagicString,\n} from './type-elision.js';\n\nimport {\n emitAngularExpr,\n emitAngularStmt,\n setEmitterSourceCode,\n} from './js-emitter.js';\nimport { lowerClassFields } from './class-field-lowering.js';\nimport {\n extractMetadata,\n collectStringConstants,\n detectSignals,\n detectFieldDecorators,\n extractConstructorDeps,\n} from './metadata.js';\nimport { buildDeferDependencyMap, buildImportMap } from './defer.js';\nimport { buildCtorParameters, buildPropDecorators } from './jit-metadata.js';\nimport { debugCompile, debugEmit } from './debug.js';\nimport { inlineStyleRanges } from './style-ast.js';\n\n/**\n * COMPLETE EXHAUSTIVE ANGULAR LITE COMPILER\n * Translates Angular Decorators + Signals to Ivy Static Definitions.\n *\n * @param registry - Optional external registry from the global analysis plugin.\n * When provided, used to resolve component/directive selectors for template compilation.\n */\nexport interface CompileResult {\n code: string;\n /** Source map for the transformation */\n map: ReturnType<MagicString['generateMap']>;\n /** Absolute paths of external resources (templateUrl, styleUrl) read during compilation */\n resourceDependencies: string[];\n}\n\nexport interface CompileOptions {\n registry?: ComponentRegistry;\n /** Pre-resolved style contents keyed by absolute file path (e.g. SCSS already compiled to CSS). */\n resolvedStyles?: Map<string, string>;\n /** Pre-processed inline styles (index in styles array → compiled CSS). */\n resolvedInlineStyles?: Map<number, string>;\n /**\n * When `false` (default), instance class field initializers are lowered to\n * constructor assignments (matching TypeScript's `useDefineForClassFields: false`\n * behavior). This is required for Angular's `inject()` and constructor DI to\n * work correctly with the standard Angular tsconfig.\n */\n useDefineForClassFields?: boolean;\n /** Enable legacy i18n message ID format (default: true). */\n enableI18nLegacyMessageIdFormat?: boolean;\n /** Normalize line endings in ICU expressions (default: true). */\n i18nNormalizeLineEndingsInICUs?: boolean;\n /** Use external IDs in `$localize` calls (for Closure Compiler compatibility). */\n i18nUseExternalIds?: boolean;\n /**\n * Compilation output mode.\n * - `'full'` (default): Emit final Ivy definitions (`ɵɵdefineComponent`) for application builds.\n * - `'partial'`: Emit partial declarations (`ɵɵngDeclareComponent`) for library publishing.\n * Partial output is version-stable and linked at application build time.\n */\n compilationMode?: 'full' | 'partial';\n /**\n * Pre-parsed OXC program of `sourceCode`, so callers that already parsed\n * the identical string can avoid a re-parse. Treated as read-only.\n */\n oxcProgram?: ReturnType<typeof parseSync>['program'];\n}\n\ntype CompileMetadata = ReturnType<typeof extractMetadata>;\n\ntype CompileDeclaration = {\n type: o.Expression;\n selector: string | null;\n className?: string;\n kind: number;\n name?: string;\n inputs?: string[];\n outputs?: string[];\n exportAs?: string[];\n isComponent?: boolean;\n};\n\n/** A top-level statement with any `export` wrapper unwrapped. */\ninterface TopLevelStatement {\n /** The declaration (or the statement itself when not exported). */\n decl: any;\n exported: boolean;\n /** Start of the whole statement, including leading class decorators. */\n start: number;\n end: number;\n}\n\nfunction toTopLevelStatement(stmt: any): TopLevelStatement {\n const isExport =\n (stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration') &&\n stmt.declaration;\n const decl = isExport ? stmt.declaration : stmt;\n return {\n decl,\n exported: !!isExport,\n start: Math.min(stmt.start, decl.decorators?.[0]?.start ?? stmt.start),\n end: stmt.end,\n };\n}\n\n/** Get the callee name of a decorator call, e.g. `Component` for `@Component(...)`. */\nfunction decoratorCallName(dec: any, sourceCode: string): string | undefined {\n const callee = dec.expression;\n if (callee?.type !== 'CallExpression') return undefined;\n return sourceCode.slice(callee.callee.start, callee.callee.end);\n}\n\n/**\n * Normalize a `providers` / `viewProviders` metadata value into the single\n * `o.Expression` Angular's injector/host emitters expect.\n *\n * `extractMetadata` stores these as an array of `WrappedNodeExpr` when the\n * source used an inline array literal (`providers: [A, B]`) — those get\n * wrapped in a `LiteralArrayExpr`. When the source referenced a const,\n * spread, or call instead (`providers: safeProviders`), it stores the raw\n * expression, which is emitted by value. Returns `null` when there is\n * nothing to emit so callers skip the feature entirely.\n */\nfunction providersToExpr(\n value: o.Expression[] | o.Expression | undefined | null,\n): o.Expression | null {\n if (!value) return null;\n if (Array.isArray(value)) {\n return value.length ? new o.LiteralArrayExpr(value) : null;\n }\n return value;\n}\n\nconst LAZY_SCOPE_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n 'ClassDeclaration',\n 'ClassExpression',\n 'TSFunctionType',\n 'TSConstructorType',\n 'TSMethodSignature',\n 'TSCallSignatureDeclaration',\n 'TSConstructSignatureDeclaration',\n]);\n\n/**\n * Collect identifier names referenced in eagerly-evaluated code only.\n * Skips function/arrow/class bodies so that lazy references\n * (e.g. `const TOKEN = () => LaterClass`) are not treated as dependencies.\n * The root node's own children are always walked.\n */\nfunction collectIdentifiers(root: any): Set<string> {\n const ids = new Set<string>();\n walkOxc(root, (n) => {\n if (n.type === 'Identifier') ids.add(n.name);\n return n === root || !LAZY_SCOPE_TYPES.has(n.type);\n });\n return ids;\n}\n\n/** Extract the names defined by a top-level declaration. */\nfunction getDefinedNames(decl: any): string[] {\n if (decl.type === 'VariableDeclaration') {\n const names: string[] = [];\n for (const d of decl.declarations) {\n collectBindingNames(d.id, names);\n }\n return names;\n }\n if (\n (decl.type === 'FunctionDeclaration' || decl.type === 'ClassDeclaration') &&\n decl.id\n ) {\n return [decl.id.name];\n }\n return [];\n}\n\n/** Recursively collect all bound identifiers from a binding pattern. */\nfunction collectBindingNames(pattern: any, out: string[]): void {\n if (!pattern) return;\n switch (pattern.type) {\n case 'Identifier':\n out.push(pattern.name);\n break;\n case 'ObjectPattern':\n for (const prop of pattern.properties) {\n collectBindingNames(\n prop.type === 'RestElement' ? prop.argument : prop.value,\n out,\n );\n }\n break;\n case 'ArrayPattern':\n for (const el of pattern.elements) collectBindingNames(el, out);\n break;\n case 'RestElement':\n collectBindingNames(pattern.argument, out);\n break;\n case 'AssignmentPattern':\n collectBindingNames(pattern.left, out);\n break;\n }\n}\n\nexport function compile(\n sourceCode: string,\n fileName: string,\n optionsOrRegistry?: CompileOptions | ComponentRegistry,\n): CompileResult {\n // Backward compat: accept ComponentRegistry directly\n const opts: CompileOptions =\n optionsOrRegistry instanceof Map\n ? { registry: optionsOrRegistry }\n : optionsOrRegistry || {};\n const registry = opts.registry;\n const resolvedStyles = opts.resolvedStyles;\n const resolvedInlineStyles = opts.resolvedInlineStyles;\n const useDefineForClassFields = opts.useDefineForClassFields ?? false;\n const isPartial = opts.compilationMode === 'partial';\n const startTimeMs = debugCompile.enabled ? performance.now() : 0;\n debugCompile(\n 'compile %s (mode=%s, registry=%d entries)',\n fileName,\n isPartial ? 'partial' : 'full',\n registry?.size ?? 0,\n );\n const oxcProgram = opts.oxcProgram ?? parseOxc(fileName, sourceCode).program;\n const styleRanges = resolvedInlineStyles && inlineStyleRanges(oxcProgram);\n const oxcClassMap = new Map<string, any>();\n for (const stmt of oxcProgram.body) {\n const decl =\n stmt.type === 'ExportNamedDeclaration' ||\n stmt.type === 'ExportDefaultDeclaration'\n ? (stmt as any).declaration\n : stmt;\n if (\n decl &&\n (decl.type === 'ClassDeclaration' || decl.type === 'ClassExpression') &&\n decl.id?.name\n ) {\n oxcClassMap.set(decl.id.name, decl);\n }\n }\n\n // Collect module-level string constants so decorator metadata can resolve\n // template-literal interpolations like `template: \\`<div class=\"${tw}\">x</div>\\``.\n const stringConsts = collectStringConstants(oxcProgram);\n\n const constantPool = new ConstantPool();\n const resourceDependencies: string[] = [];\n const parseFile = new ParseSourceFile(sourceCode, fileName);\n const parseLoc = new ParseLocation(parseFile, 0, 0, 0);\n const typeSourceSpan = new ParseSourceSpan(parseLoc, parseLoc);\n const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, oxcProgram);\n const importSpecifierByName = new Map<string, string>();\n const importedNames = new Set<string>();\n const typeOnlyImportedNames = new Set<string>();\n\n for (const stmt of oxcProgram.body as any[]) {\n if (stmt.type !== 'ImportDeclaration') continue;\n\n const moduleSpecifier: string = stmt.source.value;\n // Explicit `import type { X }` — declaration-level type-only import\n const isDeclarationTypeOnly = stmt.importKind === 'type';\n for (const element of stmt.specifiers) {\n if (element.type !== 'ImportSpecifier') continue;\n const localName: string = element.local.name;\n importSpecifierByName.set(localName, moduleSpecifier);\n // Explicit `import { type X }` — specifier-level type-only import.\n // Both forms erase the symbol at runtime, so they cannot be used as\n // DI tokens. Add them to typeOnlyImports so extractConstructorDeps\n // surfaces ɵɵinvalidFactory() instead of emitting a broken\n // ɵɵdirectiveInject(X) referring to a non-existent value.\n if (isDeclarationTypeOnly || element.importKind === 'type') {\n typeOnlyImports.add(localName);\n typeOnlyImportedNames.add(localName);\n } else {\n importedNames.add(localName);\n }\n }\n }\n\n // Build a file-local selector map as fallback when no external registry is provided.\n // Skip the expensive extractMetadata scan when a registry covers all classes.\n const localSelectors = new Map<string, string>();\n /**\n * Per component class: the dependencies only its @defer blocks use, which\n * its class metadata must load lazily (`ɵsetClassMetadataAsync`).\n */\n const deferredMetadataDeps = new Map<\n string,\n { symbolName: string; importPath: string; isDefaultImport: boolean }[]\n >();\n if (!registry) {\n for (const [clsName, oxcNode] of oxcClassMap) {\n const decs: any[] = oxcNode.decorators || [];\n if (decs.length > 0) {\n const meta = extractMetadata(decs[0], sourceCode, stringConsts);\n if (meta?.selector) {\n localSelectors.set(clsName, meta.selector.split(',')[0].trim());\n }\n }\n }\n }\n\n const bindingParser = isPartial ? undefined : makeBindingParser();\n setEmitterSourceCode(sourceCode);\n\n // --- Direct walk: compile each Angular-decorated class and collect string outputs ---\n interface ClassCompileResult {\n ivyCode: string[]; // \"static ɵfac = ...\", \"static ɵcmp = ...\", etc.\n decorators: any[]; // Angular decorators to remove (OXC nodes)\n classEnd: number; // Position of closing } in original source\n // setClassMetadata calls for classes nested in a function scope, which\n // must be emitted next to the class rather than at module scope.\n scopedMetadata: o.Statement[];\n }\n const classResults: ClassCompileResult[] = [];\n const topLevelClasses = new Set(\n (oxcProgram.body as any[]).map((stmt) => toTopLevelStatement(stmt).decl),\n );\n // Track synthetic imports needed for NgModule export expansion.\n // Maps exported class name → import specifier.\n const syntheticImports = new Map<string, string>();\n // A type-only import is erased at runtime, so its synthetic value import\n // needs an alias to avoid redeclaring the type-only binding.\n const dependencyLocalName = (name: string) =>\n typeOnlyImportedNames.has(name) ? `ɵngDep_${name}` : name;\n\n // ANGULAR_DECORATORS imported from utils\n\n for (const node of findAllClasses(oxcProgram)) {\n const decorators: any[] = node.decorators;\n if (!decorators || decorators.length === 0) continue;\n\n const className: string | undefined = node.id?.name;\n if (!className) continue;\n\n const angularDecorators = decorators.filter((dec) =>\n ANGULAR_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? ''),\n );\n if (angularDecorators.length === 0) continue;\n\n const ivyCode: string[] = [];\n let targetType: FactoryTarget = FactoryTarget.Injectable;\n // Store resolved resources per decorator for metadata inlining\n const resolvedResources = new Map<\n any,\n { template?: string; styles?: string[] }\n >();\n\n const classRef: o.R3Reference = {\n value: new o.WrappedNodeExpr(className),\n type: new o.WrappedNodeExpr(className),\n };\n\n // Detect `class Foo extends Bar` so the directive/component def\n // gets `usesInheritance: true`. Angular's compiler turns that into\n // `features: [InheritDefinitionFeature]`, which is what causes the\n // runtime to merge inputs/outputs/queries/host bindings from the\n // base class. Without it, derived directives like\n // `BrnPopover extends BrnDialog` lose every input declared on the\n // base, and any host directive that references those inputs by\n // public name fails at runtime with NG0311.\n const usesInheritance = !!node.superClass;\n\n let classCompileError: Error | null = null;\n\n angularDecorators.forEach((dec) => {\n const decoratorName = decoratorCallName(dec, sourceCode)!;\n const meta = extractMetadata(dec, sourceCode, stringConsts);\n const sigs = detectSignals(node, sourceCode);\n const fields = detectFieldDecorators(node, sourceCode);\n const hostBindings = parseHostBindings(meta.hostRaw || {});\n\n const hostMetadata: o.R3HostMetadata = {\n attributes: hostBindings.attributes,\n listeners: { ...hostBindings.listeners, ...fields.hostListeners },\n properties: { ...hostBindings.properties, ...fields.hostProperties },\n specialAttributes: hostBindings.specialAttributes,\n };\n\n switch (decoratorName) {\n case 'Component': {\n targetType = FactoryTarget.Component;\n if (!meta.selector) {\n meta.selector = `ng-component-${className.toLowerCase()}`;\n }\n\n const declarations: CompileDeclaration[] = [];\n // Dedupe by class name across direct imports, tuple-barrel\n // expansion, and NgModule export expansion so the final\n // `dependencies: () => [...]` list never contains the same\n // class twice. Otherwise Angular's runtime throws NG0300\n // (\"Multiple components match …\") when a file lists both\n // `NgIcon` and a barrel like `HlmIconImports = [HlmIcon, NgIcon]`\n // that re-exports it, or when two NgModules re-export the same\n // directive (e.g. FormsModule + ReactiveFormsModule →\n // DefaultValueAccessor).\n const seenDeclarationNames = new Set<string>();\n\n // Expand `imports` entries that are not directives themselves\n // (e.g. NgModules and tuple barrels like `HlmSelectImports =\n // [HlmSelect, HlmSelectContent, ...] as const`) into the\n // underlying directive class names. Returns the original entry\n // when it doesn't match either expansion case.\n const collectExpandedImports = (\n depClassName: string,\n visited: Set<string>,\n ): string[] => {\n if (visited.has(depClassName)) return [];\n visited.add(depClassName);\n const entry = registry?.get(depClassName);\n if (!entry) return [depClassName];\n if (entry.kind === 'ngmodule' && entry.exports) {\n const out: string[] = [];\n for (const name of entry.exports) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n if (entry.kind === 'tuple' && entry.members) {\n const out: string[] = [];\n for (const name of entry.members) {\n out.push(...collectExpandedImports(name, visited));\n }\n return out;\n }\n return [depClassName];\n };\n\n for (const dep of Array.isArray(meta.imports) ? meta.imports : []) {\n const depNode = dep.node;\n const depClassName: string =\n typeof depNode === 'string'\n ? depNode\n : (depNode?.name ?? depNode?.type === 'Identifier')\n ? depNode.name\n : sourceCode.slice(depNode?.start ?? 0, depNode?.end ?? 0);\n const registryEntry = registry?.get(depClassName);\n\n // Tuple barrel: `imports: [HlmSelectImports]` where the\n // const is `[HlmSelect, HlmSelectContent, ...] as const`.\n // Expand into the underlying directive declarations and\n // track synthetic imports for any classes not already\n // referenced in this file.\n if (registryEntry?.kind === 'tuple' && registryEntry.members) {\n const expanded = collectExpandedImports(depClassName, new Set());\n const tupleSpecifier = importSpecifierByName.get(depClassName);\n for (const memberName of expanded) {\n const memberEntry = registry?.get(memberName);\n if (!memberEntry || memberEntry.kind === 'tuple') continue;\n const memberRef = new o.WrappedNodeExpr(\n dependencyLocalName(memberName),\n );\n if (!importedNames.has(memberName)) {\n const memberSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n memberEntry,\n tupleSpecifier,\n );\n if (memberSpecifier) {\n syntheticImports.set(memberName, memberSpecifier);\n }\n }\n const kind = memberEntry.kind === 'pipe' ? 1 : 0;\n const memberDecl: CompileDeclaration = {\n type: memberRef,\n selector: memberEntry.selector,\n kind,\n ...(kind === 1 ? { name: memberEntry.pipeName } : {}),\n };\n if (memberEntry.inputs) {\n memberDecl.inputs = Object.values(memberEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (memberEntry.outputs) {\n memberDecl.outputs = Object.values(\n memberEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(memberName)) {\n seenDeclarationNames.add(memberName);\n declarations.push(memberDecl);\n }\n }\n continue;\n }\n\n if (registryEntry?.kind === 'ngmodule' && registryEntry.exports) {\n const moduleSpecifier = importSpecifierByName.get(depClassName);\n\n // Recursively collect all non-module exports (handles nested NgModules\n // like ReactiveFormsModule → ɵInternalFormsSharedModule → DefaultValueAccessor)\n const allExports: string[] = [];\n const expandModule = (\n moduleName: string,\n visited = new Set<string>(),\n ) => {\n if (visited.has(moduleName)) return;\n visited.add(moduleName);\n const mod = registry?.get(moduleName);\n if (!mod?.exports) return;\n for (const name of mod.exports) {\n const entry = registry?.get(name);\n if (!entry) continue;\n if (entry.kind === 'ngmodule') {\n expandModule(name, visited);\n } else {\n allExports.push(name);\n }\n }\n };\n expandModule(depClassName);\n\n for (const exportedName of allExports) {\n const exportedEntry = registry?.get(exportedName);\n if (exportedEntry) {\n const kind = exportedEntry.kind === 'pipe' ? 1 : 0;\n // Create a reference to the exported class. If it's not\n // already imported, track it for synthetic import injection.\n const exportedRef = new o.WrappedNodeExpr(\n dependencyLocalName(exportedName),\n );\n const exportedSpecifier = resolveSyntheticImportSpecifier(\n fileName,\n exportedEntry,\n moduleSpecifier,\n );\n if (exportedSpecifier) {\n syntheticImports.set(exportedName, exportedSpecifier);\n }\n const decl: CompileDeclaration = {\n type: exportedRef,\n selector: exportedEntry.selector,\n kind,\n ...(kind === 1 ? { name: exportedEntry.pipeName } : {}),\n };\n if (exportedEntry.inputs) {\n decl.inputs = Object.values(exportedEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (exportedEntry.outputs) {\n decl.outputs = Object.values(\n exportedEntry.outputs,\n ) as string[];\n }\n if (!seenDeclarationNames.has(exportedName)) {\n seenDeclarationNames.add(exportedName);\n declarations.push(decl);\n }\n }\n }\n continue;\n }\n\n const selector =\n registryEntry?.selector ?? localSelectors.get(depClassName);\n const kind = registryEntry?.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: dep,\n selector: selector || `_unresolved-${depClassName}`,\n kind,\n ...(kind === 1 ? { name: registryEntry?.pipeName } : {}),\n };\n // Pass inputs/outputs from registry so template bindings resolve.\n // R3DirectiveDependencyMetadata expects inputs/outputs as string[]\n // of binding property names.\n if (registryEntry?.inputs) {\n decl.inputs = Object.values(registryEntry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (registryEntry?.outputs) {\n decl.outputs = Object.values(registryEntry.outputs) as string[];\n }\n if (!seenDeclarationNames.has(depClassName)) {\n seenDeclarationNames.add(depClassName);\n declarations.push(decl);\n }\n }\n\n // Add self-reference so recursive components (e.g. tree views)\n // can use their own selector in their template.\n // Skip in partial mode — the linker handles self-resolution.\n if (!isPartial && !seenDeclarationNames.has(className)) {\n const selfInputs = Object.entries(sigs.inputs).map(\n ([, v]: [string, any]) => v.bindingPropertyName,\n );\n const selfOutputs = Object.values({\n ...meta.outputs,\n ...fields.outputs,\n ...sigs.outputs,\n }) as string[];\n seenDeclarationNames.add(className);\n declarations.push({\n type: classRef.value,\n selector: meta.selector,\n kind: 0,\n ...(selfInputs.length > 0 ? { inputs: selfInputs } : {}),\n ...(selfOutputs.length > 0 ? { outputs: selfOutputs } : {}),\n });\n }\n\n // Non-standalone components get their directive/pipe scope from the\n // @NgModule that declares them. Whole-program ngtsc resolves this; a\n // per-file engine can't read the module from the component file, but the\n // project-wide registry (populated at buildStart) records every module's\n // declarations + imports. We resolve the owning module's transitive scope\n // here and inline it into the component's own `dependencies` — matching\n // ngtsc, and surviving tree-shaking (unlike a separate, droppable\n // `ɵɵsetComponentScope` call).\n //\n // A component declared in an @NgModule must set\n // `standalone: false`, so only those need the owning-module lookup.\n if (!isPartial && meta.standalone === false && registry) {\n let owningModule:\n | { declarations?: string[]; imports?: string[] }\n | undefined;\n for (const entry of registry.values()) {\n if (\n entry.kind === 'ngmodule' &&\n entry.declarations?.includes(className)\n ) {\n owningModule = entry;\n break;\n }\n }\n if (owningModule) {\n // Transitive scope = the module's own declarations + the exported\n // declarations of every imported module (recursively) + tuple members.\n const scopeNames = new Set<string>();\n const addExportsOf = (modName: string, visited: Set<string>) => {\n if (visited.has(modName)) return;\n visited.add(modName);\n const e = registry.get(modName);\n if (!e) return;\n if (e.kind === 'ngmodule') {\n for (const exp of e.exports ?? []) addExportsOf(exp, visited);\n } else if (e.kind === 'tuple') {\n for (const m of e.members ?? []) scopeNames.add(m);\n } else {\n scopeNames.add(modName);\n }\n };\n for (const d of owningModule.declarations ?? [])\n scopeNames.add(d);\n for (const imp of owningModule.imports ?? [])\n addExportsOf(imp, new Set());\n\n for (const name of scopeNames) {\n if (seenDeclarationNames.has(name)) continue;\n const entry = registry.get(name);\n if (\n !entry ||\n entry.kind === 'ngmodule' ||\n entry.kind === 'tuple'\n )\n continue;\n if (!importedNames.has(name)) {\n const spec = resolveSyntheticImportSpecifier(\n fileName,\n entry,\n importSpecifierByName.get(name),\n );\n if (spec) syntheticImports.set(name, spec);\n }\n const kind = entry.kind === 'pipe' ? 1 : 0;\n const decl: CompileDeclaration = {\n type: new o.WrappedNodeExpr(dependencyLocalName(name)),\n selector: entry.selector || `_unresolved-${name}`,\n kind,\n ...(kind === 1 ? { name: entry.pipeName } : {}),\n };\n if (entry.inputs) {\n decl.inputs = Object.values(entry.inputs).map(\n (i) => i.bindingPropertyName,\n );\n }\n if (entry.outputs) {\n decl.outputs = Object.values(entry.outputs) as string[];\n }\n seenDeclarationNames.add(name);\n declarations.push(decl);\n }\n }\n }\n\n let templateContent = meta.template || '';\n if (!templateContent && meta.templateUrl) {\n try {\n const templatePath = path.resolve(\n path.dirname(fileName),\n meta.templateUrl,\n );\n templateContent = fs.readFileSync(templatePath, 'utf-8');\n resourceDependencies.push(templatePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read template file \"${meta.templateUrl}\" for ${className}`,\n );\n }\n }\n\n if (Array.isArray(meta.styleUrls)) {\n for (const url of meta.styleUrls) {\n try {\n const stylePath = path.resolve(path.dirname(fileName), url);\n const styleContent =\n resolvedStyles?.get(stylePath) ??\n fs.readFileSync(stylePath, 'utf-8');\n meta.styles.push(styleContent);\n resourceDependencies.push(stylePath);\n } catch {\n console.warn(\n `[fast-compile] Could not read style file \"${url}\" for ${className}`,\n );\n }\n }\n }\n\n const styleRange = styleRanges?.get(dec);\n if (resolvedInlineStyles && styleRange) {\n for (let k = 0; k < styleRange.count; k++) {\n const css = resolvedInlineStyles.get(styleRange.start + k);\n if (css !== undefined) meta.styles[k] = css;\n }\n }\n\n // Store resolved resources for metadata inlining\n resolvedResources.set(dec, {\n template: templateContent || undefined,\n styles: meta.styles?.length > 0 ? [...meta.styles] : undefined,\n });\n\n const parsedTemplate = parseTemplate(templateContent, fileName, {\n preserveWhitespaces: meta.preserveWhitespaces,\n enableI18nLegacyMessageIdFormat:\n opts.enableI18nLegacyMessageIdFormat ?? true,\n i18nNormalizeLineEndingsInICUs:\n opts.i18nNormalizeLineEndingsInICUs ?? true,\n });\n\n const ivyInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (ivyInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(ivyInputs, meta.inputs);\n }\n Object.assign(ivyInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n ivyInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals\n // so `input(null, { alias: 'aria-label' })` registers with\n // the public name `aria-label`, not the class property name.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const templateErrors = parsedTemplate.errors ?? [];\n if (templateErrors.length > 0) {\n const firstError = templateErrors[0];\n classCompileError = new Error(\n `[fast-compile] Template parse error in ${fileName} (${className}): ${firstError.msg}`,\n );\n return;\n }\n\n // Classes used only inside @defer blocks load through the blocks'\n // dynamic import()s, so they must not also be eager dependencies:\n // that would keep their module in this chunk. Once nothing else\n // references them, the TypeScript strip pass drops their imports.\n const deferDependencies = buildDeferDependencyMap(\n parsedTemplate,\n oxcProgram,\n registry,\n localSelectors,\n );\n if (!isPartial && deferDependencies.deferredImports.size > 0) {\n const importMap = buildImportMap(oxcProgram);\n const metadataDeps: {\n symbolName: string;\n importPath: string;\n isDefaultImport: boolean;\n }[] = [];\n for (let i = declarations.length - 1; i >= 0; i--) {\n const name = declarationName(declarations[i]);\n const info = name !== null ? importMap.get(name) : undefined;\n if (\n name === null ||\n info === undefined ||\n !deferDependencies.deferredImports.has(name)\n ) {\n continue;\n }\n declarations.splice(i, 1);\n metadataDeps.unshift({\n symbolName: name,\n importPath: info.path,\n isDefaultImport: info.isDefault,\n });\n }\n if (metadataDeps.length > 0) {\n deferredMetadataDeps.set(className, metadataDeps);\n }\n }\n\n const componentMeta: CompileMetadata & {\n name: string;\n type: o.R3Reference;\n typeSourceSpan: ParseSourceSpan;\n declarations: CompileDeclaration[];\n template: {\n nodes: o.Node[];\n ngContentSelectors: string[];\n preserveWhitespaces: boolean;\n };\n } = {\n ...meta,\n name: className,\n type: classRef,\n typeSourceSpan,\n declarations,\n template: {\n nodes: parsedTemplate.nodes,\n ngContentSelectors: parsedTemplate.ngContentSelectors,\n preserveWhitespaces: parsedTemplate.preserveWhitespaces,\n },\n styles: [...(meta.styles || []), ...(parsedTemplate.styles || [])],\n inputs: ivyInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n host: hostMetadata,\n changeDetection: meta.changeDetection ?? (isPartial ? null : 1),\n encapsulation: meta.encapsulation ?? 0,\n exportAs: meta.exportAs,\n providers: providersToExpr(meta.providers),\n viewProviders: providersToExpr(meta.viewProviders),\n animations: meta.animations?.length\n ? new o.LiteralArrayExpr(meta.animations)\n : null,\n isStandalone: meta.standalone,\n imports: meta.imports,\n lifecycle: { usesOnChanges: false },\n // Angular v19/v20's `createComponentDefinitionMap` reads\n // `meta.interpolation.start` and `meta.interpolation.end`\n // unconditionally (the `!== DEFAULT_INTERPOLATION_CONFIG` check\n // is reference-equality, so a missing field enters the block\n // and crashes with `Cannot read properties of undefined`). v21\n // dropped the field from `createComponentDefinitionMap`\n // entirely. Use the v19/v20 singleton when the Angular package\n // exports it (matches the reference-equality check, skipping\n // the partial-mode emission block) and fall back to a plain\n // shape on v21+ where the field is ignored anyway.\n interpolation: (\n o as {\n DEFAULT_INTERPOLATION_CONFIG?: { start: string; end: string };\n }\n ).DEFAULT_INTERPOLATION_CONFIG ?? { start: '{{', end: '}}' },\n usesInheritance,\n defer: {\n mode: 0,\n blocks: deferDependencies.blocks,\n },\n declarationListEmitMode: 1,\n i18nUseExternalIds: opts.i18nUseExternalIds ?? false,\n relativeContextFilePath: fileName,\n controlCreate: null,\n hasDirectiveDependencies:\n declarations.length > 0 ||\n (Array.isArray(meta.imports) && meta.imports.length > 0),\n };\n\n if (isPartial) {\n // Partial compilation accesses .inputs, .outputs, .exportAs on\n // each declaration — ensure they are arrays (not undefined).\n componentMeta.declarations = declarations.map((d) => ({\n ...d,\n inputs: d.inputs ?? null,\n outputs: d.outputs ?? null,\n exportAs: d.exportAs ?? null,\n isComponent: d.isComponent ?? false,\n }));\n const cmp = compileDeclareComponentFromMetadata(\n componentMeta,\n parsedTemplate,\n {\n content: templateContent,\n sourceUrl: fileName,\n isInline: !meta.templateUrl,\n inlineTemplateLiteralExpression: null,\n },\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n } else {\n const cmp = compileComponentFromMetadata(\n componentMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵcmp = /*@__PURE__*/ ${emitAngularExpr(cmp.expression)}`,\n );\n }\n break;\n }\n\n case 'Directive': {\n targetType = FactoryTarget.Directive;\n // Build proper input descriptors (same as Component path)\n const dirInputs: Record<string, unknown> = {};\n if (Array.isArray(meta.inputs)) {\n meta.inputs.forEach((i: string) => (dirInputs[i] = i));\n } else if (meta.inputs) {\n Object.assign(dirInputs, meta.inputs);\n }\n Object.assign(dirInputs, fields.inputs);\n for (const [key, val] of Object.entries(sigs.inputs)) {\n const sigDesc = val as {\n bindingPropertyName?: string;\n required?: boolean;\n transform?: o.Expression | null;\n };\n dirInputs[key] = {\n classPropertyName: key,\n // Honor the binding name (alias) extracted by detectSignals.\n bindingPropertyName: sigDesc.bindingPropertyName ?? key,\n isSignal: true,\n required: sigDesc.required || false,\n transformFunction: sigDesc.transform || null,\n };\n }\n const directiveMeta = {\n ...meta,\n // Abstract base directives are declared as `@Directive()` with\n // no metadata. Angular's R3DirectiveMetadata accepts\n // `selector: string | null`, but the downstream selector parser\n // calls `.replace()` on the value and crashes on `undefined`.\n // Coerce missing selectors to `null` so abstract base classes\n // compile correctly.\n selector: meta.selector ?? null,\n name: className,\n type: classRef,\n typeSourceSpan,\n host: hostMetadata,\n inputs: dirInputs,\n outputs: { ...meta.outputs, ...fields.outputs, ...sigs.outputs },\n viewQueries: [...fields.viewQueries, ...sigs.viewQueries],\n queries: [...fields.contentQueries, ...sigs.contentQueries],\n // Angular's compiler treats `providers` as an Expression and\n // emits `ɵɵProvidersFeature(<expr>)` whenever it is truthy.\n // `providersToExpr` lowers an inline array literal to a\n // LiteralArrayExpr (matching the Component branch) and passes a\n // const/spread reference through by value — returning `null`\n // when there are no providers so Angular skips the feature\n // entirely. Passing the bare JS array would otherwise be lowered\n // to `null` and crash Angular at runtime in `resolveProvider`.\n providers: providersToExpr(meta.providers),\n exportAs: meta.exportAs,\n isStandalone: meta.standalone,\n lifecycle: { usesOnChanges: false },\n usesInheritance,\n controlCreate: null,\n };\n if (isPartial) {\n const dir = compileDeclareDirectiveFromMetadata(directiveMeta);\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n } else {\n const dir = compileDirectiveFromMetadata(\n directiveMeta,\n constantPool,\n bindingParser!,\n );\n ivyCode.push(\n `static ɵdir = /*@__PURE__*/ ${emitAngularExpr(dir.expression)}`,\n );\n }\n break;\n }\n\n case 'Pipe': {\n targetType = FactoryTarget.Pipe;\n const pipeMeta = {\n ...meta,\n name: className,\n pipeName: meta.name,\n type: classRef,\n isStandalone: meta.standalone,\n pure: meta.pure ?? true,\n };\n if (isPartial) {\n const pipe = compileDeclarePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n } else {\n const pipe = compilePipeFromMetadata(pipeMeta);\n ivyCode.push(\n `static ɵpipe = /*@__PURE__*/ ${emitAngularExpr(pipe.expression)}`,\n );\n }\n break;\n }\n\n case 'Injectable': {\n targetType = FactoryTarget.Injectable;\n const injectableMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n providedIn: {\n expression: new o.LiteralExpr(meta.providedIn ?? null),\n forwardRef: 0,\n },\n };\n // Forward provider configuration so `ɵprov` honors useFactory/\n // useClass/useExisting/useValue. Without this, an\n // `@Injectable({ useFactory: () => ... })` quietly falls back\n // to constructor instantiation.\n if (meta.useClass) injectableMeta.useClass = meta.useClass;\n if (meta.useFactory) injectableMeta.useFactory = meta.useFactory;\n if (meta.useExisting) injectableMeta.useExisting = meta.useExisting;\n if (meta.useValue) injectableMeta.useValue = meta.useValue;\n // Dependency list for `useFactory` / `useClass`; without it the\n // emitted factory is invoked with no arguments.\n if (meta.deps) injectableMeta.deps = meta.deps;\n if (isPartial) {\n const inj = compileDeclareInjectableFromMetadata(injectableMeta);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n } else {\n const inj = o.compileInjectable(injectableMeta, true);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(inj.expression)}`,\n );\n }\n break;\n }\n\n case 'Service': {\n // `@Service` (and the `compileService` compiler API) landed in\n // Angular 22. On older peers the decorator does not exist; fail\n // loudly rather than falling through and emitting a default\n // `Injectable`-target factory with no `ɵprov`.\n if (!angularVersionAtLeast(22)) {\n classCompileError = new Error(\n `[fast-compile] @Service on ${className} requires Angular 22 or later`,\n );\n break;\n }\n targetType = (FactoryTarget as any).Service;\n const serviceMeta: any = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n };\n if (meta.autoProvided === false) serviceMeta.autoProvided = false;\n if (meta.factory) serviceMeta.factory = meta.factory;\n if (isPartial) {\n const svc = (o as any).compileDeclareServiceFromMetadata(\n serviceMeta,\n );\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n } else {\n const svc = (o as any).compileService(serviceMeta, false);\n ivyCode.push(\n `static ɵprov = /*@__PURE__*/ ${emitAngularExpr(svc.expression)}`,\n );\n }\n break;\n }\n\n case 'NgModule': {\n targetType = FactoryTarget.NgModule;\n const ngModuleImports = Array.isArray(meta.imports)\n ? meta.imports\n : [];\n const ngModuleDeclarations = Array.isArray(meta.declarations)\n ? meta.declarations\n : [];\n const ngModuleExports = Array.isArray(meta.exports)\n ? meta.exports\n : [];\n const ngModuleBootstrap = Array.isArray(meta.bootstrap)\n ? meta.bootstrap\n : [];\n\n const ngModuleMeta = {\n kind: R3NgModuleMetadataKind.Global as const,\n type: classRef,\n bootstrap: ngModuleBootstrap.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n declarations: ngModuleDeclarations.map(\n (e: o.WrappedNodeExpr<any>) => ({ value: e, type: e }),\n ),\n publicDeclarationTypes: null,\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n includeImportTypes: true,\n exports: ngModuleExports.map((e: o.WrappedNodeExpr<any>) => ({\n value: e,\n type: e,\n })),\n selectorScopeMode: R3SelectorScopeMode.Inline,\n containsForwardDecls: false,\n schemas: [],\n id: null,\n };\n const injectorMeta = {\n name: className,\n type: classRef,\n providers: providersToExpr(meta.providers),\n imports: ngModuleImports.map((e: o.WrappedNodeExpr<any>) => e),\n };\n if (isPartial) {\n const ngMod = compileDeclareNgModuleFromMetadata(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileDeclareInjectorFromMetadata(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n } else {\n const ngMod = compileNgModule(ngModuleMeta);\n ivyCode.push(\n `static ɵmod = /*@__PURE__*/ ${emitAngularExpr(ngMod.expression)}`,\n );\n const injector = compileInjector(injectorMeta);\n ivyCode.push(\n `static ɵinj = /*@__PURE__*/ ${emitAngularExpr(injector.expression)}`,\n );\n }\n break;\n }\n }\n });\n\n if (classCompileError) {\n throw classCompileError;\n }\n\n // Generate factory\n const deps = extractConstructorDeps(node, sourceCode, typeOnlyImports);\n if (deps === null) {\n const baseVar = `ɵ${className}_BaseFactory`;\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ (() => { let ${baseVar}; return function ${className}_Factory(__ngFactoryType__) { return (${baseVar} || (${baseVar} = i0.ɵɵgetInheritedFactory(${className})))(__ngFactoryType__ || ${className}); }; })()`,\n );\n } else if (deps === 'invalid') {\n ivyCode.unshift(\n `static ɵfac = function ${className}_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); }`,\n );\n } else {\n const factoryMeta = {\n name: className,\n type: classRef,\n typeArgumentCount: 0,\n deps,\n target: targetType,\n };\n if (isPartial) {\n const fac = compileDeclareFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n } else {\n const fac = compileFactoryFunction(factoryMeta);\n ivyCode.unshift(\n `static ɵfac = /*@__PURE__*/ ${emitAngularExpr(fac.expression)}`,\n );\n }\n }\n\n // Emit setClassMetadata for runtime decorator reflection (devMode only)\n const ctorParameters = buildCtorParameters(\n node,\n sourceCode,\n typeOnlyImports,\n );\n const propDecorators = buildPropDecorators(node, sourceCode, 'i0.');\n const scopedMetadata: o.Statement[] = [];\n angularDecorators.forEach((dec) => {\n const decName = decoratorCallName(dec, sourceCode)!;\n const decArgsNode = dec.expression.arguments[0];\n const textOf = (n: any) => sourceCode.slice(n.start, n.end);\n\n // Build the decorator args for setClassMetadata, inlining resources if needed.\n const resources = resolvedResources.get(dec);\n let metadataArgsExpr: string | null = null;\n if (decArgsNode) {\n if (resources && decArgsNode.type === 'ObjectExpression') {\n // Inline external templateUrl/styleUrl(s) into the metadata so Angular's\n // runtime doesn't try to fetch relative URLs (which fails during SSR).\n const rewrittenProps: string[] = [];\n let needsTransform = false;\n for (const prop of decArgsNode.properties) {\n if (\n prop.type !== 'Property' ||\n prop.shorthand ||\n prop.method ||\n prop.kind !== 'init'\n ) {\n rewrittenProps.push(textOf(prop));\n continue;\n }\n const propName = textOf(prop.key);\n\n if (propName === 'templateUrl' && resources.template) {\n rewrittenProps.push(\n `template: ${JSON.stringify(resources.template)}`,\n );\n needsTransform = true;\n } else if (\n (propName === 'styleUrl' || propName === 'styleUrls') &&\n resources.styles?.length\n ) {\n rewrittenProps.push(\n `styles: [${resources.styles.map((s) => JSON.stringify(s)).join(', ')}]`,\n );\n needsTransform = true;\n } else {\n rewrittenProps.push(textOf(prop));\n }\n }\n metadataArgsExpr = needsTransform\n ? `{${rewrittenProps.join(', ')}}`\n : textOf(decArgsNode);\n } else {\n metadataArgsExpr = textOf(decArgsNode);\n }\n }\n\n try {\n // `LiteralMapPropertyAssignment` was a class with a constructor in\n // Angular up through ~v19, removed-then-restored in later v20/v21\n // patches. The only stable shape across versions is the plain\n // `{ key, value, quoted }` object literal — Angular's own emitter\n // and Analog's `JSEmitter` both consume entries via duck typing\n // (`.key` / `.value` / `.quoted`), and `compileClassMetadata` does\n // not `instanceof`-check entries. The js-emitter has a matching\n // comment at the consumption site. Using `new o.LiteralMapProperty\n // Assignment(...)` would throw \"is not a constructor\" on Angular\n // versions where the class export is missing (e.g. 20.3.x), and\n // the surrounding try/catch would silently disable class metadata\n // emission for every class in the project.\n const classMetaInput = {\n type: new o.WrappedNodeExpr(className),\n decorators: new o.LiteralArrayExpr([\n new o.LiteralMapExpr([\n {\n key: 'type',\n value: new o.WrappedNodeExpr(decName),\n quoted: false,\n },\n ...(metadataArgsExpr\n ? [\n {\n key: 'args',\n value: new o.LiteralArrayExpr([\n new o.WrappedNodeExpr(metadataArgsExpr),\n ]),\n quoted: false,\n },\n ]\n : []),\n ] as unknown as o.LiteralMapPropertyAssignment[]),\n ]),\n ctorParameters: ctorParameters\n ? new o.WrappedNodeExpr(`() => [${ctorParameters}]`)\n : null,\n propDecorators: propDecorators\n ? new o.WrappedNodeExpr(propDecorators)\n : null,\n };\n // A component whose @defer blocks load some dependencies lazily must\n // not reference them eagerly in its metadata either.\n const deferredDeps =\n decName === 'Component'\n ? deferredMetadataDeps.get(className)\n : undefined;\n const classMetadataExpr = isPartial\n ? compileDeclareClassMetadata(classMetaInput)\n : deferredDeps\n ? compileComponentClassMetadata(classMetaInput, deferredDeps)\n : compileClassMetadata(classMetaInput);\n const metadataStmt = new o.ExpressionStatement(classMetadataExpr);\n if (topLevelClasses.has(node)) {\n constantPool.statements.push(metadataStmt);\n } else {\n scopedMetadata.push(metadataStmt);\n }\n } catch (e) {\n // Skip if compileClassMetadata fails — surfaced via DEBUG=analog-fast-compile\n if (debugCompile.enabled) {\n debugCompile(\n 'compileClassMetadata failed for %s in %s: %s',\n className,\n fileName,\n (e as Error)?.message,\n );\n }\n }\n });\n\n // Collect member decorators (@HostListener, @HostBinding, @Input, @Output,\n // @ViewChild, @ContentChild, etc.) so they are removed from the source.\n // The metadata has already been extracted by detectFieldDecorators().\n const memberDecorators: any[] = [];\n for (const member of node.body.body) {\n for (const dec of member.decorators ?? []) {\n if (FIELD_DECORATORS.has(decoratorCallName(dec, sourceCode) ?? '')) {\n memberDecorators.push(dec);\n }\n }\n }\n\n classResults.push({\n ivyCode,\n decorators: [...angularDecorators, ...memberDecorators],\n classEnd: node.end,\n scopedMetadata,\n });\n }\n\n // Apply edits via MagicString\n const ms = new MagicString(sourceCode, { filename: fileName });\n\n // 1. Prepend i0 import (skip if already present)\n if (!sourceCode.includes('import * as i0 from')) {\n ms.prepend('import * as i0 from \"@angular/core\";\\n');\n }\n\n // 1b. Inject synthetic imports for NgModule-exported classes\n for (const [name, specifier] of syntheticImports) {\n const localName = dependencyLocalName(name);\n if (!importedNames.has(localName)) {\n const binding = localName === name ? name : `${name} as ${localName}`;\n ms.prepend(`import { ${binding} } from \"${specifier}\";\\n`);\n importedNames.add(localName);\n }\n }\n\n // 2a. Hoist non-exported variable/function declarations that appear after\n // a class to just before the first class. This avoids TDZ errors when\n // static ɵcmp references file-level constants declared after the class.\n //\n // We must NOT hoist a statement whose initializer references a name\n // (class, exported const/let) that is defined between firstClassPos and\n // the statement itself — doing so would move the reference before the\n // definition and cause a TDZ error at runtime.\n if (classResults.length > 0) {\n // Find the position right before the first class (any class, not just Angular-decorated)\n const statements = (oxcProgram.body as any[]).map(toTopLevelStatement);\n let firstClassPos = Infinity;\n const nonHoistableNames = new Set<string>();\n for (const { decl, start } of statements) {\n if (decl.type === 'ClassDeclaration') {\n firstClassPos = start;\n // The first class itself is non-hoistable — statements hoisted\n // before it must not reference it.\n if (decl.id) {\n nonHoistableNames.add(decl.id.name);\n }\n break;\n }\n }\n\n // Pass 1: collect names defined by statements that will NOT be hoisted\n // (classes, enums, exported vars/functions) and therefore remain after\n // firstClassPos.\n for (const { decl, exported, start } of statements) {\n if (start <= firstClassPos) continue;\n\n if (\n decl.type === 'ClassDeclaration' ||\n decl.type === 'TSEnumDeclaration'\n ) {\n if (decl.id) nonHoistableNames.add(decl.id.name);\n } else if (\n exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration')\n ) {\n for (const n of getDefinedNames(decl)) {\n nonHoistableNames.add(n);\n }\n }\n }\n\n // Pass 2: for each hoist candidate, check if it references any\n // non-hoistable name. If it does, skip it and add its own names to the\n // non-hoistable set (transitivity).\n for (const { decl, exported, start, end } of statements) {\n if (start <= firstClassPos) continue;\n\n const isCandidate =\n !exported &&\n (decl.type === 'VariableDeclaration' ||\n decl.type === 'FunctionDeclaration');\n if (!isCandidate) continue;\n\n const referencedIds = collectIdentifiers(decl);\n let referencesNonHoistable = false;\n for (const id of referencedIds) {\n if (nonHoistableNames.has(id)) {\n referencesNonHoistable = true;\n break;\n }\n }\n\n if (referencesNonHoistable) {\n // Don't hoist — mark this statement's names as non-hoistable too\n for (const name of getDefinedNames(decl)) {\n nonHoistableNames.add(name);\n }\n } else {\n // Move rather than re-insert so the statement keeps its source map.\n // The separating newline is attached to the moved chunk.\n ms.appendLeft(end, '\\n');\n ms.move(start, end, firstClassPos);\n }\n }\n }\n\n // 2. For each compiled class: remove decorators + insert Ivy definitions\n for (const cr of classResults) {\n // Remove Angular decorators from source\n for (const dec of cr.decorators) {\n const start = dec.start;\n const end = dec.end;\n let trimEnd = end;\n while (\n trimEnd < sourceCode.length &&\n (sourceCode[trimEnd] === ' ' ||\n sourceCode[trimEnd] === '\\n' ||\n sourceCode[trimEnd] === '\\r')\n ) {\n trimEnd++;\n }\n ms.remove(start, trimEnd);\n }\n\n // Insert static members before closing }\n if (cr.ivyCode.length > 0) {\n const memberCode = cr.ivyCode.map((c) => ' ' + c + ';').join('\\n');\n ms.appendLeft(cr.classEnd - 1, '\\n' + memberCode + '\\n');\n }\n\n for (const stmt of cr.scopedMetadata) {\n ms.appendLeft(cr.classEnd, `\\n/*@__PURE__*/ ${emitAngularStmt(stmt)}`);\n }\n }\n\n // 3. Emit constant pool statements.\n // Split into: helper declarations (const/function) that must appear before\n // the class (since static property initializers reference them), and\n // side-effect statements (setClassMetadata IIFEs) that go after.\n const helpers: string[] = [];\n const sideEffects: string[] = [];\n for (const s of constantPool.statements) {\n const code = emitAngularStmt(s);\n if (\n s instanceof o.ExpressionStatement &&\n s.expr instanceof o.InvokeFunctionExpr\n ) {\n // setClassMetadata is wrapped in `(() => { ... })()` — annotate\n // the IIFE call so bundlers can drop it when ngDevMode is folded\n // to false at production build time.\n sideEffects.push(`/*@__PURE__*/ ${code}`);\n } else {\n helpers.push(code);\n }\n }\n\n if (sideEffects.length > 0) {\n ms.append('\\n\\n' + sideEffects.join('\\n'));\n }\n\n // 4. Lower class field initializers to constructor assignments when\n // useDefineForClassFields is false (standard Angular tsconfig).\n // Uses the original OXC AST positions which are still valid for MagicString\n // since MagicString tracks edits relative to the original source.\n // Ivy static definitions (ɵcmp, ɵfac) are not in the original AST so they\n // are unaffected, and shouldLowerField skips static fields regardless.\n if (!useDefineForClassFields) {\n lowerClassFields(ms, sourceCode, oxcProgram);\n }\n\n // 5. Elide imports that are only used in type positions (type annotations,\n // implements, generics, etc.). Without this pass, single-file transpilers\n // like OXC / esbuild cannot tell that `import { SomeType }` is type-only\n // and will leave the import in the output, causing runtime errors.\n // Detection runs once on the final output; helpers are appended for\n // analysis only, since their position does not affect references.\n const helperCode = helpers.join('\\n');\n const willElide = detectTypeOnlyImportNames(\n ms.toString() + '\\n' + helperCode,\n );\n if (helpers.length > 0) {\n // Insert helpers after the last import / top-level non-class statement,\n // well before any class that references them. Skip imports that will be\n // fully removed by type elision (step 5): inserting inside a\n // soon-to-be-removed range would discard the helpers with the import.\n let insertPos = 0;\n for (const stmt of oxcProgram.body as any[]) {\n const { decl } = toTopLevelStatement(stmt);\n if (stmt.type === 'ImportDeclaration') {\n // Skip imports that will be entirely removed by type elision\n if (willElide.size > 0 && stmt.specifiers.length > 0) {\n const allElided = stmt.specifiers.every(\n (spec: any) =>\n spec.type === 'ImportNamespaceSpecifier' ||\n spec.importKind === 'type' ||\n willElide.has(spec.local.name),\n );\n if (allElided) continue;\n }\n insertPos = stmt.end;\n } else if (\n decl.type === 'VariableDeclaration' &&\n !sourceCode.slice(stmt.start, stmt.end).includes('class')\n ) {\n insertPos = stmt.end;\n } else if (\n stmt.type !== 'TSExportAssignment' &&\n !(\n stmt.type === 'ExportDefaultDeclaration' &&\n decl.type !== 'ClassDeclaration' &&\n decl.type !== 'FunctionDeclaration'\n )\n ) {\n // Stop at the first class or non-import/non-variable statement\n break;\n }\n }\n // Helpers must survive downstream `ms.overwrite()` / `ms.remove()` of\n // imports performed by the type-only specifier elision pass (step 5).\n //\n // Case `insertPos > 0`: a surviving import ends at `insertPos`. Use\n // `appendRight(insertPos, …)` so helpers bind to the `\\n` after the\n // import's `;` — outside any overwrite range `[node.start, node.end)`\n // of a preceding import. `appendLeft(insertPos, …)` would bind to the\n // `;` itself, which IS inside the overwrite range and would be wiped.\n //\n // Case `insertPos === 0`: no import survives — every import is going\n // to be elided, and `elideTypeOnlyImportsMagicString` will\n // `ms.remove(0, declEnd)` the first one. `appendRight(0, …)` anchors\n // to the character at position 0 (the first import's first char),\n // which is inside `[0, declEnd)` and gets wiped. Use `appendLeft(0, …)`\n // instead — it anchors to the LEFT of position 0, outside any range\n // starting at 0, so the helpers survive. Ordering is still correct\n // because the i0 import prepended in step 1 lives in MagicString's\n // `intro` (from `ms.prepend`), which always emits before any\n // `appendLeft` content at position 0.\n if (insertPos === 0) {\n ms.appendLeft(0, helperCode + '\\n');\n } else {\n ms.appendRight(insertPos, '\\n' + helperCode + '\\n');\n }\n }\n elideTypeOnlyImportsMagicString(ms, oxcProgram, willElide);\n\n const map = ms.generateMap({\n source: fileName,\n file: fileName + '.js',\n includeContent: true,\n hires: 'boundary',\n });\n\n if (debugCompile.enabled) {\n debugCompile(\n 'compile %s done (%dms, %d classes, %d resource deps)',\n fileName,\n Math.round(performance.now() - startTimeMs),\n classResults.length,\n resourceDependencies.length,\n );\n }\n return {\n code: ms.toString(),\n map,\n resourceDependencies,\n };\n}\n\n/** The local class name an `imports` entry declares, when it is a plain identifier. */\nfunction declarationName(declaration: CompileDeclaration): string | null {\n const node = (declaration.type as { node?: unknown }).node as\n | string\n | { type?: string; name?: string }\n | undefined;\n if (typeof node === 'string') {\n return node;\n }\n if (node?.type === 'Identifier' && typeof node.name === 'string') {\n return node.name;\n }\n return declaration.className ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyIA,SAAS,oBAAoB,MAA8B;CACzD,MAAM,YACH,KAAK,SAAS,4BACb,KAAK,SAAS,+BAChB,KAAK;CACP,MAAM,OAAO,WAAW,KAAK,cAAc;CAC3C,OAAO;EACL;EACA,UAAU,CAAC,CAAC;EACZ,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,aAAa,EAAE,EAAE,SAAS,KAAK,KAAK;EACrE,KAAK,KAAK;CACZ;AACF;;AAGA,SAAS,kBAAkB,KAAU,YAAwC;CAC3E,MAAM,SAAS,IAAI;CACnB,IAAI,QAAQ,SAAS,kBAAkB,OAAO,KAAA;CAC9C,OAAO,WAAW,MAAM,OAAO,OAAO,OAAO,OAAO,OAAO,GAAG;AAChE;;;;;;;;;;;;AAaA,SAAS,gBACP,OACqB;CACrB,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,SAAS,IAAI,EAAE,iBAAiB,KAAK,IAAI;CAExD,OAAO;AACT;AAEA,IAAM,mCAAmB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;AAQD,SAAS,mBAAmB,MAAwB;CAClD,MAAM,sBAAM,IAA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D,OAAO,KAAK;CAEd,OAAO,YAAY,aAAa;AAClC"}
@@ -138,7 +138,7 @@ function buildDeferDependencyMap(parsedTemplate, program, registry, localSelecto
138
138
  const mVar = ast.variable("m");
139
139
  const innerFn = ast.arrowFn([new ast.FnParam("m", ast.DYNAMIC_TYPE)], new o.ReadPropExpr(mVar, symbolName));
140
140
  const importExpr = new o.InvokeFunctionExpr(new o.ReadPropExpr(new o.DynamicImportExpr(new o.LiteralExpr(info.path)), "then"), [innerFn]);
141
- blockDeps.push(new o.ArrowFunctionExpr([], importExpr));
141
+ blockDeps.push(importExpr);
142
142
  }
143
143
  if (blockDeps.length > 0) blocks.set(block, new o.ArrowFunctionExpr([], new o.LiteralArrayExpr(blockDeps)));
144
144
  else blocks.set(block, null);
@@ -1 +1 @@
1
- {"version":3,"file":"defer.js","names":[],"sources":["../../../../src/lib/compiler/defer.ts"],"sourcesContent":["import * as o from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\n\n/** Recursively collect all DeferredBlock nodes from a template AST. */\nexport function collectDeferBlocks(nodes: any[]): any[] {\n const result: any[] = [];\n function walk(node: any) {\n if (!node) return;\n if (node.constructor?.name === 'DeferredBlock') {\n result.push(node);\n }\n // Walk all possible child structures across block types:\n // Element/Template: children\n // IfBlock: branches (each has children)\n // ForLoopBlock: children, empty (has children)\n // SwitchBlock: groups (Angular v21+, each is a SwitchBlockCaseGroup with\n // children) or cases (Angular v18-v20, each has children)\n // DeferredBlock: children, placeholder/loading/error (each has children)\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/**\n * Collect element tag names from template AST nodes recursively.\n *\n * When `excludeDeferBlocks` is true, the deferred body of any DeferredBlock is\n * skipped — its children are treated as deferred, not eager. The fallback\n * subtrees (`@placeholder`, `@loading`, `@error`) are still walked: Angular\n * treats them as *eager* dependencies because the placeholder must render in\n * the main bundle before the defer trigger fires. A component shared between\n * the defer body and a fallback block must stay in static imports, otherwise\n * the fallback render breaks.\n */\nexport function collectElementNames(\n nodes: any[],\n excludeDeferBlocks = false,\n): Set<string> {\n const result = new Set<string>();\n function walk(node: any) {\n if (!node) return;\n if (excludeDeferBlocks && node.constructor?.name === 'DeferredBlock') {\n // Skip the deferred body but keep walking the fallback subtrees so\n // components referenced in `@placeholder` / `@loading` / `@error`\n // stay in the eager set.\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n return;\n }\n if (node.constructor?.name === 'Element') result.add(node.name);\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/** Information about how a class is imported. */\nexport interface ImportInfo {\n /** Module path from the import statement. */\n path: string;\n /** Whether the class was imported as a default import (`import X from`). */\n isDefault: boolean;\n /**\n * Original exported name on the source module's namespace. For\n * `import { HeavyWidget as Widget } from './heavy'`, the local\n * binding is `Widget` but the namespace exposes `HeavyWidget` —\n * `await import('./heavy')` returns `{ HeavyWidget }`, not\n * `{ Widget }`. Defer dependency emit must use the exported name,\n * not the local alias, or the lookup resolves to `undefined` at\n * runtime.\n */\n exportName: string;\n}\n\n/**\n * Build import info map: localName → { path, isDefault, exportName }\n * from source file imports. Tracks default vs named imports plus the\n * original exported name so the defer dependency generator can emit\n * `import('./p').then(m => m.default)` for default imports and\n * `import('./p').then(m => m.OriginalExportName)` for aliased named\n * imports.\n */\nexport function buildImportMap(program: any): Map<string, ImportInfo> {\n const result = new Map<string, ImportInfo>();\n for (const stmt of program.body) {\n if (stmt.type !== 'ImportDeclaration') continue;\n const path: string = stmt.source.value;\n for (const spec of stmt.specifiers) {\n if (spec.type === 'ImportDefaultSpecifier') {\n result.set(spec.local.name, {\n path,\n isDefault: true,\n exportName: 'default',\n });\n } else if (spec.type === 'ImportSpecifier') {\n // `import { Foo as Bar }` → imported is `Foo`, local is `Bar`.\n const exportName: string = spec.imported.name ?? spec.imported.value;\n const info: ImportInfo = { path, isDefault: false, exportName };\n // Key the map by BOTH the local binding and the original export\n // name. The defer-dep lookup uses the className from the\n // registry — which is always the original class name from the\n // source file (`HeavyWidget`), not the consumer's local alias\n // (`Widget`). Without the export-name key, aliased imports\n // would silently produce no defer dependency at all.\n result.set(spec.local.name, info);\n if (exportName !== spec.local.name) {\n result.set(exportName, info);\n }\n }\n }\n }\n return result;\n}\n\n/**\n * Build defer block dependency map with dynamic import() expressions.\n *\n * For each defer block, identifies which imported components are only used\n * inside defer blocks (not in the eager template), and generates dynamic\n * import expressions for lazy loading.\n *\n * Returns:\n * - blocks: Map<DeferredBlock, Expression | null> for compileComponentFromMetadata\n * - deferredImports: Set<string> of class names that should be removed from static imports\n */\nexport function buildDeferDependencyMap(\n parsedTemplate: any,\n program: any,\n registry: ComponentRegistry | undefined,\n localSelectors: Map<string, string>,\n): { blocks: Map<any, any>; deferredImports: Set<string> } {\n const deferBlocks = collectDeferBlocks(parsedTemplate.nodes);\n if (deferBlocks.length === 0) {\n return { blocks: new Map(), deferredImports: new Set() };\n }\n\n const deferElements = new Set<string>();\n for (const block of deferBlocks) {\n const elements = collectElementNames(block.children || []);\n for (const el of elements) deferElements.add(el);\n }\n // Eager elements = elements reachable without crossing into a DeferredBlock.\n // Pass `excludeDeferBlocks` so a defer block nested inside @switch / @if /\n // @for is not unfolded into the eager set. Without this, a component used\n // only inside such a nested defer would be misclassified as eager and lose\n // its lazy-load dependency function.\n const eagerElements = collectElementNames(parsedTemplate.nodes, true);\n\n // Build selector → className map from registry + local selectors\n const selectorToClass = new Map<string, string>();\n if (registry) {\n for (const [className, entry] of registry) {\n if (entry.selector) selectorToClass.set(entry.selector, className);\n }\n }\n for (const [className, selector] of localSelectors) {\n selectorToClass.set(selector, className);\n }\n\n // Build className → importPath map\n const importMap = buildImportMap(program);\n\n // Find defer-only component class names\n const deferredImports = new Set<string>();\n const deferOnlyElements = new Set<string>();\n for (const el of deferElements) {\n if (!eagerElements.has(el)) deferOnlyElements.add(el);\n }\n\n for (const el of deferOnlyElements) {\n const className = selectorToClass.get(el);\n if (className && importMap.has(className)) {\n deferredImports.add(className);\n }\n }\n\n // Build the blocks map with dependency functions\n const blocks = new Map<any, any>();\n for (const block of deferBlocks) {\n const blockElements = collectElementNames(block.children || []);\n const blockDeps: any[] = [];\n // Within a single block, dedupe by `${path}#${symbolName}` so two\n // refs to the same component don't generate two import expressions.\n const seenInBlock = new Set<string>();\n\n for (const el of blockElements) {\n const className = selectorToClass.get(el);\n if (!className || !deferredImports.has(className)) continue;\n const info = importMap.get(className)!;\n // Use the original exported name (tracked by buildImportMap) so\n // aliased imports like `import { HeavyWidget as Widget }` resolve\n // to `m.HeavyWidget` instead of `m.Widget` (which would be\n // `undefined` on the module namespace).\n const symbolName = info.exportName;\n const key = `${info.path}#${symbolName}`;\n if (seenInBlock.has(key)) continue;\n seenInBlock.add(key);\n // import('./path').then(m => m.ClassName) — or `m.default` for\n // default imports. Without the `.then(...)` resolver Angular's\n // runtime gets a module namespace and can't find the class.\n // `FnParam` and the `variable()` helper aren't on the top-level\n // namespace; they live in the `outputAst` sub-namespace.\n const ast: any = (o as any).outputAst;\n const mVar = ast.variable('m');\n const innerFn = ast.arrowFn(\n [new ast.FnParam('m', ast.DYNAMIC_TYPE)],\n new o.ReadPropExpr(mVar, symbolName),\n );\n const importExpr = new o.InvokeFunctionExpr(\n new o.ReadPropExpr(\n new o.DynamicImportExpr(new o.LiteralExpr(info.path)),\n 'then',\n ),\n [innerFn],\n );\n blockDeps.push(new o.ArrowFunctionExpr([], importExpr));\n }\n\n if (blockDeps.length > 0) {\n // () => [import('./a').then(m => m.A), import('./b').then(m => m.default)]\n blocks.set(\n block,\n new o.ArrowFunctionExpr([], new o.LiteralArrayExpr(blockDeps)),\n );\n } else {\n blocks.set(block, null);\n }\n }\n\n return { blocks, deferredImports };\n}\n"],"mappings":";;;AAIA,SAAgB,mBAAmB,OAAqB;CACtD,MAAM,SAAgB,CAAC;CACvB,SAAS,KAAK,MAAW;EACvB,IAAI,CAAC,MAAM;EACX,IAAI,KAAK,aAAa,SAAS,iBAC7B,OAAO,KAAK,IAAI;EASlB,IAAI,MAAM,QAAQ,KAAK,QAAQ,GAAG,KAAK,SAAS,QAAQ,IAAI;EAC5D,IAAI,MAAM,QAAQ,KAAK,QAAQ,GAAG,KAAK,SAAS,QAAQ,IAAI;EAC5D,IAAI,MAAM,QAAQ,KAAK,WAAW,GAAG,KAAK,YAAY,QAAQ,IAAI;EAClE,IAAI,MAAM,QAAQ,KAAK,MAAM,GAAG,KAAK,OAAO,QAAQ,IAAI;EACxD,IAAI,MAAM,QAAQ,KAAK,KAAK,GAAG,KAAK,MAAM,QAAQ,IAAI;EACtD,IAAI,KAAK,OAAO,UAAU,KAAK,MAAM,SAAS,QAAQ,IAAI;EAC1D,IAAI,KAAK,aAAa,UAAU,KAAK,YAAY,SAAS,QAAQ,IAAI;EACtE,IAAI,KAAK,SAAS,UAAU,KAAK,QAAQ,SAAS,QAAQ,IAAI;EAC9D,IAAI,KAAK,OAAO,UAAU,KAAK,MAAM,SAAS,QAAQ,IAAI;CAC5D;C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ACnC"}
1
+ {"version":3,"file":"defer.js","names":[],"sources":["../../../../src/lib/compiler/defer.ts"],"sourcesContent":["import * as o from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\n\n/** Recursively collect all DeferredBlock nodes from a template AST. */\nexport function collectDeferBlocks(nodes: any[]): any[] {\n const result: any[] = [];\n function walk(node: any) {\n if (!node) return;\n if (node.constructor?.name === 'DeferredBlock') {\n result.push(node);\n }\n // Walk all possible child structures across block types:\n // Element/Template: children\n // IfBlock: branches (each has children)\n // ForLoopBlock: children, empty (has children)\n // SwitchBlock: groups (Angular v21+, each is a SwitchBlockCaseGroup with\n // children) or cases (Angular v18-v20, each has children)\n // DeferredBlock: children, placeholder/loading/error (each has children)\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/**\n * Collect element tag names from template AST nodes recursively.\n *\n * When `excludeDeferBlocks` is true, the deferred body of any DeferredBlock is\n * skipped — its children are treated as deferred, not eager. The fallback\n * subtrees (`@placeholder`, `@loading`, `@error`) are still walked: Angular\n * treats them as *eager* dependencies because the placeholder must render in\n * the main bundle before the defer trigger fires. A component shared between\n * the defer body and a fallback block must stay in static imports, otherwise\n * the fallback render breaks.\n */\nexport function collectElementNames(\n nodes: any[],\n excludeDeferBlocks = false,\n): Set<string> {\n const result = new Set<string>();\n function walk(node: any) {\n if (!node) return;\n if (excludeDeferBlocks && node.constructor?.name === 'DeferredBlock') {\n // Skip the deferred body but keep walking the fallback subtrees so\n // components referenced in `@placeholder` / `@loading` / `@error`\n // stay in the eager set.\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n return;\n }\n if (node.constructor?.name === 'Element') result.add(node.name);\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/** Information about how a class is imported. */\nexport interface ImportInfo {\n /** Module path from the import statement. */\n path: string;\n /** Whether the class was imported as a default import (`import X from`). */\n isDefault: boolean;\n /**\n * Original exported name on the source module's namespace. For\n * `import { HeavyWidget as Widget } from './heavy'`, the local\n * binding is `Widget` but the namespace exposes `HeavyWidget` —\n * `await import('./heavy')` returns `{ HeavyWidget }`, not\n * `{ Widget }`. Defer dependency emit must use the exported name,\n * not the local alias, or the lookup resolves to `undefined` at\n * runtime.\n */\n exportName: string;\n}\n\n/**\n * Build import info map: localName → { path, isDefault, exportName }\n * from source file imports. Tracks default vs named imports plus the\n * original exported name so the defer dependency generator can emit\n * `import('./p').then(m => m.default)` for default imports and\n * `import('./p').then(m => m.OriginalExportName)` for aliased named\n * imports.\n */\nexport function buildImportMap(program: any): Map<string, ImportInfo> {\n const result = new Map<string, ImportInfo>();\n for (const stmt of program.body) {\n if (stmt.type !== 'ImportDeclaration') continue;\n const path: string = stmt.source.value;\n for (const spec of stmt.specifiers) {\n if (spec.type === 'ImportDefaultSpecifier') {\n result.set(spec.local.name, {\n path,\n isDefault: true,\n exportName: 'default',\n });\n } else if (spec.type === 'ImportSpecifier') {\n // `import { Foo as Bar }` → imported is `Foo`, local is `Bar`.\n const exportName: string = spec.imported.name ?? spec.imported.value;\n const info: ImportInfo = { path, isDefault: false, exportName };\n // Key the map by BOTH the local binding and the original export\n // name. The defer-dep lookup uses the className from the\n // registry — which is always the original class name from the\n // source file (`HeavyWidget`), not the consumer's local alias\n // (`Widget`). Without the export-name key, aliased imports\n // would silently produce no defer dependency at all.\n result.set(spec.local.name, info);\n if (exportName !== spec.local.name) {\n result.set(exportName, info);\n }\n }\n }\n }\n return result;\n}\n\n/**\n * Build defer block dependency map with dynamic import() expressions.\n *\n * For each defer block, identifies which imported components are only used\n * inside defer blocks (not in the eager template), and generates dynamic\n * import expressions for lazy loading.\n *\n * Returns:\n * - blocks: Map<DeferredBlock, Expression | null> for compileComponentFromMetadata\n * - deferredImports: Set<string> of class names that should be removed from static imports\n */\nexport function buildDeferDependencyMap(\n parsedTemplate: any,\n program: any,\n registry: ComponentRegistry | undefined,\n localSelectors: Map<string, string>,\n): { blocks: Map<any, any>; deferredImports: Set<string> } {\n const deferBlocks = collectDeferBlocks(parsedTemplate.nodes);\n if (deferBlocks.length === 0) {\n return { blocks: new Map(), deferredImports: new Set() };\n }\n\n const deferElements = new Set<string>();\n for (const block of deferBlocks) {\n const elements = collectElementNames(block.children || []);\n for (const el of elements) deferElements.add(el);\n }\n // Eager elements = elements reachable without crossing into a DeferredBlock.\n // Pass `excludeDeferBlocks` so a defer block nested inside @switch / @if /\n // @for is not unfolded into the eager set. Without this, a component used\n // only inside such a nested defer would be misclassified as eager and lose\n // its lazy-load dependency function.\n const eagerElements = collectElementNames(parsedTemplate.nodes, true);\n\n // Build selector → className map from registry + local selectors\n const selectorToClass = new Map<string, string>();\n if (registry) {\n for (const [className, entry] of registry) {\n if (entry.selector) selectorToClass.set(entry.selector, className);\n }\n }\n for (const [className, selector] of localSelectors) {\n selectorToClass.set(selector, className);\n }\n\n // Build className → importPath map\n const importMap = buildImportMap(program);\n\n // Find defer-only component class names\n const deferredImports = new Set<string>();\n const deferOnlyElements = new Set<string>();\n for (const el of deferElements) {\n if (!eagerElements.has(el)) deferOnlyElements.add(el);\n }\n\n for (const el of deferOnlyElements) {\n const className = selectorToClass.get(el);\n if (className && importMap.has(className)) {\n deferredImports.add(className);\n }\n }\n\n // Build the blocks map with dependency functions\n const blocks = new Map<any, any>();\n for (const block of deferBlocks) {\n const blockElements = collectElementNames(block.children || []);\n const blockDeps: any[] = [];\n // Within a single block, dedupe by `${path}#${symbolName}` so two\n // refs to the same component don't generate two import expressions.\n const seenInBlock = new Set<string>();\n\n for (const el of blockElements) {\n const className = selectorToClass.get(el);\n if (!className || !deferredImports.has(className)) continue;\n const info = importMap.get(className)!;\n // Use the original exported name (tracked by buildImportMap) so\n // aliased imports like `import { HeavyWidget as Widget }` resolve\n // to `m.HeavyWidget` instead of `m.Widget` (which would be\n // `undefined` on the module namespace).\n const symbolName = info.exportName;\n const key = `${info.path}#${symbolName}`;\n if (seenInBlock.has(key)) continue;\n seenInBlock.add(key);\n // import('./path').then(m => m.ClassName) — or `m.default` for\n // default imports. Without the `.then(...)` resolver Angular's\n // runtime gets a module namespace and can't find the class.\n // `FnParam` and the `variable()` helper aren't on the top-level\n // namespace; they live in the `outputAst` sub-namespace.\n const ast: any = (o as any).outputAst;\n const mVar = ast.variable('m');\n const innerFn = ast.arrowFn(\n [new ast.FnParam('m', ast.DYNAMIC_TYPE)],\n new o.ReadPropExpr(mVar, symbolName),\n );\n const importExpr = new o.InvokeFunctionExpr(\n new o.ReadPropExpr(\n new o.DynamicImportExpr(new o.LiteralExpr(info.path)),\n 'then',\n ),\n [innerFn],\n );\n // Angular's dependency resolver returns the import promises themselves.\n // A function in the array would be taken for an already-loaded class.\n blockDeps.push(importExpr);\n }\n\n if (blockDeps.length > 0) {\n // () => [import('./a').then(m => m.A), import('./b').then(m => m.default)]\n blocks.set(\n block,\n new o.ArrowFunctionExpr([], new o.LiteralArrayExpr(blockDeps)),\n );\n } else {\n blocks.set(block, null);\n }\n }\n\n return { blocks, defer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a,CAAC,gBAAgB,IAAI,SAAS,GAAG;GACnD,MAAM,OAAO,UAAU,IAAI,SAAS;GAKpC,MAAM,aAAa,KAAK;GACxB,MAAM,MAAM,GAAG,KAAK,KAAK,GAAG;GAC5B,IAAI,YAAY,IAAI,GAAG,GAAG;GAC1B,YAAY,IAAI,GAAG;GAMnB,MAAM,MAAY,EAAU;GAC5B,MAAM,OAAO,IAAI,SAAS,GAAG;GAC7B,MAAM,UAAU,IAAI,QAClB,CAAC,IAAI,IAAI,QAAQ,KAAK,IAAI,YAAY,CAAC,GACvC,IAAI,EAAE,aAAa,MAAM,UAAU,CACrC;GACA,MAAM,aAAa,IAAI,EAAE,mBACvB,IAAI,EAAE,aACJ,IAAI,EAAE,kBAAkB,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC,GACpD,MACF,GACA,CAAC,OAAO,CACV;GAGA,UAAU,KAAK,UAAU;EAC3B;EAEA,IAAI,UAAU,SAAS,GAErB,OAAO,IACL,OACA,IAAI,EAAE,kBAAkB,CAAC,GAAG,IAAI,EAAE,iBAAiB,SAAS,CAAC,CAC/D;OAEA,OAAO,IAAI,OAAO,IAAI;CAE1B;CAEA,OAAO;EAAE;EAAQ;CAAgB;AACnC"}
@@ -15,7 +15,7 @@ import { createHotUpdateBatcher } from "./hot-update-batch.js";
15
15
  import { StyleUrlsResolver, TemplateUrlsResolver } from "./component-resolvers.js";
16
16
  import { augmentHostWithCaching, augmentHostWithModuleResolution, augmentHostWithResources, augmentProgramWithVersioning, mergeTransformers } from "./host.js";
17
17
  import { union } from "es-toolkit";
18
- import { mkdirSync, writeFileSync } from "node:fs";
18
+ import { mkdirSync, realpathSync, writeFileSync } from "node:fs";
19
19
  import { createRequire } from "node:module";
20
20
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
21
21
  import { normalizePath, preprocessCSS } from "vite";
@@ -67,11 +67,25 @@ function ngtscCompilePlugin(ctxOrOptions) {
67
67
  const templateUrlsResolver = new TemplateUrlsResolver();
68
68
  let outputFile;
69
69
  const outputFiles = /* @__PURE__ */ new Map();
70
+ const realPaths = /* @__PURE__ */ new Map();
71
+ const toRealPath = (file) => {
72
+ const normalizedFile = normalizePath(file);
73
+ const cachedPath = realPaths.get(normalizedFile);
74
+ if (cachedPath !== void 0) return cachedPath;
75
+ let realPath;
76
+ try {
77
+ realPath = normalizePath(realpathSync(normalizedFile));
78
+ } catch {
79
+ return normalizedFile;
80
+ }
81
+ realPaths.set(normalizedFile, realPath);
82
+ return realPath;
83
+ };
70
84
  const normalizeEmitterLookupId = (file) => {
71
85
  const normalizedFile = normalizePath(file);
72
- if (!normalizedFile.startsWith("/@fs/")) return normalizedFile;
86
+ if (!normalizedFile.startsWith("/@fs/")) return toRealPath(normalizedFile);
73
87
  const fsPath = normalizedFile.slice(4).replace(/^\/([A-Za-z]:\/)/, "$1");
74
- return normalizePath(fsPath);
88
+ return toRealPath(fsPath);
75
89
  };
76
90
  const describeEmitMarkers = (content) => ({
77
91
  contentLength: content.length,
@@ -212,7 +226,7 @@ function ngtscCompilePlugin(ctxOrOptions) {
212
226
  }
213
227
  if (isTest) tsCompilerOptions["supportTestBed"] = true;
214
228
  const replacements = ctx.options.fileReplacements.map((rp) => join(ctx.options.workspaceRoot, rp.ssr || rp.with));
215
- rootNames = union(union(rootNames, ctx.tsconfigResolver.ensureIncludeCache()), replacements);
229
+ rootNames = [...new Set(union(union(rootNames, ctx.tsconfigResolver.ensureIncludeCache()), replacements).map(toRealPath))];
216
230
  const hostKey = JSON.stringify(tsCompilerOptions);
217
231
  let host;
218
232
  if (cachedHost && cachedHostKey === hostKey) host = cachedHost;
@@ -307,7 +321,7 @@ function ngtscCompilePlugin(ctxOrOptions) {
307
321
  });
308
322
  };
309
323
  const writeOutputFile = (id) => {
310
- const sourceFile = builder.getSourceFile(id);
324
+ const sourceFile = builder.getSourceFile(toRealPath(id));
311
325
  if (!sourceFile) return;
312
326
  let content = "";
313
327
  let map;
@@ -319,7 +333,8 @@ function ngtscCompilePlugin(ctxOrOptions) {
319
333
  mapFilename = filename;
320
334
  }
321
335
  if (!ctx.watchMode && !isTest && /\.d\.ts/.test(filename) && !filename.includes(".ngtypecheck.")) {
322
- const declarationPath = resolve(config.root, config.build.outDir, relative(config.root, filename)).replace("/src/", "/");
336
+ const root = toRealPath(config.root);
337
+ const declarationPath = resolve(root, config.build.outDir, relative(root, filename)).replace("/src/", "/");
323
338
  const declarationFileDir = declarationPath.replace(basename(filename), "").replace("/src/", "/");
324
339
  declarationFiles.push({
325
340
  declarationFileDir,
@@ -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 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 ...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,MA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AuB,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, realpathSync, 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 // Vite resolves module ids through symlinks, while the TypeScript program\n // names files by the tsconfig path as given. Both sides go through\n // `toRealPath` so `/var/...` and `/private/var/...` (macOS) or a symlinked\n // workspace name the same file.\n const realPaths = new Map<string, string>();\n const toRealPath = (file: string): string => {\n const normalizedFile = normalizePath(file);\n const cachedPath = realPaths.get(normalizedFile);\n if (cachedPath !== undefined) {\n return cachedPath;\n }\n\n let realPath: string;\n try {\n realPath = normalizePath(realpathSync(normalizedFile));\n } catch {\n // Not on disk (yet): leave it as is and don't cache it.\n return normalizedFile;\n }\n realPaths.set(normalizedFile, realPath);\n return realPath;\n };\n\n const normalizeEmitterLookupId = (file: string): string => {\n const normalizedFile = normalizePath(file);\n\n if (!normalizedFile.startsWith('/@fs/')) {\n return toRealPath(normalizedFile);\n }\n\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n\n return toRealPath(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 = [\n ...new Set(\n union(\n union(rootNames, ctx.tsconfigResolver.ensureIncludeCache()),\n replacements,\n ).map(toRealPath),\n ),\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(toRealPath(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 root = toRealPath(config.root);\n const declarationPath = resolve(\n root,\n config.build.outDir,\n relative(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,MAA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