@analogjs/vite-plugin-angular 3.0.0-beta.62 → 3.0.0-beta.63

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.
@@ -100,7 +100,7 @@ function fastCompilePlugin(optionsOrCtx) {
100
100
  entries = scanFile(code, file, program);
101
101
  scanResults?.set(file, entries);
102
102
  }
103
- for (const entry of entries) if (overwrite || !registry.has(entry.className)) registry.set(entry.className, entry);
103
+ scanner.recordFileEntries(file, entries, overwrite);
104
104
  const dir = dirname(file);
105
105
  for (const rel of collectRelativeReExports(code, file, program)) {
106
106
  const normalizedRel = rel.replace(/\.(?:js|mjs)$/u, "");
@@ -145,13 +145,19 @@ function fastCompilePlugin(optionsOrCtx) {
145
145
  fileContents.set(file, code);
146
146
  const entries = scanFile(code, file);
147
147
  scanResults.set(file, entries);
148
- return entries;
148
+ return {
149
+ file,
150
+ entries
151
+ };
149
152
  } catch (e) {
150
153
  if (debugRegistry.enabled) debugRegistry("initFastCompile: skipping unreadable %s: %s", file, e?.message);
151
- return [];
154
+ return {
155
+ file,
156
+ entries: []
157
+ };
152
158
  }
153
159
  }));
