@analogjs/vite-plugin-angular 3.0.0-beta.47 → 3.0.0-beta.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/lib/component-scanner.d.ts +74 -0
- package/src/lib/component-scanner.js +178 -0
- package/src/lib/component-scanner.js.map +1 -0
- package/src/lib/fast-compile-plugin.js +26 -165
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/ngp-compile-api.d.ts +55 -0
- package/src/lib/ngp-compile-api.js +12 -0
- package/src/lib/ngp-compile-api.js.map +1 -0
- package/src/lib/ngp-compile-plugin.js +286 -41
- package/src/lib/ngp-compile-plugin.js.map +1 -1
- package/src/lib/utils/lsp-type-checker.d.ts +22 -2
- package/src/lib/utils/lsp-type-checker.js +39 -10
- package/src/lib/utils/lsp-type-checker.js.map +1 -1
- package/src/lib/utils/ngp-host-fs.d.ts +32 -0
- package/src/lib/utils/ngp-host-fs.js +104 -0
- package/src/lib/utils/ngp-host-fs.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fast-compile-plugin.js","names":[],"sources":["../../../src/lib/fast-compile-plugin.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './compiler/utils.js';\nimport * as vite from 'vite';\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n compile,\n scanFile,\n declaresNonStandaloneComponent,\n scanPackageDts,\n collectImportedPackages,\n collectRelativeReExports,\n collectReExports,\n collectAllImports,\n jitTransform,\n inlineResourceUrls,\n extractInlineStyles,\n generateHmrCode,\n debugRegistry,\n ANGULAR_DECORATOR_CALL_RE,\n type ComponentRegistry,\n} from './compiler/index.js';\nimport { 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 {\n FastCompileApi,\n FastCompileResolve,\n FastCompileSourceFormat,\n} from './fast-compile-api.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nexport interface FastCompilePluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n fastCompileMode?: 'full' | 'partial';\n disableTypeChecking?: boolean;\n typeChecker?: TypeCheckerOption;\n include?: string[];\n}\n\nfunction isFastCompilePluginOptions(\n value: unknown,\n): value is FastCompilePluginOptions {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isAngularBuildContext(value) &&\n 'tsconfigGetter' in value &&\n typeof (value as FastCompilePluginOptions).tsconfigGetter === 'function'\n );\n}\n\ntype ResolveImport = (spec: string, importer: string) => Promise<string | null>;\n\n/**\n * Directory that `compilerOptions.paths` targets resolve against. Mirrors\n * TypeScript: `baseUrl` when set, otherwise the directory of the config\n * that declares `paths` (`pathsBasePath`, since `baseUrl` is optional\n * from TS 4.1).\n */\nexport function getPathsBasePath(\n options: { baseUrl?: string; pathsBasePath?: string } | undefined,\n fallback: string,\n): string {\n return options?.baseUrl ?? options?.pathsBasePath ?? fallback;\n}\n\nexport function fastCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompilePluginOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n ...optionsOrCtx,\n compilationBackend: 'fast',\n });\n\n const pluginOptions: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n /** Source formats registered through `api.fastCompile.registerSourceFormat`. */\n const sourceFormats: FastCompileSourceFormat[] = [];\n const sourceFormatOf = (\n file: string,\n ): FastCompileSourceFormat | undefined => {\n const path = file.split('?')[0];\n return sourceFormats.find((format) => format.test(path));\n };\n\n /** Whether `file` is a module compiled through this plugin. */\n const isCompiledSource = (file: string): boolean =>\n TS_EXT_REGEX.test(file) || sourceFormatOf(file) !== undefined;\n\n /**\n * Reads a source file for registry scanning. Modules of a registered source\n * format are converted to TypeScript first so the scanner sees their classes.\n */\n const readScanSource = async (file: string): Promise<string> => {\n const code = await fsPromises.readFile(file, 'utf-8');\n const format = sourceFormatOf(file);\n return format ? format.toScanSource(code, file) : code;\n };\n\n /**\n * Adapts a Vite-style resolver to the scanner's: only source files this\n * plugin compiles, outside `node_modules` (package declarations come from\n * the lazy `.d.ts` scanner instead).\n */\n const toResolveImport =\n (resolve: FastCompileResolve): ResolveImport =>\n async (spec, importer) => {\n const resolved = await resolve(spec, importer);\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n return isCompiledSource(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n };\n\n const tsconfigResolver =\n sharedCtx?.tsconfigResolver ??\n new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include ?? [],\n liveReload: pluginOptions.liveReload,\n isTest: pluginOptions.isTest,\n });\n\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // fast-compile plugin state\n const registry: ComponentRegistry = new Map();\n const resourceToSource = new Map<string, string>();\n const scannedDtsPackages = new Set<string>();\n const emittedMaps = new Map<string, string>();\n let projectRoot = '';\n let useDefineForClassFields = true;\n let tsConfig: ReturnType<typeof compilerCli.readConfiguration>;\n\n // Files scanned on demand (mapped to the barrel chain they pulled in), which\n // modules were compiled against each scanned file, and the one-time\n // whole-project scan non-standalone components fall back to.\n const lazyScans = new Map<string, Promise<Set<string>>>();\n const importersByFile = new Map<string, Set<string>>();\n let projectScan: Promise<void> | undefined;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code = fileContents?.get(file) ?? (await 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 registry.clear();\n scannedDtsPackages.clear();\n lazyScans.clear();\n importersByFile.clear();\n projectScan = undefined;\n const resolvedTsConfigPath = resolveTsConfigPath();\n projectRoot = dirname(resolvedTsConfigPath);\n tsConfig = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = tsConfig.options?.useDefineForClassFields ?? true;\n }\n\n /** Scan all source files reachable from the tsconfig into the registry. */\n async function scanProject(): Promise<void> {\n const config = tsConfig;\n const extraIncludes = tsconfigResolver.ensureIncludeCache();\n // Collect candidate files: tsconfig rootNames PLUS explicit/integration\n // include globs PLUS the entry points named in `compilerOptions.paths`.\n // App tsconfigs typically only include the app's own sources, so workspace\n // library entry barrels (e.g. `HlmSelectImports = [HlmSelect,\n // HlmSelectContent, ...] as const`) live outside `rootNames` and would\n // otherwise miss the initial scan. The compiler then can't see that\n // `HlmSelectImports` is a tuple barrel and emits the bare identifier into\n // the parent component's `dependencies()` list, where Angular's runtime\n // silently drops it because arrays don't have a directive def.\n const candidates = new Set<string>([...config.rootNames, ...extraIncludes]);\n const tsPaths = config.options?.paths;\n const baseUrl = getPathsBasePath(config.options, projectRoot);\n // Cold-start dedup caches shared by the three scan phases below\n // (candidates scan, walkImports, scanBarrelExports). Scoped to this\n // init call only — HMR/watcher re-scans must hit disk fresh.\n const fileContents = new Map<string, string>();\n const scanResults = new Map<string, ReturnType<typeof scanFile>>();\n if (tsPaths) {\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n // Skip wildcard patterns — entry barrels are normally exact\n // file paths like \"libs/helm/select/src/index.ts\".\n if (target.includes('*')) continue;\n candidates.add(resolve(baseUrl, target));\n }\n }\n }\n const results = await Promise.all(\n Array.from(candidates).map(async (file) => {\n try {\n const code = await 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 readScanSource(file));\n fileContents.set(file, code);\n } catch {\n return;\n }\n // Single parse shared by scanFile, collectImportedPackages, and\n // collectAllImports. On a parse error each consumer re-parses on\n // its own, preserving their individual failure semantics.\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults.set(file, entries);\n }\n for (const entry of entries) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n // Pre-scan the `.d.ts` of every external package this file imports (and,\n // transitively, packages those packages' NgModules re-export — e.g.\n // BrowserModule → CommonModule → NgIf). Doing this at buildStart means the\n // registry is complete before any component transforms, so non-standalone\n // component scope resolves regardless of file transform order.\n for (const pkg of collectImportedPackages(code, file, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n try {\n for (const entry of scanPackageDts(\n pkg,\n projectRoot,\n scannedDtsPackages,\n )) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n const dir = dirname(file);\n const targets = await Promise.all(\n collectAllImports(code, file, program).map((spec) => {\n if (spec.startsWith('.')) {\n return resolveToSource(\n resolve(dir, spec.replace(/\\.(?:js|mjs)$/u, '')),\n );\n }\n let resolved = bareSpecResolveCache.get(spec);\n if (!resolved) {\n resolved = resolveFirstSource(resolvePathSpecifier(spec));\n bareSpecResolveCache.set(spec, resolved);\n }\n return resolved;\n }),\n );\n await Promise.all(\n targets.filter((t): t is string => !!t).map((t) => walkImports(t)),\n );\n };\n const walkRoots = [...new Set([...config.rootNames, ...extraIncludes])];\n await Promise.all(walkRoots.map((file) => walkImports(file)));\n\n // Library barrels typically `export * from './lib/...'` rather than\n // declaring directives directly, so the entry file alone gives us\n // the tuple consts but not the directive classes they reference.\n // Walk the relative `export *` chain so the underlying classes also\n // land in the registry. Use a SHARED visited set across all\n // barrels so recursive walks don't double-scan a file that's\n // re-exported from multiple entry points.\n const buildStartVisited = new Set<string>();\n if (tsPaths) {\n const barrelCandidates: string[] = [];\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n if (target.includes('*')) continue;\n barrelCandidates.push(resolve(baseUrl, target));\n }\n }\n await Promise.all(\n barrelCandidates.map((c) =>\n scanBarrelExports(\n c,\n buildStartVisited,\n false,\n fileContents,\n scanResults,\n ),\n ),\n );\n }\n debugRegistry(\n 'initFastCompile done: %d entries from %d candidate files',\n registry.size,\n candidates.size,\n );\n }\n\n function ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: ReturnType<typeof parseSync>['program'],\n ): void {\n ensureDtsRegistryForPackages(collectImportedPackages(code, id, program));\n }\n\n /** Scan the `.d.ts` declarations of `packages` into the registry, once each. */\n function ensureDtsRegistryForPackages(packages: Iterable<string>): void {\n for (const pkg of packages) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n\n try {\n const dtsEntries = scanPackageDts(\n pkg,\n // Before a tsconfig resolves, look up packages from the working directory.\n projectRoot || process.cwd(),\n scannedDtsPackages,\n );\n for (const entry of dtsEntries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n /**\n * Scan the source files `id` imports into the registry on demand and record\n * `id` as their importer, so a metadata change in any of them recompiles it.\n */\n async function resolveImportedDeclarations(\n code: string,\n id: string,\n program: ReturnType<typeof parseSync>['program'],\n resolveImport: ResolveImport,\n ): Promise<void> {\n await resolveImportSpecifiers(\n collectAllImports(code, id, program),\n id,\n resolveImport,\n );\n }\n\n /**\n * Scan the files behind `specs`, imported by `id`, into the registry and\n * record `id` as their importer.\n */\n async function resolveImportSpecifiers(\n specs: string[],\n id: string,\n resolveImport: ResolveImport,\n ): Promise<void> {\n await Promise.all(\n specs.map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await scanOnDemand(file, resolveImport)) {\n let importers = importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n function scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = lazyScans.get(file);\n if (!scan) {\n scan = scanWithReExports(file, resolveImport);\n lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n async function scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: ReturnType<typeof parseSync>['program'];\n try {\n code = await readScanSource(current);\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n\n /**\n * The element selector of a component or directive class, for source formats\n * that reference components by class. Includes registries contributed\n * through `analog.setup()`.\n */\n function lookupSelector(className: string): string | null {\n const registries = sharedCtx\n ? sharedCtx.componentRegistries\n : componentRegistries;\n const entry =\n registry.get(className) ??\n registries.map((r) => r.get(className)).find((e) => e !== undefined);\n if (!entry || (entry.kind !== 'component' && entry.kind !== 'directive')) {\n return null;\n }\n return entry.selector;\n }\n\n function registryEntriesOf(file: string) {\n return [...registry.values()].filter((e) => e.fileName === file);\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\n resolveImport: ResolveImport,\n ): Promise<{ code: string; map: any } | undefined> {\n if (!ANGULAR_DECORATOR_CALL_RE.test(code)) {\n // Non-Angular file — strip TS-only syntax ourselves so barrels\n // like `export { Foo, type Bar } from './x'` and other TS-only\n // forms don't leak unstripped to Rolldown. In rolldown-vite the\n // built-in `vite:oxc` strip is registered as a Rust-side native\n // plugin (`viteTransformPlugin` from `rolldown/experimental`); if\n // its hook-filter treats files our `transform.filter.id.include`\n // claimed as already-handled, no JS-side fallback runs and raw\n // TS reaches the parser → `SyntaxError: Unexpected identifier`.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(code, id, {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n })\n : await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n sourcemap: true,\n });\n return { code: stripped.code, map: stripped.map };\n }\n\n // JIT mode\n if (pluginOptions.jit) {\n const result = jitTransform(code, id);\n // Strip TypeScript-only syntax (e.g. `readonly`, parameter property\n // modifiers, type annotations on fields) so the output is valid JS\n // for Rolldown. `angularVitestSourcemapPlugin` normally runs this\n // strip downstream in tests, but it is intentionally skipped on\n // StackBlitz / WebContainer — and the production build pipeline\n // does not register it either — so the JIT path must self-strip\n // to stay safe across environments.\n //\n // Pass the jitTransform map as `inMap` so OXC/esbuild emit a map\n // composed with the original `.ts` source — without this, debug\n // stack traces and breakpoints land on the wrong lines once the\n // strip removes any TS-only token. `jitTransform` returns\n // `map: null` for files with no Angular class (no edits made);\n // passing that to OXC/esbuild as `inMap` throws, so coerce to\n // `undefined` in that case.\n const inMap = result.map ?? undefined;\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n inMap,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n inMap,\n );\n return { code: stripped.code, map: stripped.map };\n }\n\n // Inline external templateUrl/styleUrl(s) into the source before compilation.\n // `stylePaths` carries the source path of each inlined external style so\n // it is preprocessed as its own file (e.g. an external `.scss` styleUrl or\n // a relative `@import`) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { stylePaths } = inlined;\n\n // Track inlined resources for HMR. `compile()` only reports resources it\n // reads through its own fallback (a templateUrl/styleUrl the inliner did\n // NOT already inline), so files inlined here must be recorded here or a\n // later edit to them never invalidates the owning module.\n for (const dep of inlined.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Single OXC parse of the post-inline source, shared by every AST\n // consumer below. `inlineResourceUrls` parsed the PRE-inline string,\n // so its program can never be reused here.\n const { program: oxcProgram } = parseOxc(id, code);\n\n // Pre-resolve component styles through the registered style preprocessor\n // and Vite's CSS pipeline (Sass/Less, PostCSS, Tailwind), like ngtsc does.\n // External styleUrls are processed as their own file; truly inline\n // `styles: [...]` use `inlineStylesExtension`.\n let resolvedInlineStyles: Map<number, string> | undefined;\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n for (let i = 0; i < styleStrings.length; i++) {\n const stylePath =\n stylePaths.get(i) ??\n (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 ensureDtsRegistryForSource(code, id, oxcProgram);\n\n for (const entry of scanFile(code, id, oxcProgram)) {\n registry.set(entry.className, entry);\n }\n await resolveImportedDeclarations(code, id, oxcProgram, resolveImport);\n if (declaresNonStandaloneComponent(oxcProgram)) {\n projectScan ??= scanProject();\n await projectScan;\n }\n\n // Merge registries contributed through `analog.setup()` into this\n // compile's lookup view. Out-of-tree compilers register directive\n // metadata for classes fastCompile can't reach through its\n // tsconfig-driven scan (e.g. `.tsrx` files compiled by `@tsrx/analog`).\n // Without this merge, a TS `@Component({ imports: [X] })` that\n // references such a class hits `_unresolved-${className}` as its\n // selector and the tag never matches at runtime.\n const activeComponentRegistries = sharedCtx\n ? sharedCtx.componentRegistries\n : componentRegistries;\n let compileRegistry: ComponentRegistry = registry;\n if (activeComponentRegistries.some((external) => external.size > 0)) {\n compileRegistry = new Map(registry);\n for (const external of activeComponentRegistries) {\n for (const [k, v] of external) compileRegistry.set(k, v);\n }\n }\n\n const result = compile(code, id, {\n registry: compileRegistry,\n resolvedInlineStyles,\n useDefineForClassFields,\n compilationMode: pluginOptions.fastCompileMode,\n oxcProgram,\n });\n\n // Track resource dependencies for HMR\n for (const dep of result.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Strip TypeScript-only syntax and compose the compiler map with the\n // final generated code so downstream breakpoints map back to the source.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n result.map,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n result.map,\n );\n let outputCode = stripped.code;\n\n // Append HMR code in dev mode\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (activeWatchMode && pluginOptions.liveReload) {\n const fileDeclarations = registryEntriesOf(id);\n if (fileDeclarations.length > 0) {\n const localDepClassNames = fileDeclarations.map((e) => e.className);\n outputCode += generateHmrCode(fileDeclarations, localDepClassNames);\n }\n }\n\n return { code: outputCode, map: stripped.map };\n }\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const resolution = tsConfigResolutionContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n pluginOptions.tsconfigGetter(),\n resolution.isProd,\n pluginOptions.isTest,\n resolution.isLib,\n pluginOptions.workspaceRoot,\n );\n }\n\n const fastCompile: FastCompileApi = {\n registerSourceFormat(format) {\n if (!sourceFormats.includes(format)) {\n sourceFormats.push(format);\n }\n },\n scanImports(specifiers, importer, resolve) {\n // Packages' Angular classes come from their `.d.ts` declarations;\n // relative imports are scanned from source.\n ensureDtsRegistryForPackages(\n specifiers\n .filter((spec) => !spec.startsWith('.') && !spec.startsWith('/'))\n .map((spec) => {\n const parts = spec.split('/');\n return spec.startsWith('@')\n ? parts.slice(0, 2).join('/')\n : parts[0];\n }),\n );\n return resolveImportSpecifiers(\n specifiers,\n importer,\n toResolveImport(resolve),\n );\n },\n resolveSelector: lookupSelector,\n async compile(code, id, { resolve, mapToSource }) {\n const transformed = await handleFastCompileTransform(\n code,\n id,\n 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 (isCompiledSource(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n\n // Remove old entries from this file\n const oldEntries = registryEntriesOf(fileId);\n for (const entry of oldEntries) {\n registry.delete(entry.className);\n }\n\n // Rescan the changed file via the barrel-aware scanner so an\n // edited barrel re-export picks up newly-referenced files.\n // Pass overwrite=true so updated metadata replaces stale\n // entries from the previous scan.\n await scanBarrelExports(fileId, new Set(), true);\n\n // Importers compiled the old selector/inputs/outputs into their\n // templates, so recompile them when this file's metadata changed.\n // Cached scans that pulled in this file may now be incomplete.\n lazyScans.clear();\n const metadataChanged =\n JSON.stringify(oldEntries) !==\n JSON.stringify(registryEntriesOf(fileId));\n if (metadataChanged) {\n const importerModules = [\n ...(importersByFile.get(fileId) ?? []),\n ].flatMap((importer) => [\n ...(ctx.server.moduleGraph.getModulesByFile(importer) ?? []),\n ]);\n return [...ctx.modules, ...importerModules];\n }\n }\n\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: pluginOptions.jit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? resolvedConfig,\n );\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n // `?raw` ids already carry Vite's native raw-loader output\n // (`export default \"<source>\"`). Recompiling them as Angular/TS\n // would strip that default export, so leave them to Vite (#2356).\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n if (activeTransformFilter && !activeTransformFilter(code, id)) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n const resolveImport = 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":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,SAAS,2BACP,OACmC;CACnC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,sBAAsB,KAAK,KAC5B,oBAAoB,SACpB,OAAQ,MAAmC,mBAAmB;AAElE;;;;;;;AAUA,SAAgB,iBACd,SACA,UACQ;CACR,OAAO,SAAS,WAAW,SAAS,iBAAiB;AACvD;AAEA,SAAgB,kBACd,cAIQ;CACR,MAAM,YAAY,sBAAsB,YAAY,IAChD,eACA,2BAA2B,YAAY,IACrC,KAAA,IACA,0BAA0B;EACxB,GAAG;EACH,oBAAoB;CACtB,CAAC;CAEP,MAAM,gBAA0C,YAC5C,UAAU,UACT;;CAGL,MAAM,gBAA2C,CAAC;CAClD,MAAM,kBACJ,SACwC;EACxC,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC;EAC7B,OAAO,cAAc,MAAM,WAAW,OAAO,KA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,SAAS,GAAG,eAAe;IAC5C;GACF;GAGA,OAAO,IAAI;EACb;EACA,UAAU,IAAI,UAAU;GACtB,OAAO,wBAAwB,IAAI,UAAU;IAC3C,KAAK,cAAc;IACnB,gBAAgB,WAAW,kBAAkB;GAC/C,CAAC;EACH;EACA,MAAM,KAAK,IAAI;GACb,OAAO,yBACL,MACA,IACA,WAAW,kBAAkB,cAC/B;EACF;EACA,WAAW;GACT,QAAQ,EACN,IAAI;IACF,SAAS,CAAC,YAAY;IAItB,SAAS;KACP;KACA;KACA;KACA;IACF;GACF,EACF;GACA,MAAM,QAAQ,MAAM,IAAI;IACtB,MAAM,wBACJ,WAAW,mBAAmB;IAChC,IAAI,yBAAyB,CAAC,sBAAsB,MAAM,EAAE,GAC1D;IAGF,IAAI,GAAG,SAAS,MAAM,GACpB,KAAK,GAAG,QAAQ,UAAU,EAAE;IAE9B,MAAM,gBAAgB,iBAAiB,MAAM,aAC3C,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":[],"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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AAc,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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { FastCompileSourceFormat, SourceMapInput } from "./fast-compile-api.js";
|
|
2
|
+
/**
|
|
3
|
+
* The NGP compile plugin's API (`compilation: 'ngp'`), for Vite plugins that
|
|
4
|
+
* compile other source formats into Angular components.
|
|
5
|
+
*
|
|
6
|
+
* NGP analyzes the whole program when the build starts, so a format's modules
|
|
7
|
+
* are lowered to TypeScript up front and NGP reads each one as a TypeScript
|
|
8
|
+
* file named after it (`counter.tsrx` as `counter.tsrx.ts`). Imports of the
|
|
9
|
+
* module resolve to that file, and the lowered code is type-checked with it.
|
|
10
|
+
*/
|
|
11
|
+
export interface NgpCompileApi {
|
|
12
|
+
registerSourceFormat(format: NgpSourceFormat): void;
|
|
13
|
+
}
|
|
14
|
+
export interface NgpSourceFormat extends FastCompileSourceFormat {
|
|
15
|
+
/** Glob of the format's modules, relative to the tsconfig's directory. */
|
|
16
|
+
include: string;
|
|
17
|
+
/** Lowers a module to the TypeScript NGP compiles in its place. */
|
|
18
|
+
lower(code: string, path: string, context: NgpLowerContext): Promise<NgpLoweredModule>;
|
|
19
|
+
}
|
|
20
|
+
export interface NgpLowerContext {
|
|
21
|
+
/**
|
|
22
|
+
* Scans the modules behind `specifiers`, imported by the module being
|
|
23
|
+
* lowered, so `resolveSelector` knows their selectors.
|
|
24
|
+
*/
|
|
25
|
+
scanImports(specifiers: string[]): Promise<void>;
|
|
26
|
+
/** The element selector of a component or directive class, if known. */
|
|
27
|
+
resolveSelector(className: string): string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface NgpLoweredModule {
|
|
30
|
+
code: string;
|
|
31
|
+
/** Why the module couldn't be lowered, reported when it's transformed. */
|
|
32
|
+
error?: {
|
|
33
|
+
message: string;
|
|
34
|
+
loc?: {
|
|
35
|
+
line: number;
|
|
36
|
+
column: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/** Maps a source map of `code` back to the module's source. */
|
|
40
|
+
mapToSource(map: SourceMapInput): {
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Maps a zero-based line and column in `code` to the module's source, or
|
|
45
|
+
* `null` for generated code.
|
|
46
|
+
*/
|
|
47
|
+
toSourceLocation(line: number, column: number): {
|
|
48
|
+
line: number;
|
|
49
|
+
column: number;
|
|
50
|
+
} | null;
|
|
51
|
+
}
|
|
52
|
+
/** Finds the NGP compile plugin's API among resolved Vite plugins. */
|
|
53
|
+
export declare function findNgpCompileApi(plugins: readonly {
|
|
54
|
+
api?: unknown;
|
|
55
|
+
}[]): NgpCompileApi | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region packages/vite-plugin-angular/src/lib/ngp-compile-api.ts
|
|
2
|
+
/** Finds the NGP compile plugin's API among resolved Vite plugins. */
|
|
3
|
+
function findNgpCompileApi(plugins) {
|
|
4
|
+
for (const plugin of plugins) {
|
|
5
|
+
const api = plugin.api;
|
|
6
|
+
if (api?.ngp) return api.ngp;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { findNgpCompileApi };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=ngp-compile-api.js.map
|
|
@@ -0,0 +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"}
|