154
- for (const entries of results) for (const entry of entries) registry.set(entry.className, entry);
160
+ for (const { file, entries } of results) scanner.recordFileEntries(file, entries, true);
155
161
  const resolvePathSpecifier = (spec) => {
156
162
  if (!tsPaths) return [];
157
163
  for (const [key, targets] of Object.entries(tsPaths)) {
@@ -210,7 +216,7 @@ function fastCompilePlugin(optionsOrCtx) {
210
216
  entries = scanFile(code, file, program);
211
217
  scanResults.set(file, entries);
212
218
  }
213
- for (const entry of entries) if (!registry.has(entry.className)) registry.set(entry.className, entry);
219
+ scanner.recordFileEntries(file, entries);
214
220
  scanner.ensureDtsRegistryForSource(code, file, program);
215
221
  const dir = dirname(file);
216
222
  const targets = await Promise.all(collectAllImports(code, file, program).map((spec) => {
@@ -303,18 +309,14 @@ function fastCompilePlugin(optionsOrCtx) {
303
309
  if (resolvedInlineStyles.size === 0) resolvedInlineStyles = void 0;
304
310
  }
305
311
  scanner.ensureDtsRegistryForSource(code, id, oxcProgram);
306
- for (const entry of scanFile(code, id, oxcProgram)) registry.set(entry.className, entry);
312
+ scanner.recordFileEntries(id, scanFile(code, id, oxcProgram), true);
307
313
  await scanner.resolveImportSpecifiers(collectAllImports(code, id, oxcProgram), id, resolveImport);
308
314
  if (declaresNonStandaloneComponent(oxcProgram)) {
309
315
  projectScan ??= scanProject();
310
316
  await projectScan;
311
317
  }
312
318
  const activeComponentRegistries = sharedCtx ? sharedCtx.componentRegistries : componentRegistries;
313
- let compileRegistry = registry;
314
- if (activeComponentRegistries.some((external) => external.size > 0)) {
315
- compileRegistry = new Map(registry);
316
- for (const external of activeComponentRegistries) for (const [k, v] of external) compileRegistry.set(k, v);
317
- }
319
+ const compileRegistry = buildCompileRegistry(scanner, oxcProgram, id, activeComponentRegistries);
318
320
  const result = compile(code, id, {
319
321
  registry: compileRegistry,
320
322
  resolvedInlineStyles,
@@ -364,7 +366,10 @@ function fastCompilePlugin(optionsOrCtx) {
364
366
  fastCompile: {
365
367
  registerSourceFormat: (format) => scanner.registerSourceFormat(format),
366
368
  scanImports: (specifiers, importer, resolve) => scanner.scanImports(specifiers, importer, resolve),
367
- resolveSelector: (className) => scanner.lookupSelector(className, sharedCtx ? sharedCtx.componentRegistries : componentRegistries),
369
+ resolveSelector: (className, moduleSpecifier, containingFile) => scanner.lookupSelector(className, sharedCtx ? sharedCtx.componentRegistries : componentRegistries, moduleSpecifier !== void 0 && containingFile !== void 0 ? {
370
+ moduleSpecifier,
371
+ containingFile
372
+ } : void 0),
368
373
  async compile(code, id, { resolve, mapToSource }) {
369
374
  const transformed = await handleFastCompileTransform(code, id, scanner.toResolveImport(resolve));
370
375
  if (!transformed) return;
@@ -487,6 +492,47 @@ function fastCompilePlugin(optionsOrCtx) {
487
492
  }
488
493
  };
489
494
  }
495
+ /**
496
+ * Builds the registry view for compiling `id`, overlaying external registries,
497
+ * this file's value import bindings (including aliases, default imports, and
498
+ * same-named components from distinct modules), and declarations from `id`
499
+ * itself. Reuses `scanner.registry` directly when no overrides apply.
500
+ */
501
+ function buildCompileRegistry(scanner, program, id, externalRegistries) {
502
+ let compileRegistry = scanner.registry;
503
+ const ensureOverlay = () => {
504
+ if (compileRegistry === scanner.registry) compileRegistry = new Map(scanner.registry);
505
+ return compileRegistry;
506
+ };
507
+ if (externalRegistries.some((external) => external.size > 0)) {
508
+ const overlay = ensureOverlay();
509
+ for (const external of externalRegistries) for (const [k, v] of external) overlay.set(k, v);
510
+ }
511
+ for (const stmt of program.body || []) {
512
+ if (stmt.type !== "ImportDeclaration" || stmt.importKind === "type" || !stmt.source?.value) continue;
513
+ const moduleSpecifier = stmt.source.value;
514
+ for (const spec of stmt.specifiers || []) {
515
+ if (spec.importKind === "type") continue;
516
+ let importedName;
517
+ let localName;
518
+ if (spec.type === "ImportDefaultSpecifier") {
519
+ importedName = "default";
520
+ localName = spec.local?.name;
521
+ } else if (spec.type === "ImportSpecifier") {
522
+ importedName = spec.imported?.type === "Identifier" ? spec.imported.name : typeof spec.imported?.value === "string" ? spec.imported.value : void 0;
523
+ localName = spec.local?.name;
524
+ }
525
+ if (!importedName || !localName) continue;
526
+ const entry = scanner.lookupEntry(importedName, externalRegistries, {
527
+ moduleSpecifier,
528
+ containingFile: id
529
+ });
530
+ if (entry && compileRegistry.get(localName) !== entry) ensureOverlay().set(localName, entry);
531
+ }
532
+ }
533
+ for (const localEntry of scanner.entriesOf(id)) if (compileRegistry.get(localEntry.className) !== localEntry) ensureOverlay().set(localEntry.className, localEntry);
534
+ return compileRegistry;
535
+ }
490
536
  export { fastCompilePlugin, getPathsBasePath };
491
537
 
492
538
  //# sourceMappingURL=fast-compile-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fast-compile-plugin.js","names":["fsPromises"],"sources":["../../../src/lib/fast-compile-plugin.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './compiler/utils.js';\nimport * as vite from 'vite';\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n compile,\n scanFile,\n declaresNonStandaloneComponent,\n collectRelativeReExports,\n collectAllImports,\n jitTransform,\n inlineResourceUrls,\n extractInlineStyles,\n generateHmrCode,\n debugRegistry,\n ANGULAR_DECORATOR_CALL_RE,\n type ComponentRegistry,\n} from './compiler/index.js';\nimport { reportStylesheetError } from './utils/stylesheet-warning.js';\n\nimport {\n TS_EXT_REGEX,\n EXCLUDED_TS_EXT_REGEX,\n getTsConfigPath,\n createDepOptimizerConfig,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport { TsconfigResolver } from './utils/tsconfig-resolver.js';\nimport type { FastCompileApi } from './fast-compile-api.js';\nimport { ComponentScanner, type ResolveImport } from './component-scanner.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nexport interface FastCompilePluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n fastCompileMode?: 'full' | 'partial';\n disableTypeChecking?: boolean;\n typeChecker?: TypeCheckerOption;\n include?: string[];\n}\n\nfunction isFastCompilePluginOptions(\n value: unknown,\n): value is FastCompilePluginOptions {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isAngularBuildContext(value) &&\n 'tsconfigGetter' in value &&\n typeof (value as FastCompilePluginOptions).tsconfigGetter === 'function'\n );\n}\n\n/**\n * Directory that `compilerOptions.paths` targets resolve against. Mirrors\n * TypeScript: `baseUrl` when set, otherwise the directory of the config\n * that declares `paths` (`pathsBasePath`, since `baseUrl` is optional\n * from TS 4.1).\n */\nexport function getPathsBasePath(\n options: { baseUrl?: string; pathsBasePath?: string } | undefined,\n fallback: string,\n): string {\n return options?.baseUrl ?? options?.pathsBasePath ?? fallback;\n}\n\nexport function fastCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompilePluginOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n ...optionsOrCtx,\n compilationBackend: 'fast',\n });\n\n const pluginOptions: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n // Component registry shared with source formats through `api.fastCompile`\n const scanner = new ComponentScanner();\n const registry = scanner.registry;\n\n const tsconfigResolver =\n sharedCtx?.tsconfigResolver ??\n new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include ?? [],\n liveReload: pluginOptions.liveReload,\n isTest: pluginOptions.isTest,\n });\n\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // fast-compile plugin state\n const resourceToSource = new Map<string, string>();\n const emittedMaps = new Map<string, string>();\n let useDefineForClassFields = true;\n let tsConfig: ReturnType<typeof compilerCli.readConfiguration>;\n\n // The one-time whole-project scan non-standalone components fall back to.\n let projectScan: Promise<void> | undefined;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code = fileContents?.get(file) ?? (await scanner.readScanSource(file));\n fileContents?.set(file, code);\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: failed to read %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return;\n }\n // Single parse shared by scanFile and collectRelativeReExports. On a\n // parse error each consumer re-parses on its own, preserving their\n // individual failure semantics (scanFile throws past its pre-filter;\n // collectRelativeReExports swallows and returns []).\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults?.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults?.set(file, entries);\n }\n for (const entry of entries) {\n // At buildStart we want stable registry entries (don't overwrite\n // an earlier scan with a barrel re-scan); HMR explicitly asks\n // for overwrite so updated metadata replaces stale entries.\n if (overwrite || !registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n // Collect every relative re-export specifier via OXC AST so\n // recursive scans can't trip over each other (a shared `/g` regex\n // would have its `lastIndex` reset by each recursive call and\n // silently skip half of an outer barrel's re-exports, which\n // previously left directives like `HlmRadioGroup` unregistered).\n const dir = dirname(file);\n for (const rel of collectRelativeReExports(code, file, program)) {\n // NodeNext-style libraries write `export * from './foo.js'`\n // even though the source is `./foo.ts`. Strip the ESM\n // extension before probing or the candidates would be\n // `foo.js.ts` / `foo.js/index.ts`, which never exist.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const reExportCandidates = [\n resolve(dir, normalizedRel + '.ts'),\n resolve(dir, normalizedRel, 'index.ts'),\n ];\n let resolved = false;\n for (const candidate of reExportCandidates) {\n try {\n await fsPromises.access(candidate);\n await scanBarrelExports(\n candidate,\n visited,\n overwrite,\n fileContents,\n scanResults,\n );\n resolved = true;\n break;\n } catch {\n // try next candidate\n }\n }\n if (!resolved && debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: %s re-export %s did not resolve to %o',\n file,\n rel,\n reExportCandidates,\n );\n }\n }\n }\n\n async function initFastCompile(): Promise<void> {\n emittedMaps.clear();\n if (pluginOptions.jit) return; // JIT: no registry scan needed\n\n projectScan = undefined;\n const resolvedTsConfigPath = resolveTsConfigPath();\n const projectRoot = dirname(resolvedTsConfigPath);\n scanner.reset(projectRoot);\n tsConfig = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = tsConfig.options?.useDefineForClassFields ?? true;\n }\n\n /** Scan all source files reachable from the tsconfig into the registry. */\n async function scanProject(): Promise<void> {\n const config = tsConfig;\n const extraIncludes = tsconfigResolver.ensureIncludeCache();\n // Collect candidate files: tsconfig rootNames PLUS explicit/integration\n // include globs PLUS the entry points named in `compilerOptions.paths`.\n // App tsconfigs typically only include the app's own sources, so workspace\n // library entry barrels (e.g. `HlmSelectImports = [HlmSelect,\n // HlmSelectContent, ...] as const`) live outside `rootNames` and would\n // otherwise miss the initial scan. The compiler then can't see that\n // `HlmSelectImports` is a tuple barrel and emits the bare identifier into\n // the parent component's `dependencies()` list, where Angular's runtime\n // silently drops it because arrays don't have a directive def.\n const candidates = new Set<string>([...config.rootNames, ...extraIncludes]);\n const tsPaths = config.options?.paths;\n const projectRoot = scanner.projectRoot;\n const baseUrl = getPathsBasePath(config.options, projectRoot);\n // Cold-start dedup caches shared by the three scan phases below\n // (candidates scan, walkImports, scanBarrelExports). Scoped to this\n // init call only — HMR/watcher re-scans must hit disk fresh.\n const fileContents = new Map<string, string>();\n const scanResults = new Map<string, ReturnType<typeof scanFile>>();\n if (tsPaths) {\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n // Skip wildcard patterns — entry barrels are normally exact\n // file paths like \"libs/helm/select/src/index.ts\".\n if (target.includes('*')) continue;\n candidates.add(resolve(baseUrl, target));\n }\n }\n }\n const results = await Promise.all(\n Array.from(candidates).map(async (file) => {\n try {\n const code = await scanner.readScanSource(file);\n fileContents.set(file, code);\n const entries = scanFile(code, file);\n scanResults.set(file, entries);\n return entries;\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'initFastCompile: skipping unreadable %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return []; // Skip unreadable files\n }\n }),\n );\n\n for (const entries of results) {\n for (const entry of entries) {\n registry.set(entry.className, entry);\n }\n }\n\n // Walk the transitive import graph from the root files so the registry also\n // contains declarations that live in files not directly in tsconfig\n // `files`/`include` (transitively-imported app sources) and in workspace\n // libraries reached through wildcard `paths` (e.g. `@bitwarden/*`). Without\n // this, a non-standalone component's owning module can't classify its\n // declarations and `ɵɵsetComponentScope` is never emitted for it. Only\n // relative imports and `paths`-mapped (project/workspace) bare specifiers are\n // followed; true `node_modules` packages are left to the lazy `.d.ts` scanner.\n // Return *all* candidate base paths a bare specifier maps to. A `paths`\n // entry can list several fallback targets (e.g. a built `dist` path first\n // and the workspace `src` second); the caller probes them in order.\n const resolvePathSpecifier = (spec: string): string[] => {\n if (!tsPaths) return [];\n for (const [key, targets] of Object.entries(tsPaths)) {\n const list = targets as string[];\n if (key.endsWith('/*')) {\n const prefix = key.slice(0, -1);\n if (spec.startsWith(prefix)) {\n // `split('*').join(...)` substitutes the single tsconfig `*`\n // wildcard without `String.replace`'s first-match-only behavior or\n // `$`-pattern interpretation of the replacement.\n return list.map((t) =>\n resolve(baseUrl, t.split('*').join(spec.slice(prefix.length))),\n );\n }\n } else if (key === spec) {\n return list.map((t) => resolve(baseUrl, t));\n }\n }\n return [];\n };\n const probeToSource = async (base: string): Promise<string | null> => {\n const candidates = base.endsWith('.ts')\n ? [base]\n : [base + '.ts', resolve(base, 'index.ts')];\n for (const candidate of candidates) {\n try {\n await fsPromises.access(candidate);\n return candidate;\n } catch {\n // try next candidate\n }\n }\n return null;\n };\n // Memoize fs probes per absolute base path. The cache stores the\n // Promise (not the settled value) so concurrent walks racing on the\n // same base collapse into a single probe.\n const baseResolveCache = new Map<string, Promise<string | null>>();\n const resolveToSource = (base: string): Promise<string | null> => {\n let probe = baseResolveCache.get(base);\n if (!probe) {\n probe = probeToSource(base);\n baseResolveCache.set(base, probe);\n }\n return probe;\n };\n // Probe each `paths` target in order; first one that resolves to source wins.\n const resolveFirstSource = async (\n bases: string[],\n ): Promise<string | null> => {\n for (const base of bases) {\n const resolved = await resolveToSource(base);\n if (resolved) return resolved;\n }\n return null;\n };\n const importWalkVisited = new Set<string>();\n // Paths-mapped resolution doesn't depend on the importer, so bare\n // specifiers can be memoized by their raw text. Relative specifiers\n // must NOT be — the same './foo' resolves differently per directory.\n const bareSpecResolveCache = new Map<string, Promise<string | null>>();\n const walkImports = async (file: string): Promise<void> => {\n if (importWalkVisited.has(file)) return;\n importWalkVisited.add(file);\n let code: string;\n try {\n code = fileContents.get(file) ?? (await scanner.readScanSource(file));\n fileContents.set(file, code);\n } catch {\n return;\n }\n // Single parse shared by scanFile, the package `.d.ts` scan, and\n // collectAllImports. On a parse error each consumer re-parses on\n // its own, preserving their individual failure semantics.\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults.set(file, entries);\n }\n for (const entry of entries) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n // Pre-scan the `.d.ts` of every external package this file imports (and,\n // transitively, packages those packages' NgModules re-export — e.g.\n // BrowserModule → CommonModule → NgIf). Doing this at buildStart means the\n // registry is complete before any component transforms, so non-standalone\n // component scope resolves regardless of file transform order.\n scanner.ensureDtsRegistryForSource(code, file, program);\n const dir = dirname(file);\n const targets = await Promise.all(\n collectAllImports(code, file, program).map((spec) => {\n if (spec.startsWith('.')) {\n return resolveToSource(\n resolve(dir, spec.replace(/\\.(?:js|mjs)$/u, '')),\n );\n }\n let resolved = bareSpecResolveCache.get(spec);\n if (!resolved) {\n resolved = resolveFirstSource(resolvePathSpecifier(spec));\n bareSpecResolveCache.set(spec, resolved);\n }\n return resolved;\n }),\n );\n await Promise.all(\n targets.filter((t): t is string => !!t).map((t) => walkImports(t)),\n );\n };\n const walkRoots = [...new Set([...config.rootNames, ...extraIncludes])];\n await Promise.all(walkRoots.map((file) => walkImports(file)));\n\n // Library barrels typically `export * from './lib/...'` rather than\n // declaring directives directly, so the entry file alone gives us\n // the tuple consts but not the directive classes they reference.\n // Walk the relative `export *` chain so the underlying classes also\n // land in the registry. Use a SHARED visited set across all\n // barrels so recursive walks don't double-scan a file that's\n // re-exported from multiple entry points.\n const buildStartVisited = new Set<string>();\n if (tsPaths) {\n const barrelCandidates: string[] = [];\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n if (target.includes('*')) continue;\n barrelCandidates.push(resolve(baseUrl, target));\n }\n }\n await Promise.all(\n barrelCandidates.map((c) =>\n scanBarrelExports(\n c,\n buildStartVisited,\n false,\n fileContents,\n scanResults,\n ),\n ),\n );\n }\n debugRegistry(\n 'initFastCompile done: %d entries from %d candidate files',\n registry.size,\n candidates.size,\n );\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\n resolveImport: ResolveImport,\n ): Promise<{ code: string; map: any } | undefined> {\n if (!ANGULAR_DECORATOR_CALL_RE.test(code)) {\n // Non-Angular file — strip TS-only syntax ourselves so barrels\n // like `export { Foo, type Bar } from './x'` and other TS-only\n // forms don't leak unstripped to Rolldown. In rolldown-vite the\n // built-in `vite:oxc` strip is registered as a Rust-side native\n // plugin (`viteTransformPlugin` from `rolldown/experimental`); if\n // its hook-filter treats files our `transform.filter.id.include`\n // claimed as already-handled, no JS-side fallback runs and raw\n // TS reaches the parser → `SyntaxError: Unexpected identifier`.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(code, id, {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n })\n : await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n sourcemap: true,\n });\n return { code: stripped.code, map: stripped.map };\n }\n\n // JIT mode\n if (pluginOptions.jit) {\n const result = jitTransform(code, id);\n // Strip TypeScript-only syntax (e.g. `readonly`, parameter property\n // modifiers, type annotations on fields) so the output is valid JS\n // for Rolldown. `angularVitestSourcemapPlugin` normally runs this\n // strip downstream in tests, but it is intentionally skipped on\n // StackBlitz / WebContainer — and the production build pipeline\n // does not register it either — so the JIT path must self-strip\n // to stay safe across environments.\n //\n // Pass the jitTransform map as `inMap` so OXC/esbuild emit a map\n // composed with the original `.ts` source — without this, debug\n // stack traces and breakpoints land on the wrong lines once the\n // strip removes any TS-only token. `jitTransform` returns\n // `map: null` for files with no Angular class (no edits made);\n // passing that to OXC/esbuild as `inMap` throws, so coerce to\n // `undefined` in that case.\n const inMap = result.map ?? undefined;\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n inMap,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n inMap,\n );\n return { code: stripped.code, map: stripped.map };\n }\n\n // Inline external templateUrl/styleUrl(s) into the source before compilation.\n // `stylePaths` carries the source path of each inlined external style so\n // it is preprocessed as its own file (e.g. an external `.scss` styleUrl or\n // a relative `@import`) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { stylePaths } = inlined;\n\n // Track inlined resources for HMR. `compile()` only reports resources it\n // reads through its own fallback (a templateUrl/styleUrl the inliner did\n // NOT already inline), so files inlined here must be recorded here or a\n // later edit to them never invalidates the owning module.\n for (const dep of inlined.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Single OXC parse of the post-inline source, shared by every AST\n // consumer below. `inlineResourceUrls` parsed the PRE-inline string,\n // so its program can never be reused here.\n const { program: oxcProgram } = parseOxc(id, code);\n\n // Pre-resolve component styles through the registered style preprocessor\n // and Vite's CSS pipeline (Sass/Less, PostCSS, Tailwind), like ngtsc does.\n // External styleUrls are processed as their own file; truly inline\n // `styles: [...]` use `inlineStylesExtension`.\n let resolvedInlineStyles: Map<number, string> | undefined;\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n for (let i = 0; i < styleStrings.length; i++) {\n const stylePath =\n stylePaths.get(i) ??\n (scanner.sourceFormatOf(id) ? id + '.ts' : id).replace(\n /\\.ts$/,\n `.inline-${i}.${pluginOptions.inlineStylesExtension || 'css'}`,\n );\n try {\n const preprocessed = preprocessStylesheet(\n styleStrings[i],\n stylePath,\n activeStylePreprocessor,\n {\n filename: stylePath,\n containingFile: id,\n order: i,\n inline: !stylePaths.has(i),\n },\n );\n const processed = await preprocessCSS(\n preprocessed,\n stylePath,\n activeConfig,\n );\n resolvedInlineStyles.set(i, processed.code);\n } catch (e) {\n reportStylesheetError(\n activeConfig?.logger,\n stylePath,\n e,\n activeConfig?.command === 'build',\n );\n }\n }\n if (resolvedInlineStyles.size === 0) resolvedInlineStyles = undefined;\n }\n\n scanner.ensureDtsRegistryForSource(code, id, oxcProgram);\n\n for (const entry of scanFile(code, id, oxcProgram)) {\n registry.set(entry.className, entry);\n }\n // Scan what `id` imports, and recompile it when their metadata changes.\n await scanner.resolveImportSpecifiers(\n collectAllImports(code, id, oxcProgram),\n id,\n resolveImport,\n );\n if (declaresNonStandaloneComponent(oxcProgram)) {\n projectScan ??= scanProject();\n await projectScan;\n }\n\n // Merge registries contributed through `analog.setup()` into this\n // compile's lookup view. Out-of-tree compilers register directive\n // metadata for classes fastCompile can't reach through its\n // tsconfig-driven scan (e.g. `.tsrx` files compiled by `@tsrx/analog`).\n // Without this merge, a TS `@Component({ imports: [X] })` that\n // references such a class hits `_unresolved-${className}` as its\n // selector and the tag never matches at runtime.\n const activeComponentRegistries = sharedCtx\n ? sharedCtx.componentRegistries\n : componentRegistries;\n let compileRegistry: ComponentRegistry = registry;\n if (activeComponentRegistries.some((external) => external.size > 0)) {\n compileRegistry = new Map(registry);\n for (const external of activeComponentRegistries) {\n for (const [k, v] of external) compileRegistry.set(k, v);\n }\n }\n\n const result = compile(code, id, {\n registry: compileRegistry,\n resolvedInlineStyles,\n useDefineForClassFields,\n compilationMode: pluginOptions.fastCompileMode,\n oxcProgram,\n });\n\n // Track resource dependencies for HMR\n for (const dep of result.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Strip TypeScript-only syntax and compose the compiler map with the\n // final generated code so downstream breakpoints map back to the source.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n result.map,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n result.map,\n );\n let outputCode = stripped.code;\n\n // Append HMR code in dev mode\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (activeWatchMode && pluginOptions.liveReload) {\n const fileDeclarations = scanner.entriesOf(id);\n if (fileDeclarations.length > 0) {\n const localDepClassNames = fileDeclarations.map((e) => e.className);\n outputCode += generateHmrCode(fileDeclarations, localDepClassNames);\n }\n }\n\n return { code: outputCode, map: stripped.map };\n }\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const resolution = tsConfigResolutionContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n pluginOptions.tsconfigGetter(),\n resolution.isProd,\n pluginOptions.isTest,\n resolution.isLib,\n pluginOptions.workspaceRoot,\n );\n }\n\n const fastCompile: FastCompileApi = {\n registerSourceFormat: (format) => scanner.registerSourceFormat(format),\n scanImports: (specifiers, importer, resolve) =>\n scanner.scanImports(specifiers, importer, resolve),\n resolveSelector: (className) =>\n scanner.lookupSelector(\n className,\n sharedCtx ? sharedCtx.componentRegistries : componentRegistries,\n ),\n async compile(code, id, { resolve, mapToSource }) {\n const transformed = await handleFastCompileTransform(\n code,\n id,\n scanner.toResolveImport(resolve),\n );\n if (!transformed) {\n return undefined;\n }\n const map =\n transformed.map && mapToSource\n ? mapToSource(transformed.map)\n : (transformed.map ?? null);\n if (map) {\n emittedMaps.set(\n normalizePath(id),\n typeof map === 'string' ? map : JSON.stringify(map),\n );\n }\n return { code: transformed.code, map };\n },\n };\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(normalizePath(id)),\n hasEmitted: (id: string): boolean => emittedMaps.has(normalizePath(id)),\n fastCompile,\n };\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-fast-compile',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n return {\n name: '@analogjs/vite-plugin-angular-fast-compile',\n api: compilerApi,\n enforce: 'pre' as const,\n async config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n }\n\n const preliminaryTsConfigPath = resolveTsConfigPath();\n\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: preliminaryTsConfigPath,\n isProd,\n jit: pluginOptions.jit,\n watchMode,\n isTest: pluginOptions.isTest,\n isAstroIntegration: pluginOptions.isAstroIntegration,\n });\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`.\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n if (sharedCtx) {\n const integrations = await sharedCtx.resolveConfig(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n } else {\n const integrations = await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n }\n },\n async buildStart() {\n await initFastCompile();\n },\n closeBundle() {\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (!activeWatchMode) {\n emittedMaps.clear();\n releaseCssPreprocessorWorkers();\n }\n },\n async handleHotUpdate(ctx) {\n if (\n sharedCtx\n ? sharedCtx.hmr.isIgnoredFile(ctx.file)\n : isIgnoredHmrFile(ctx.file)\n ) {\n return [];\n }\n\n // Resource file changes → invalidate parent .ts module\n if (resourceToSource.has(ctx.file)) {\n const parentSource = resourceToSource.get(ctx.file)!;\n const parentModule = ctx.server.moduleGraph.getModuleById(parentSource);\n if (parentModule) {\n return [parentModule];\n }\n }\n\n if (scanner.isCompiledSource(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n\n // Remove old entries from this file. Cached scans that pulled in\n // this file may now be incomplete.\n const oldEntries = scanner.entriesOf(fileId);\n scanner.invalidate(fileId);\n\n // Rescan the changed file via the barrel-aware scanner so an\n // edited barrel re-export picks up newly-referenced files.\n // Pass overwrite=true so updated metadata replaces stale\n // entries from the previous scan.\n await scanBarrelExports(fileId, new Set(), true);\n\n // Importers compiled the old selector/inputs/outputs into their\n // templates, so recompile them when this file's metadata changed.\n const metadataChanged =\n JSON.stringify(oldEntries) !==\n JSON.stringify(scanner.entriesOf(fileId));\n if (metadataChanged) {\n const importerModules = [\n ...(scanner.importersByFile.get(fileId) ?? []),\n ].flatMap((importer) => [\n ...(ctx.server.moduleGraph.getModulesByFile(importer) ?? []),\n ]);\n return [...ctx.modules, ...importerModules];\n }\n }\n\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: pluginOptions.jit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? resolvedConfig,\n );\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n // `?raw` ids already carry Vite's native raw-loader output\n // (`export default \"<source>\"`). Recompiling them as Angular/TS\n // would strip that default export, so leave them to Vite (#2356).\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n if (activeTransformFilter && !activeTransformFilter(code, id)) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n const resolveImport = scanner.toResolveImport((spec, importer) =>\n this.resolve(spec, importer, { skipSelf: true }),\n );\n\n const transformed = await handleFastCompileTransform(\n code,\n id,\n resolveImport,\n );\n if (transformed?.map) {\n emittedMaps.set(\n normalizePath(id),\n typeof transformed.map === 'string'\n ? transformed.map\n : JSON.stringify(transformed.map),\n );\n }\n return transformed;\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAAS,2BACP,OACmC;CACnC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,sBAAsB,KAAK,KAC5B,oBAAoB,SACpB,OAAQ,MAAmC,mBAAmB;AAElE;;;;;;;AAQA,SAAgB,iBACd,SACA,UACQ;CACR,OAAO,SAAS,WAAW,SAAS,iBAAiB;AACvD;AAEA,SAAgB,kBACd,cAIQ;CACR,MAAM,YAAY,sBAAsB,YAAY,IAChD,eACA,2BAA2B,YAAY,IACrC,KAAA,IACA,0BAA0B;EACxB,GAAG;EACH,oBAAoB;CACtB,CAAC;CAEP,MAAM,gBAA0C,YAC5C,UAAU,UACT;CAGL,MAAM,UAAU,IAAI,iBAAiB;CACrC,MAAM,WAAW,QAAQ;CAEzB,MAAM,mBACJ,WAAW,oBACX,IAAI,iBAAiB;EACnB,eAAe,cAAc;EAC7B,SAAS,cAAc,WAAW,CAAC;EACnC,YAAY,cAAc;EAC1B,QAAQ,cAAc;CACxB,CAAC;CAEH,IAAI;CACJ,IAAI;CACJ,IAAI,sBAAkD,CAAC;CACvD,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAGhB,MAAM,mCAAmB,IAAI,IAAoB;CACjD,MAAM,8BAAc,IAAI,IAAoB;CAC5C,IAAI,0BAA0B;CAC9B,IAAI;CAGJ,IAAI;;;;;;;;;;;;;;;;;CAkBJ,eAAe,kBACb,MACA,0BAAuB,IAAI,IAAI,GAC/B,YAAY,OACZ,cACA,aACe;EACf,IAAI,QAAQ,IAAI,IAAI,GAAG;EACvB,QAAQ,IAAI,IAAI;EAChB,IAAI;EACJ,IAAI;GACF,OAAO,cAAc,IAAI,IAAI,KAAM,MAAM,QAAQ,eAAe,IAAI;GACpE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BACJ,WAAW,mBAAmB;IAChC,IAAI,yBAAyB,CAAC,sBAAsB,MAAM,EAAE,GAC1D;IAGF,IAAI,GAAG,SAAS,MAAM,GACpB,KAAK,GAAG,QAAQ,UAAU,EAAE;IAE9B,MAAM,gBAAgB,QAAQ,iBAAiB,MAAM,aACnD,KAAK,QAAQ,MAAM,UAAU,EAAE,UAAU,KAAK,CAAC,CACjD;IAEA,MAAM,cAAc,MAAM,2BACxB,MACA,IACA,aACF;IACA,IAAI,aAAa,KACf,YAAY,IACV,cAAc,EAAE,GAChB,OAAO,YAAY,QAAQ,WACvB,YAAY,MACZ,KAAK,UAAU,YAAY,GAAG,CACpC;IAEF,OAAO;GACT;EACF;CACF;AACF"}
1
+ {"version":3,"file":"fast-compile-plugin.js","names":["fsPromises"],"sources":["../../../src/lib/fast-compile-plugin.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './compiler/utils.js';\nimport * as vite from 'vite';\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n compile,\n scanFile,\n declaresNonStandaloneComponent,\n collectRelativeReExports,\n collectAllImports,\n jitTransform,\n inlineResourceUrls,\n extractInlineStyles,\n generateHmrCode,\n debugRegistry,\n ANGULAR_DECORATOR_CALL_RE,\n type ComponentRegistry,\n} from './compiler/index.js';\nimport { reportStylesheetError } from './utils/stylesheet-warning.js';\n\nimport {\n TS_EXT_REGEX,\n EXCLUDED_TS_EXT_REGEX,\n getTsConfigPath,\n createDepOptimizerConfig,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport { TsconfigResolver } from './utils/tsconfig-resolver.js';\nimport type { FastCompileApi } from './fast-compile-api.js';\nimport { ComponentScanner, type ResolveImport } from './component-scanner.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nexport interface FastCompilePluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n fastCompileMode?: 'full' | 'partial';\n disableTypeChecking?: boolean;\n typeChecker?: TypeCheckerOption;\n include?: string[];\n}\n\nfunction isFastCompilePluginOptions(\n value: unknown,\n): value is FastCompilePluginOptions {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isAngularBuildContext(value) &&\n 'tsconfigGetter' in value &&\n typeof (value as FastCompilePluginOptions).tsconfigGetter === 'function'\n );\n}\n\n/**\n * Directory that `compilerOptions.paths` targets resolve against. Mirrors\n * TypeScript: `baseUrl` when set, otherwise the directory of the config\n * that declares `paths` (`pathsBasePath`, since `baseUrl` is optional\n * from TS 4.1).\n */\nexport function getPathsBasePath(\n options: { baseUrl?: string; pathsBasePath?: string } | undefined,\n fallback: string,\n): string {\n return options?.baseUrl ?? options?.pathsBasePath ?? fallback;\n}\n\nexport function fastCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompilePluginOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n ...optionsOrCtx,\n compilationBackend: 'fast',\n });\n\n const pluginOptions: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n // Component registry shared with source formats through `api.fastCompile`\n const scanner = new ComponentScanner();\n const registry = scanner.registry;\n\n const tsconfigResolver =\n sharedCtx?.tsconfigResolver ??\n new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include ?? [],\n liveReload: pluginOptions.liveReload,\n isTest: pluginOptions.isTest,\n });\n\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // fast-compile plugin state\n const resourceToSource = new Map<string, string>();\n const emittedMaps = new Map<string, string>();\n let useDefineForClassFields = true;\n let tsConfig: ReturnType<typeof compilerCli.readConfiguration>;\n\n // The one-time whole-project scan non-standalone components fall back to.\n let projectScan: Promise<void> | undefined;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code = fileContents?.get(file) ?? (await scanner.readScanSource(file));\n fileContents?.set(file, code);\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: failed to read %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return;\n }\n // Single parse shared by scanFile and collectRelativeReExports. On a\n // parse error each consumer re-parses on its own, preserving their\n // individual failure semantics (scanFile throws past its pre-filter;\n // collectRelativeReExports swallows and returns []).\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults?.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults?.set(file, entries);\n }\n // At buildStart we want stable registry entries (don't overwrite\n // an earlier scan with a barrel re-scan); HMR explicitly asks\n // for overwrite so updated metadata replaces stale entries.\n scanner.recordFileEntries(file, entries, overwrite);\n // Collect every relative re-export specifier via OXC AST so\n // recursive scans can't trip over each other (a shared `/g` regex\n // would have its `lastIndex` reset by each recursive call and\n // silently skip half of an outer barrel's re-exports, which\n // previously left directives like `HlmRadioGroup` unregistered).\n const dir = dirname(file);\n for (const rel of collectRelativeReExports(code, file, program)) {\n // NodeNext-style libraries write `export * from './foo.js'`\n // even though the source is `./foo.ts`. Strip the ESM\n // extension before probing or the candidates would be\n // `foo.js.ts` / `foo.js/index.ts`, which never exist.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const reExportCandidates = [\n resolve(dir, normalizedRel + '.ts'),\n resolve(dir, normalizedRel, 'index.ts'),\n ];\n let resolved = false;\n for (const candidate of reExportCandidates) {\n try {\n await fsPromises.access(candidate);\n await scanBarrelExports(\n candidate,\n visited,\n overwrite,\n fileContents,\n scanResults,\n );\n resolved = true;\n break;\n } catch {\n // try next candidate\n }\n }\n if (!resolved && debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: %s re-export %s did not resolve to %o',\n file,\n rel,\n reExportCandidates,\n );\n }\n }\n }\n\n async function initFastCompile(): Promise<void> {\n emittedMaps.clear();\n if (pluginOptions.jit) return; // JIT: no registry scan needed\n\n projectScan = undefined;\n const resolvedTsConfigPath = resolveTsConfigPath();\n const projectRoot = dirname(resolvedTsConfigPath);\n scanner.reset(projectRoot);\n tsConfig = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = tsConfig.options?.useDefineForClassFields ?? true;\n }\n\n /** Scan all source files reachable from the tsconfig into the registry. */\n async function scanProject(): Promise<void> {\n const config = tsConfig;\n const extraIncludes = tsconfigResolver.ensureIncludeCache();\n // Collect candidate files: tsconfig rootNames PLUS explicit/integration\n // include globs PLUS the entry points named in `compilerOptions.paths`.\n // App tsconfigs typically only include the app's own sources, so workspace\n // library entry barrels (e.g. `HlmSelectImports = [HlmSelect,\n // HlmSelectContent, ...] as const`) live outside `rootNames` and would\n // otherwise miss the initial scan. The compiler then can't see that\n // `HlmSelectImports` is a tuple barrel and emits the bare identifier into\n // the parent component's `dependencies()` list, where Angular's runtime\n // silently drops it because arrays don't have a directive def.\n const candidates = new Set<string>([...config.rootNames, ...extraIncludes]);\n const tsPaths = config.options?.paths;\n const projectRoot = scanner.projectRoot;\n const baseUrl = getPathsBasePath(config.options, projectRoot);\n // Cold-start dedup caches shared by the three scan phases below\n // (candidates scan, walkImports, scanBarrelExports). Scoped to this\n // init call only — HMR/watcher re-scans must hit disk fresh.\n const fileContents = new Map<string, string>();\n const scanResults = new Map<string, ReturnType<typeof scanFile>>();\n if (tsPaths) {\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n // Skip wildcard patterns — entry barrels are normally exact\n // file paths like \"libs/helm/select/src/index.ts\".\n if (target.includes('*')) continue;\n candidates.add(resolve(baseUrl, target));\n }\n }\n }\n const results = await Promise.all(\n Array.from(candidates).map(async (file) => {\n try {\n const code = await scanner.readScanSource(file);\n fileContents.set(file, code);\n const entries = scanFile(code, file);\n scanResults.set(file, entries);\n return { file, entries };\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'initFastCompile: skipping unreadable %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return { file, entries: [] }; // Skip unreadable files\n }\n }),\n );\n\n for (const { file, entries } of results) {\n scanner.recordFileEntries(file, entries, true);\n }\n\n // Walk the transitive import graph from the root files so the registry also\n // contains declarations that live in files not directly in tsconfig\n // `files`/`include` (transitively-imported app sources) and in workspace\n // libraries reached through wildcard `paths` (e.g. `@bitwarden/*`). Without\n // this, a non-standalone component's owning module can't classify its\n // declarations and `ɵɵsetComponentScope` is never emitted for it. Only\n // relative imports and `paths`-mapped (project/workspace) bare specifiers are\n // followed; true `node_modules` packages are left to the lazy `.d.ts` scanner.\n // Return *all* candidate base paths a bare specifier maps to. A `paths`\n // entry can list several fallback targets (e.g. a built `dist` path first\n // and the workspace `src` second); the caller probes them in order.\n const resolvePathSpecifier = (spec: string): string[] => {\n if (!tsPaths) return [];\n for (const [key, targets] of Object.entries(tsPaths)) {\n const list = targets as string[];\n if (key.endsWith('/*')) {\n const prefix = key.slice(0, -1);\n if (spec.startsWith(prefix)) {\n // `split('*').join(...)` substitutes the single tsconfig `*`\n // wildcard without `String.replace`'s first-match-only behavior or\n // `$`-pattern interpretation of the replacement.\n return list.map((t) =>\n resolve(baseUrl, t.split('*').join(spec.slice(prefix.length))),\n );\n }\n } else if (key === spec) {\n return list.map((t) => resolve(baseUrl, t));\n }\n }\n return [];\n };\n const probeToSource = async (base: string): Promise<string | null> => {\n const candidates = base.endsWith('.ts')\n ? [base]\n : [base + '.ts', resolve(base, 'index.ts')];\n for (const candidate of candidates) {\n try {\n await fsPromises.access(candidate);\n return candidate;\n } catch {\n // try next candidate\n }\n }\n return null;\n };\n // Memoize fs probes per absolute base path. The cache stores the\n // Promise (not the settled value) so concurrent walks racing on the\n // same base collapse into a single probe.\n const baseResolveCache = new Map<string, Promise<string | null>>();\n const resolveToSource = (base: string): Promise<string | null> => {\n let probe = baseResolveCache.get(base);\n if (!probe) {\n probe = probeToSource(base);\n baseResolveCache.set(base, probe);\n }\n return probe;\n };\n // Probe each `paths` target in order; first one that resolves to source wins.\n const resolveFirstSource = async (\n bases: string[],\n ): Promise<string | null> => {\n for (const base of bases) {\n const resolved = await resolveToSource(base);\n if (resolved) return resolved;\n }\n return null;\n };\n const importWalkVisited = new Set<string>();\n // Paths-mapped resolution doesn't depend on the importer, so bare\n // specifiers can be memoized by their raw text. Relative specifiers\n // must NOT be — the same './foo' resolves differently per directory.\n const bareSpecResolveCache = new Map<string, Promise<string | null>>();\n const walkImports = async (file: string): Promise<void> => {\n if (importWalkVisited.has(file)) return;\n importWalkVisited.add(file);\n let code: string;\n try {\n code = fileContents.get(file) ?? (await scanner.readScanSource(file));\n fileContents.set(file, code);\n } catch {\n return;\n }\n // Single parse shared by scanFile, the package `.d.ts` scan, and\n // collectAllImports. On a parse error each consumer re-parses on\n // its own, preserving their individual failure semantics.\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults.set(file, entries);\n }\n scanner.recordFileEntries(file, entries);\n // Pre-scan the `.d.ts` of every external package this file imports (and,\n // transitively, packages those packages' NgModules re-export — e.g.\n // BrowserModule → CommonModule → NgIf). Doing this at buildStart means the\n // registry is complete before any component transforms, so non-standalone\n // component scope resolves regardless of file transform order.\n scanner.ensureDtsRegistryForSource(code, file, program);\n const dir = dirname(file);\n const targets = await Promise.all(\n collectAllImports(code, file, program).map((spec) => {\n if (spec.startsWith('.')) {\n return resolveToSource(\n resolve(dir, spec.replace(/\\.(?:js|mjs)$/u, '')),\n );\n }\n let resolved = bareSpecResolveCache.get(spec);\n if (!resolved) {\n resolved = resolveFirstSource(resolvePathSpecifier(spec));\n bareSpecResolveCache.set(spec, resolved);\n }\n return resolved;\n }),\n );\n await Promise.all(\n targets.filter((t): t is string => !!t).map((t) => walkImports(t)),\n );\n };\n const walkRoots = [...new Set([...config.rootNames, ...extraIncludes])];\n await Promise.all(walkRoots.map((file) => walkImports(file)));\n\n // Library barrels typically `export * from './lib/...'` rather than\n // declaring directives directly, so the entry file alone gives us\n // the tuple consts but not the directive classes they reference.\n // Walk the relative `export *` chain so the underlying classes also\n // land in the registry. Use a SHARED visited set across all\n // barrels so recursive walks don't double-scan a file that's\n // re-exported from multiple entry points.\n const buildStartVisited = new Set<string>();\n if (tsPaths) {\n const barrelCandidates: string[] = [];\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n if (target.includes('*')) continue;\n barrelCandidates.push(resolve(baseUrl, target));\n }\n }\n await Promise.all(\n barrelCandidates.map((c) =>\n scanBarrelExports(\n c,\n buildStartVisited,\n false,\n fileContents,\n scanResults,\n ),\n ),\n );\n }\n debugRegistry(\n 'initFastCompile done: %d entries from %d candidate files',\n registry.size,\n candidates.size,\n );\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\n resolveImport: ResolveImport,\n ): Promise<{ code: string; map: any } | undefined> {\n if (!ANGULAR_DECORATOR_CALL_RE.test(code)) {\n // Non-Angular file — strip TS-only syntax ourselves so barrels\n // like `export { Foo, type Bar } from './x'` and other TS-only\n // forms don't leak unstripped to Rolldown. In rolldown-vite the\n // built-in `vite:oxc` strip is registered as a Rust-side native\n // plugin (`viteTransformPlugin` from `rolldown/experimental`); if\n // its hook-filter treats files our `transform.filter.id.include`\n // claimed as already-handled, no JS-side fallback runs and raw\n // TS reaches the parser → `SyntaxError: Unexpected identifier`.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(code, id, {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n })\n : await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n sourcemap: true,\n });\n return { code: stripped.code, map: stripped.map };\n }\n\n // JIT mode\n if (pluginOptions.jit) {\n const result = jitTransform(code, id);\n // Strip TypeScript-only syntax (e.g. `readonly`, parameter property\n // modifiers, type annotations on fields) so the output is valid JS\n // for Rolldown. `angularVitestSourcemapPlugin` normally runs this\n // strip downstream in tests, but it is intentionally skipped on\n // StackBlitz / WebContainer — and the production build pipeline\n // does not register it either — so the JIT path must self-strip\n // to stay safe across environments.\n //\n // Pass the jitTransform map as `inMap` so OXC/esbuild emit a map\n // composed with the original `.ts` source — without this, debug\n // stack traces and breakpoints land on the wrong lines once the\n // strip removes any TS-only token. `jitTransform` returns\n // `map: null` for files with no Angular class (no edits made);\n // passing that to OXC/esbuild as `inMap` throws, so coerce to\n // `undefined` in that case.\n const inMap = result.map ?? undefined;\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n inMap,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n inMap,\n );\n return { code: stripped.code, map: stripped.map };\n }\n\n // Inline external templateUrl/styleUrl(s) into the source before compilation.\n // `stylePaths` carries the source path of each inlined external style so\n // it is preprocessed as its own file (e.g. an external `.scss` styleUrl or\n // a relative `@import`) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { stylePaths } = inlined;\n\n // Track inlined resources for HMR. `compile()` only reports resources it\n // reads through its own fallback (a templateUrl/styleUrl the inliner did\n // NOT already inline), so files inlined here must be recorded here or a\n // later edit to them never invalidates the owning module.\n for (const dep of inlined.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Single OXC parse of the post-inline source, shared by every AST\n // consumer below. `inlineResourceUrls` parsed the PRE-inline string,\n // so its program can never be reused here.\n const { program: oxcProgram } = parseOxc(id, code);\n\n // Pre-resolve component styles through the registered style preprocessor\n // and Vite's CSS pipeline (Sass/Less, PostCSS, Tailwind), like ngtsc does.\n // External styleUrls are processed as their own file; truly inline\n // `styles: [...]` use `inlineStylesExtension`.\n let resolvedInlineStyles: Map<number, string> | undefined;\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n for (let i = 0; i < styleStrings.length; i++) {\n const stylePath =\n stylePaths.get(i) ??\n (scanner.sourceFormatOf(id) ? id + '.ts' : id).replace(\n /\\.ts$/,\n `.inline-${i}.${pluginOptions.inlineStylesExtension || 'css'}`,\n );\n try {\n const preprocessed = preprocessStylesheet(\n styleStrings[i],\n stylePath,\n activeStylePreprocessor,\n {\n filename: stylePath,\n containingFile: id,\n order: i,\n inline: !stylePaths.has(i),\n },\n );\n const processed = await preprocessCSS(\n preprocessed,\n stylePath,\n activeConfig,\n );\n resolvedInlineStyles.set(i, processed.code);\n } catch (e) {\n reportStylesheetError(\n activeConfig?.logger,\n stylePath,\n e,\n activeConfig?.command === 'build',\n );\n }\n }\n if (resolvedInlineStyles.size === 0) resolvedInlineStyles = undefined;\n }\n\n scanner.ensureDtsRegistryForSource(code, id, oxcProgram);\n\n scanner.recordFileEntries(id, scanFile(code, id, oxcProgram), true);\n // Scan what `id` imports, and recompile it when their metadata changes.\n await scanner.resolveImportSpecifiers(\n collectAllImports(code, id, oxcProgram),\n id,\n resolveImport,\n );\n if (declaresNonStandaloneComponent(oxcProgram)) {\n projectScan ??= scanProject();\n await projectScan;\n }\n\n // Merge registries contributed through `analog.setup()` into this\n // compile's lookup view. Out-of-tree compilers register directive\n // metadata for classes fastCompile can't reach through its\n // tsconfig-driven scan (e.g. `.tsrx` files compiled by `@tsrx/analog`).\n // Without this merge, a TS `@Component({ imports: [X] })` that\n // references such a class hits `_unresolved-${className}` as its\n // selector and the tag never matches at runtime.\n const activeComponentRegistries = sharedCtx\n ? sharedCtx.componentRegistries\n : componentRegistries;\n const compileRegistry = buildCompileRegistry(\n scanner,\n oxcProgram,\n id,\n activeComponentRegistries,\n );\n\n const result = compile(code, id, {\n registry: compileRegistry,\n resolvedInlineStyles,\n useDefineForClassFields,\n compilationMode: pluginOptions.fastCompileMode,\n oxcProgram,\n });\n\n // Track resource dependencies for HMR\n for (const dep of result.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Strip TypeScript-only syntax and compose the compiler map with the\n // final generated code so downstream breakpoints map back to the source.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n result.map,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n result.map,\n );\n let outputCode = stripped.code;\n\n // Append HMR code in dev mode\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (activeWatchMode && pluginOptions.liveReload) {\n const fileDeclarations = scanner.entriesOf(id);\n if (fileDeclarations.length > 0) {\n const localDepClassNames = fileDeclarations.map((e) => e.className);\n outputCode += generateHmrCode(fileDeclarations, localDepClassNames);\n }\n }\n\n return { code: outputCode, map: stripped.map };\n }\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const resolution = tsConfigResolutionContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n pluginOptions.tsconfigGetter(),\n resolution.isProd,\n pluginOptions.isTest,\n resolution.isLib,\n pluginOptions.workspaceRoot,\n );\n }\n\n const fastCompile: FastCompileApi = {\n registerSourceFormat: (format) => scanner.registerSourceFormat(format),\n scanImports: (specifiers, importer, resolve) =>\n scanner.scanImports(specifiers, importer, resolve),\n resolveSelector: (className, moduleSpecifier, containingFile) =>\n scanner.lookupSelector(\n className,\n sharedCtx ? sharedCtx.componentRegistries : componentRegistries,\n moduleSpecifier !== undefined && containingFile !== undefined\n ? { moduleSpecifier, containingFile }\n : undefined,\n ),\n async compile(code, id, { resolve, mapToSource }) {\n const transformed = await handleFastCompileTransform(\n code,\n id,\n scanner.toResolveImport(resolve),\n );\n if (!transformed) {\n return undefined;\n }\n const map =\n transformed.map && mapToSource\n ? mapToSource(transformed.map)\n : (transformed.map ?? null);\n if (map) {\n emittedMaps.set(\n normalizePath(id),\n typeof map === 'string' ? map : JSON.stringify(map),\n );\n }\n return { code: transformed.code, map };\n },\n };\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(normalizePath(id)),\n hasEmitted: (id: string): boolean => emittedMaps.has(normalizePath(id)),\n fastCompile,\n };\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-fast-compile',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n return {\n name: '@analogjs/vite-plugin-angular-fast-compile',\n api: compilerApi,\n enforce: 'pre' as const,\n async config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n }\n\n const preliminaryTsConfigPath = resolveTsConfigPath();\n\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: preliminaryTsConfigPath,\n isProd,\n jit: pluginOptions.jit,\n watchMode,\n isTest: pluginOptions.isTest,\n isAstroIntegration: pluginOptions.isAstroIntegration,\n });\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`.\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n if (sharedCtx) {\n const integrations = await sharedCtx.resolveConfig(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n } else {\n const integrations = await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n }\n },\n async buildStart() {\n await initFastCompile();\n },\n closeBundle() {\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (!activeWatchMode) {\n emittedMaps.clear();\n releaseCssPreprocessorWorkers();\n }\n },\n async handleHotUpdate(ctx) {\n if (\n sharedCtx\n ? sharedCtx.hmr.isIgnoredFile(ctx.file)\n : isIgnoredHmrFile(ctx.file)\n ) {\n return [];\n }\n\n // Resource file changes → invalidate parent .ts module\n if (resourceToSource.has(ctx.file)) {\n const parentSource = resourceToSource.get(ctx.file)!;\n const parentModule = ctx.server.moduleGraph.getModuleById(parentSource);\n if (parentModule) {\n return [parentModule];\n }\n }\n\n if (scanner.isCompiledSource(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n\n // Remove old entries from this file. Cached scans that pulled in\n // this file may now be incomplete.\n const oldEntries = scanner.entriesOf(fileId);\n scanner.invalidate(fileId);\n\n // Rescan the changed file via the barrel-aware scanner so an\n // edited barrel re-export picks up newly-referenced files.\n // Pass overwrite=true so updated metadata replaces stale\n // entries from the previous scan.\n await scanBarrelExports(fileId, new Set(), true);\n\n // Importers compiled the old selector/inputs/outputs into their\n // templates, so recompile them when this file's metadata changed.\n const metadataChanged =\n JSON.stringify(oldEntries) !==\n JSON.stringify(scanner.entriesOf(fileId));\n if (metadataChanged) {\n const importerModules = [\n ...(scanner.importersByFile.get(fileId) ?? []),\n ].flatMap((importer) => [\n ...(ctx.server.moduleGraph.getModulesByFile(importer) ?? []),\n ]);\n return [...ctx.modules, ...importerModules];\n }\n }\n\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: pluginOptions.jit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? resolvedConfig,\n );\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n // `?raw` ids already carry Vite's native raw-loader output\n // (`export default \"<source>\"`). Recompiling them as Angular/TS\n // would strip that default export, so leave them to Vite (#2356).\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n if (activeTransformFilter && !activeTransformFilter(code, id)) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n const resolveImport = scanner.toResolveImport((spec, importer) =>\n this.resolve(spec, importer, { skipSelf: true }),\n );\n\n const transformed = await handleFastCompileTransform(\n code,\n id,\n resolveImport,\n );\n if (transformed?.map) {\n emittedMaps.set(\n normalizePath(id),\n typeof transformed.map === 'string'\n ? transformed.map\n : JSON.stringify(transformed.map),\n );\n }\n return transformed;\n },\n },\n };\n}\n\n/**\n * Builds the registry view for compiling `id`, overlaying external registries,\n * this file's value import bindings (including aliases, default imports, and\n * same-named components from distinct modules), and declarations from `id`\n * itself. Reuses `scanner.registry` directly when no overrides apply.\n */\nfunction buildCompileRegistry(\n scanner: ComponentScanner,\n program: ReturnType<typeof parseSync>['program'],\n id: string,\n externalRegistries: readonly ComponentRegistryEntries[],\n): ComponentRegistry {\n let compileRegistry: ComponentRegistry = scanner.registry;\n const ensureOverlay = (): ComponentRegistry => {\n if (compileRegistry === scanner.registry) {\n compileRegistry = new Map(scanner.registry);\n }\n return compileRegistry;\n };\n\n if (externalRegistries.some((external) => external.size > 0)) {\n const overlay = ensureOverlay();\n for (const external of externalRegistries) {\n for (const [k, v] of external) overlay.set(k, v);\n }\n }\n\n for (const stmt of program.body || []) {\n if (\n stmt.type !== 'ImportDeclaration' ||\n (stmt as any).importKind === 'type' ||\n !stmt.source?.value\n ) {\n continue;\n }\n const moduleSpecifier: string = stmt.source.value;\n for (const spec of (stmt as any).specifiers || []) {\n if (spec.importKind === 'type') continue;\n let importedName: string | undefined;\n let localName: string | undefined;\n if (spec.type === 'ImportDefaultSpecifier') {\n importedName = 'default';\n localName = spec.local?.name;\n } else if (spec.type === 'ImportSpecifier') {\n importedName =\n spec.imported?.type === 'Identifier'\n ? spec.imported.name\n : typeof spec.imported?.value === 'string'\n ? spec.imported.value\n : undefined;\n localName = spec.local?.name;\n }\n if (!importedName || !localName) continue;\n const entry = scanner.lookupEntry(importedName, externalRegistries, {\n moduleSpecifier,\n containingFile: id,\n });\n if (entry && compileRegistry.get(localName) !== entry) {\n ensureOverlay().set(localName, entry);\n }\n }\n }\n\n for (const localEntry of scanner.entriesOf(id)) {\n if (compileRegistry.get(localEntry.className) !== localEntry) {\n ensureOverlay().set(localEntry.className, localEntry);\n }\n }\n\n return compileRegistry;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAAS,2BACP,OACmC;CACnC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,sBAAsB,KAAK,KAC5B,oBAAoB,SACpB,OAAQ,MAAmC,mBAAmB;AAElE;;;;;;;AAQA,SAAgB,iBACd,SACA,UACQ;CACR,OAAO,SAAS,WAAW,SAAS,iBAAiB;AACvD;AAEA,SAAgB,kBACd,cAIQ;CACR,MAAM,YAAY,sBAAsB,YAAY,IAChD,eACA,2BAA2B,YAAY,IACrC,KAAA,IACA,0BAA0B;EACxB,GAAG;EACH,oBAAoB;CACtB,CAAC;CAEP,MAAM,gBAA0C,YAC5C,UAAU,UACT;CAGL,MAAM,UAAU,IAAI,iBAAiB;CACrC,MAAM,WAAW,QAAQ;CAEzB,MAAM,mBACJ,WAAW,oBACX,IAAI,iBAAiB;EACnB,eAAe,cAAc;EAC7B,SAAS,cAAc,WAAW,CAAC;EACnC,YAAY,cAAc;EAC1B,QAAQ,cAAc;CACxB,CAAC;CAEH,IAAI;CACJ,IAAI;CACJ,IAAI,sBAAkD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AAC,GAAG;GACjD,IAAI,KAAK,eAAe,QAAQ;GAChC,IAAI;GACJ,IAAI;GACJ,IAAI,KAAK,SAAS,0BAA0B;IAC1C,eAAe;IACf,YAAY,KAAK,OAAO;GAC1B,OAAO,IAAI,KAAK,SAAS,mBAAmB;IAC1C,eACE,KAAK,UAAU,SAAS,eACpB,KAAK,SAAS,OACd,OAAO,KAAK,UAAU,UAAU,WAC9B,KAAK,SAAS,QACd,KAAA;IACR,YAAY,KAAK,OAAO;GAC1B;GACA,IAAI,CAAC,gBAAgB,CAAC,WAAW;GACjC,MAAM,QAAQ,QAAQ,YAAY,cAAc,oBAAoB;IAClE;IACA,gBAAgB;GAClB,CAAC;GACD,IAAI,SAAS,gBAAgB,IAAI,SAAS,MAAM,OAC9C,cAAc,CAAC,CAAC,IAAI,WAAW,KAAK;EAExC;CACF;CAEA,KAAK,MAAM,cAAc,QAAQ,UAAU,EAAE,GAC3C,IAAI,gBAAgB,IAAI,WAAW,SAAS,MAAM,YAChD,cAAc,CAAC,CAAC,IAAI,WAAW,WAAW,UAAU;CAIxD,OAAO;AACT"}
@@ -24,7 +24,7 @@ export interface NgpLowerContext {
24
24
  */
25
25
  scanImports(specifiers: string[]): Promise<void>;
26
26
  /** The element selector of a component or directive class, if known. */
27
- resolveSelector(className: string): string | null;
27
+ resolveSelector(className: string, moduleSpecifier?: string, containingFile?: string): string | null;
28
28
  }
29
29
  export interface NgpLoweredModule {
30
30
  code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ngp-compile-api.js","names":[],"sources":["../../../src/lib/ngp-compile-api.ts"],"sourcesContent":["import type {\n FastCompileSourceFormat,\n SourceMapInput,\n} from './fast-compile-api.js';\n\n/**\n * The NGP compile plugin's API (`compilation: 'ngp'`), for Vite plugins that\n * compile other source formats into Angular components.\n *\n * NGP analyzes the whole program when the build starts, so a format's modules\n * are lowered to TypeScript up front and NGP reads each one as a TypeScript\n * file named after it (`counter.tsrx` as `counter.tsrx.ts`). Imports of the\n * module resolve to that file, and the lowered code is type-checked with it.\n */\nexport interface NgpCompileApi {\n registerSourceFormat(format: NgpSourceFormat): void;\n}\n\nexport interface NgpSourceFormat extends FastCompileSourceFormat {\n /** Glob of the format's modules, relative to the tsconfig's directory. */\n include: string;\n /** Lowers a module to the TypeScript NGP compiles in its place. */\n lower(\n code: string,\n path: string,\n context: NgpLowerContext,\n ): Promise<NgpLoweredModule>;\n}\n\nexport interface NgpLowerContext {\n /**\n * Scans the modules behind `specifiers`, imported by the module being\n * lowered, so `resolveSelector` knows their selectors.\n */\n scanImports(specifiers: string[]): Promise<void>;\n /** The element selector of a component or directive class, if known. */\n resolveSelector(className: string): string | null;\n}\n\nexport interface NgpLoweredModule {\n code: string;\n /** Why the module couldn't be lowered, reported when it's transformed. */\n error?: { message: string; loc?: { line: number; column: number } };\n /** Maps a source map of `code` back to the module's source. */\n mapToSource(map: SourceMapInput): { [key: string]: unknown };\n /**\n * Maps a zero-based line and column in `code` to the module's source, or\n * `null` for generated code.\n */\n toSourceLocation(\n line: number,\n column: number,\n ): { line: number; column: number } | null;\n}\n\n/** Finds the NGP compile plugin's API among resolved Vite plugins. */\nexport function findNgpCompileApi(\n plugins: readonly { api?: unknown }[],\n): NgpCompileApi | undefined {\n for (const plugin of plugins) {\n const api = plugin.api as { ngp?: NgpCompileApi } | undefined;\n if (api?.ngp) {\n return api.ngp;\n }\n }\n return undefined;\n}\n"],"mappings":";;AAwDA,SAAgB,kBACd,SAC2B;CAC3B,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,MAAM,OAAO;EACnB,IAAI,KAAK,KACP,OAAO,IAAI;CAEf;AAEF"}
1
+ {"version":3,"file":"ngp-compile-api.js","names":[],"sources":["../../../src/lib/ngp-compile-api.ts"],"sourcesContent":["import type {\n FastCompileSourceFormat,\n SourceMapInput,\n} from './fast-compile-api.js';\n\n/**\n * The NGP compile plugin's API (`compilation: 'ngp'`), for Vite plugins that\n * compile other source formats into Angular components.\n *\n * NGP analyzes the whole program when the build starts, so a format's modules\n * are lowered to TypeScript up front and NGP reads each one as a TypeScript\n * file named after it (`counter.tsrx` as `counter.tsrx.ts`). Imports of the\n * module resolve to that file, and the lowered code is type-checked with it.\n */\nexport interface NgpCompileApi {\n registerSourceFormat(format: NgpSourceFormat): void;\n}\n\nexport interface NgpSourceFormat extends FastCompileSourceFormat {\n /** Glob of the format's modules, relative to the tsconfig's directory. */\n include: string;\n /** Lowers a module to the TypeScript NGP compiles in its place. */\n lower(\n code: string,\n path: string,\n context: NgpLowerContext,\n ): Promise<NgpLoweredModule>;\n}\n\nexport interface NgpLowerContext {\n /**\n * Scans the modules behind `specifiers`, imported by the module being\n * lowered, so `resolveSelector` knows their selectors.\n */\n scanImports(specifiers: string[]): Promise<void>;\n /** The element selector of a component or directive class, if known. */\n resolveSelector(\n className: string,\n moduleSpecifier?: string,\n containingFile?: string,\n ): string | null;\n}\n\nexport interface NgpLoweredModule {\n code: string;\n /** Why the module couldn't be lowered, reported when it's transformed. */\n error?: { message: string; loc?: { line: number; column: number } };\n /** Maps a source map of `code` back to the module's source. */\n mapToSource(map: SourceMapInput): { [key: string]: unknown };\n /**\n * Maps a zero-based line and column in `code` to the module's source, or\n * `null` for generated code.\n */\n toSourceLocation(\n line: number,\n column: number,\n ): { line: number; column: number } | null;\n}\n\n/** Finds the NGP compile plugin's API among resolved Vite plugins. */\nexport function findNgpCompileApi(\n plugins: readonly { api?: unknown }[],\n): NgpCompileApi | undefined {\n for (const plugin of plugins) {\n const api = plugin.api as { ngp?: NgpCompileApi } | undefined;\n if (api?.ngp) {\n return api.ngp;\n }\n }\n return undefined;\n}\n"],"mappings":";;AA4DA,SAAgB,kBACd,SAC2B;CAC3B,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,MAAM,OAAO;EACnB,IAAI,KAAK,KACP,OAAO,IAAI;CAEf;AAEF"}
@@ -151,7 +151,10 @@ function ngpCompilePlugin(optionsOrCtx) {
151
151
  const removed = removals.get(programFile);
152
152
  const lowered = await format.lower(source, sourceFile, {
153
153
  scanImports: (specifiers) => scanner.scanImports(specifiers, sourceFile, resolve),
154
- resolveSelector: (className) => scanner.lookupSelector(className, sharedCtx?.componentRegistries ?? componentRegistries)
154
+ resolveSelector: (className, moduleSpecifier, containingFile) => scanner.lookupSelector(className, sharedCtx?.componentRegistries ?? componentRegistries, moduleSpecifier !== void 0 ? {
155
+ moduleSpecifier,
156
+ containingFile: containingFile ?? sourceFile
157
+ } : void 0)
155
158
  });
156
159
  if (removals.get(programFile) !== removed) return false;
157
160
  const changed = sourceModules.get(programFile)?.lowered.code !== lowered.code;