@analogjs/vite-plugin-angular 3.0.0-beta.8 → 3.0.0
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/migrations/migrate-setup-vitest/migrate-setup-vitest.js +3 -3
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/ngp/LICENSE +21 -0
- package/ngp/api.mjs +46806 -0
- package/ngp/build.json +4 -0
- package/ngp/ng_analyze.cjs +601 -0
- package/ngp/ng_analyze_bg.wasm +0 -0
- package/package.json +5 -2
- package/src/index.d.ts +2 -0
- package/src/index.js +4 -3
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.js +2 -3
- package/src/lib/angular-build-context.d.ts +215 -0
- package/src/lib/angular-build-context.js +360 -0
- package/src/lib/angular-build-context.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +6 -4
- package/src/lib/angular-build-optimizer-plugin.js +25 -11
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +5 -3
- package/src/lib/angular-jit-plugin.js +16 -9
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +6 -109
- package/src/lib/angular-vite-plugin.js +9 -1251
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +3 -2
- package/src/lib/angular-vitest-plugin.js +7 -5
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/companion-plugins.d.ts +7 -0
- package/src/lib/companion-plugins.js +37 -0
- package/src/lib/companion-plugins.js.map +1 -0
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +11 -2
- package/src/lib/compilation-api/compilation-api-plugin.js +156 -285
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compilation-api/index.js +1 -2
- package/src/lib/compiler/angular-version.js +0 -1
- package/src/lib/compiler/class-field-lowering.js +1 -2
- package/src/lib/compiler/compile.d.ts +1 -1
- package/src/lib/compiler/compile.js +224 -151
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/constants.js +1 -2
- package/src/lib/compiler/debug.js +1 -2
- package/src/lib/compiler/defer.d.ts +2 -3
- package/src/lib/compiler/defer.js +13 -16
- package/src/lib/compiler/defer.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +6 -1
- package/src/lib/compiler/dts-reader.js +20 -12
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +8 -4
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +6 -6
- package/src/lib/compiler/jit-metadata.js +1 -2
- package/src/lib/compiler/jit-transform.js +37 -15
- package/src/lib/compiler/jit-transform.js.map +1 -1
- package/src/lib/compiler/js-emitter.d.ts +0 -3
- package/src/lib/compiler/js-emitter.js +4 -23
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/compiler/metadata.js +2 -3
- package/src/lib/compiler/registry.d.ts +9 -1
- package/src/lib/compiler/registry.js +36 -8
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/compiler/resource-inliner.d.ts +8 -9
- package/src/lib/compiler/resource-inliner.js +11 -20
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.d.ts +22 -1
- package/src/lib/compiler/style-ast.js +37 -20
- package/src/lib/compiler/style-ast.js.map +1 -1
- package/src/lib/compiler/type-elision.d.ts +4 -3
- package/src/lib/compiler/type-elision.js +11 -13
- package/src/lib/compiler/type-elision.js.map +1 -1
- package/src/lib/compiler/utils.d.ts +9 -7
- package/src/lib/compiler/utils.js +50 -11
- package/src/lib/compiler/utils.js.map +1 -1
- package/src/lib/compiler-plugin.js +1 -2
- package/src/lib/component-resolvers.js +1 -2
- package/src/lib/component-scanner.d.ts +101 -0
- package/src/lib/component-scanner.js +331 -0
- package/src/lib/component-scanner.js.map +1 -0
- package/src/lib/component-styles-plugin.d.ts +52 -0
- package/src/lib/component-styles-plugin.js +352 -0
- package/src/lib/component-styles-plugin.js.map +1 -0
- package/src/lib/compose-angular-plugins.d.ts +12 -0
- package/src/lib/compose-angular-plugins.js +30 -0
- package/src/lib/compose-angular-plugins.js.map +1 -0
- package/src/lib/dev-server-mode-plugin.d.ts +7 -0
- package/src/lib/dev-server-mode-plugin.js +22 -0
- package/src/lib/dev-server-mode-plugin.js.map +1 -0
- package/src/lib/encapsulation-plugin.js +1 -2
- package/src/lib/fast-compile-api.d.ts +62 -0
- package/src/lib/fast-compile-api.js +11 -0
- package/src/lib/fast-compile-api.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +6 -1
- package/src/lib/fast-compile-plugin.js +222 -117
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.d.ts +3 -0
- package/src/lib/host.js +5 -4
- package/src/lib/host.js.map +1 -1
- package/src/lib/hot-update-batch.js +1 -2
- package/src/lib/live-reload-plugin.d.ts +6 -3
- package/src/lib/live-reload-plugin.js +14 -8
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-api.d.ts +55 -0
- package/src/lib/ngp-compile-api.js +11 -0
- package/src/lib/ngp-compile-api.js.map +1 -0
- package/src/lib/ngp-compile-plugin.d.ts +4 -0
- package/src/lib/ngp-compile-plugin.js +675 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
- package/src/lib/ngtsc-compile-plugin.js +776 -0
- package/src/lib/ngtsc-compile-plugin.js.map +1 -0
- package/src/lib/nx-folder-plugin.d.ts +6 -5
- package/src/lib/nx-folder-plugin.js +13 -9
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +6 -0
- package/src/lib/plugins/file-replacements.plugin.js +2 -2
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +5 -1
- package/src/lib/router-plugin.js +14 -6
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-preprocessor.js +1 -2
- package/src/lib/stylesheet-registry.js +1 -2
- package/src/lib/stylesheet-registry.js.map +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -3
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +1 -2
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +3 -4
- package/src/lib/utils/css-extension-resolver.js +1 -2
- package/src/lib/utils/css-preprocessor-workers.js +1 -2
- package/src/lib/utils/debug-harness.js +1 -2
- package/src/lib/utils/debug-log-file.js +1 -2
- package/src/lib/utils/debug.js +1 -2
- package/src/lib/utils/devkit.js +2 -3
- package/src/lib/utils/hmr-component-updates.d.ts +7 -0
- package/src/lib/utils/hmr-component-updates.js +86 -0
- package/src/lib/utils/hmr-component-updates.js.map +1 -0
- package/src/lib/utils/jit-inline-styles.js +1 -2
- package/src/lib/utils/lsp-type-checker.d.ts +75 -0
- package/src/lib/utils/lsp-type-checker.js +532 -0
- package/src/lib/utils/lsp-type-checker.js.map +1 -0
- package/src/lib/utils/ngp-host-fs.d.ts +43 -0
- package/src/lib/utils/ngp-host-fs.js +128 -0
- package/src/lib/utils/ngp-host-fs.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +15 -8
- package/src/lib/utils/plugin-config.js +19 -7
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/rolldown.js +1 -2
- package/src/lib/utils/safe-module-paths.js +1 -2
- package/src/lib/utils/stylesheet-warning.d.ts +2 -0
- package/src/lib/utils/stylesheet-warning.js +10 -0
- package/src/lib/utils/stylesheet-warning.js.map +1 -0
- package/src/lib/utils/transform-cache.js +1 -2
- package/src/lib/utils/transform-cache.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +2 -3
- package/src/lib/utils/virtual-ids.js +1 -2
- package/src/lib/utils/virtual-resources.js +1 -2
- package/src/lib/utils/virtual-resources.js.map +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +11 -3
- package/src/lib/virtual-modules-plugin.js +70 -15
- package/src/lib/virtual-modules-plugin.js.map +1 -1
|
@@ -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, isAbsolute, resolve } from 'node:path';\nimport { parseSync } from 'oxc-parser';\nimport * as vite from 'vite';\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\n\nimport {\n compile,\n scanFile,\n scanPackageDts,\n collectImportedPackages,\n collectRelativeReExports,\n collectAllImports,\n jitTransform,\n inlineResourceUrls,\n extractInlineStyles,\n generateHmrCode,\n debugCompile,\n debugRegistry,\n ANGULAR_DECORATOR_CALL_RE,\n type ComponentRegistry,\n} from './compiler/index.js';\n\nimport {\n TS_EXT_REGEX,\n getTsConfigPath,\n createDepOptimizerConfig,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\nimport {\n loadVirtualRawModule,\n rewriteHtmlRawImport,\n} from './utils/virtual-resources.js';\nimport { markStylePathSafe } from './utils/safe-module-paths.js';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.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}\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 pluginOptions: FastCompilePluginOptions,\n): Plugin {\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\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 let projectRoot = '';\n let useDefineForClassFields = true;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code =\n fileContents?.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents?.set(file, code);\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: failed to read %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return;\n }\n // Single parse shared by scanFile and collectRelativeReExports. On a\n // parse error each consumer re-parses on its own, preserving their\n // individual failure semantics (scanFile throws past its pre-filter;\n // collectRelativeReExports swallows and returns []).\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseSync(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() {\n if (pluginOptions.jit) return; // JIT: no registry scan needed\n\n // Scan all source files to build the registry\n registry.clear();\n scannedDtsPackages.clear();\n const resolvedTsConfigPath = resolveTsConfigPath();\n projectRoot = dirname(resolvedTsConfigPath);\n const config = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = config.options?.useDefineForClassFields ?? true;\n\n // Collect candidate files: tsconfig rootNames PLUS the entry points\n // named in `compilerOptions.paths`. App tsconfigs typically only\n // include the app's own sources, so workspace library entry barrels\n // (e.g. `HlmSelectImports = [HlmSelect, HlmSelectContent, ...] as\n // const`) live outside `rootNames` and would otherwise miss the\n // initial scan. The compiler then can't see that `HlmSelectImports`\n // is a tuple barrel and emits the bare identifier into the parent\n // 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);\n const tsPaths = config.options?.paths;\n const baseUrl = getPathsBasePath(config.options, projectRoot);\n // Cold-start dedup caches shared by the three scan phases below\n // (candidates scan, walkImports, scanBarrelExports). Scoped to this\n // init call only — HMR/watcher re-scans must hit disk fresh.\n const fileContents = new Map<string, string>();\n const scanResults = new Map<string, ReturnType<typeof scanFile>>();\n if (tsPaths) {\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n // Skip wildcard patterns — entry barrels are normally exact\n // file paths like \"libs/helm/select/src/index.ts\".\n if (target.includes('*')) continue;\n candidates.add(resolve(baseUrl, target));\n }\n }\n }\n const results = await Promise.all(\n Array.from(candidates).map(async (file) => {\n try {\n const code = await fsPromises.readFile(file, 'utf-8');\n fileContents.set(file, code);\n const entries = scanFile(code, file);\n scanResults.set(file, entries);\n return entries;\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'initFastCompile: skipping unreadable %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return []; // Skip unreadable files\n }\n }),\n );\n\n for (const entries of results) {\n for (const entry of entries) {\n registry.set(entry.className, entry);\n }\n }\n\n // Walk the transitive import graph from the root files so the registry also\n // contains declarations that live in files not directly in tsconfig\n // `files`/`include` (transitively-imported app sources) and in workspace\n // libraries reached through wildcard `paths` (e.g. `@bitwarden/*`). Without\n // this, a non-standalone component's owning module can't classify its\n // declarations and `ɵɵsetComponentScope` is never emitted for it. Only\n // relative imports and `paths`-mapped (project/workspace) bare specifiers are\n // followed; true `node_modules` packages are left to the lazy `.d.ts` scanner.\n // Return *all* candidate base paths a bare specifier maps to. A `paths`\n // entry can list several fallback targets (e.g. a built `dist` path first\n // and the workspace `src` second); the caller probes them in order.\n const resolvePathSpecifier = (spec: string): string[] => {\n if (!tsPaths) return [];\n for (const [key, targets] of Object.entries(tsPaths)) {\n const list = targets as string[];\n if (key.endsWith('/*')) {\n const prefix = key.slice(0, -1);\n if (spec.startsWith(prefix)) {\n // `split('*').join(...)` substitutes the single tsconfig `*`\n // wildcard without `String.replace`'s first-match-only behavior or\n // `$`-pattern interpretation of the replacement.\n return list.map((t) =>\n resolve(baseUrl, t.split('*').join(spec.slice(prefix.length))),\n );\n }\n } else if (key === spec) {\n return list.map((t) => resolve(baseUrl, t));\n }\n }\n return [];\n };\n const probeToSource = async (base: string): Promise<string | null> => {\n const candidates = base.endsWith('.ts')\n ? [base]\n : [base + '.ts', resolve(base, 'index.ts')];\n for (const candidate of candidates) {\n try {\n await fsPromises.access(candidate);\n return candidate;\n } catch {\n // try next candidate\n }\n }\n return null;\n };\n // Memoize fs probes per absolute base path. The cache stores the\n // Promise (not the settled value) so concurrent walks racing on the\n // same base collapse into a single probe.\n const baseResolveCache = new Map<string, Promise<string | null>>();\n const resolveToSource = (base: string): Promise<string | null> => {\n let probe = baseResolveCache.get(base);\n if (!probe) {\n probe = probeToSource(base);\n baseResolveCache.set(base, probe);\n }\n return probe;\n };\n // Probe each `paths` target in order; first one that resolves to source wins.\n const resolveFirstSource = async (\n bases: string[],\n ): Promise<string | null> => {\n for (const base of bases) {\n const resolved = await resolveToSource(base);\n if (resolved) return resolved;\n }\n return null;\n };\n const importWalkVisited = new Set<string>();\n // Paths-mapped resolution doesn't depend on the importer, so bare\n // specifiers can be memoized by their raw text. Relative specifiers\n // must NOT be — the same './foo' resolves differently per directory.\n const bareSpecResolveCache = new Map<string, Promise<string | null>>();\n const walkImports = async (file: string): Promise<void> => {\n if (importWalkVisited.has(file)) return;\n importWalkVisited.add(file);\n let code: string;\n try {\n code =\n fileContents.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents.set(file, code);\n } catch {\n return;\n }\n // Single parse shared by scanFile, collectImportedPackages, and\n // collectAllImports. On a parse error each consumer re-parses on\n // its own, preserving their individual failure semantics.\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseSync(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 await Promise.all(config.rootNames.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 ) {\n for (const pkg of collectImportedPackages(code, id, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n\n try {\n const dtsEntries = scanPackageDts(pkg, projectRoot, scannedDtsPackages);\n for (const entry of dtsEntries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\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 // `styleExtensions` carries the source extension of each inlined external\n // style so it can be preprocessed by its own file type (e.g. an external\n // `.scss` styleUrl) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { styleExtensions } = 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 } = parseSync(id, code);\n\n // Pre-resolve inline styles that need preprocessing (SCSS/Sass/Less). Run\n // whenever a style needs a non-`css` preprocessor — either the configured\n // `inlineStylesExtension` for truly-inline styles, or an external styleUrl's\n // own extension.\n let resolvedInlineStyles: Map<number, string> | undefined;\n\n const inlineExt = pluginOptions.inlineStylesExtension;\n const styleNeedsPreprocess = (ext: string) => ext !== '' && ext !== 'css';\n\n if (styleNeedsPreprocess(inlineExt) || styleExtensions.size > 0) {\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n for (let i = 0; i < styleStrings.length; i++) {\n // External styleUrls are preprocessed by their own extension; truly\n // inline `styles: [...]` fall back to `inlineStylesExtension`.\n const ext = styleExtensions.get(i) ?? inlineExt;\n if (!styleNeedsPreprocess(ext)) continue;\n try {\n const fakePath = id.replace(/\\.ts$/, `.inline-${i}.${ext}`);\n const processed = await preprocessCSS(\n styleStrings[i],\n fakePath,\n resolvedConfig,\n );\n resolvedInlineStyles.set(i, processed.code);\n } catch (e) {\n if (debugCompile.enabled) {\n debugCompile(\n 'inline style #%d preprocessing failed in %s: %s',\n i,\n id,\n (e as Error)?.message,\n );\n }\n // Skip styles that can't be preprocessed\n }\n }\n if (resolvedInlineStyles.size === 0) resolvedInlineStyles = undefined;\n }\n }\n\n ensureDtsRegistryForSource(code, id, oxcProgram);\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 let compileRegistry: ComponentRegistry = registry;\n if (componentRegistries.some((external) => external.size > 0)) {\n compileRegistry = new Map(registry);\n for (const external of componentRegistries) {\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 if (watchMode && pluginOptions.liveReload) {\n const fileDeclarations = [...registry.values()].filter(\n (e) => e.fileName === id,\n );\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() {\n const { root, isProd, isLib } = tsConfigResolutionContext!;\n return getTsConfigPath(\n root,\n pluginOptions.tsconfigGetter(),\n isProd,\n pluginOptions.isTest,\n isLib,\n pluginOptions.workspaceRoot,\n );\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-fast-compile',\n api: { getTsConfigPath: resolveTsConfigPath },\n enforce: 'pre' as const,\n async config(config, { command }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\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`, registered once at the\n // `angular()` factory level (which is the only public entry point\n // that wires this plugin in).\n return {\n ...(vite.rolldownVersion ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n const integrations = await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n },\n configureServer(server) {\n // Watch for new .ts files and scan them into the registry. Use\n // the barrel-aware scanner so a newly added re-export entry\n // (`export * from './x'`) also expands its underlying directive\n // classes — otherwise the registry stays stale until restart.\n server.watcher.on('add', async (filePath) => {\n if (\n filePath.endsWith('.ts') &&\n !filePath.endsWith('.spec.ts') &&\n !filePath.endsWith('.d.ts')\n ) {\n await scanBarrelExports(filePath, new Set(), true);\n }\n });\n },\n async buildStart() {\n await initFastCompile();\n },\n closeBundle() {\n if (!watchMode) {\n releaseCssPreprocessorWorkers();\n }\n },\n async handleHotUpdate(ctx) {\n // Resource file changes → invalidate parent .ts module\n if (resourceToSource.has(ctx.file)) {\n const parentSource = resourceToSource.get(ctx.file)!;\n const parentModule = ctx.server.moduleGraph.getModuleById(parentSource);\n if (parentModule) {\n return [parentModule];\n }\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n\n // Remove old entries from this file\n const oldEntries = [...registry.entries()]\n .filter(([_, v]) => v.fileName === fileId)\n .map(([k]) => k);\n for (const key of oldEntries) {\n registry.delete(key);\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\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n if (id.includes(':style')) {\n markStylePathSafe(resolvedConfig, filePath);\n return filePath + '?inline';\n }\n return toVirtualRawId(filePath);\n }\n\n const rawRewrite = rewriteHtmlRawImport(id, importer);\n if (rawRewrite) return rawRewrite;\n\n // User `.scss?inline` / `.css?inline` imports: resolve and mark\n // safe so Vite's native CSS pipeline handles them.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id) && importer) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : normalizePath(resolve(dirname(importer), filePath));\n markStylePathSafe(resolvedConfig, resolved);\n return resolved + '?inline';\n }\n\n return undefined;\n },\n async load(id) {\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Vitest fallback: module-runner can skip resolveId, so the bare\n // ?inline query reaches load. Mark safe and let Vite handle it.\n if (/\\.(css|scss|sass|less)\\?inline$/.test(id)) {\n markStylePathSafe(resolvedConfig, id.split('?')[0]);\n }\n\n return;\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 if (transformFilter && !transformFilter(code, id)) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n return handleFastCompileTransform(code, id);\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,iBACd,SACA,UACQ;CACR,OAAO,SAAS,WAAW,SAAS,iBAAiB;AACvD;AAEA,SAAgB,kBACd,eACQ;CACR,IAAI;CACJ,IAAI;CACJ,IAAI,sBAAkD,CAAC;CACvD,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAGhB,MAAM,2BAA8B,IAAI,IAAI;CAC5C,MAAM,mCAAmB,IAA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ib/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(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,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"}
|
package/src/lib/host.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Logger } from "vite";
|
|
1
2
|
import * as ts from "typescript";
|
|
2
3
|
import { type StylePreprocessor } from "./style-preprocessor.js";
|
|
3
4
|
import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
|
|
@@ -11,6 +12,8 @@ export declare function augmentHostWithResources(host: ts.CompilerHost, transfor
|
|
|
11
12
|
stylesheetRegistry?: AnalogStylesheetRegistry;
|
|
12
13
|
sourceFileCache?: SourceFileCache;
|
|
13
14
|
stylePreprocessor?: StylePreprocessor;
|
|
15
|
+
logger?: Logger;
|
|
16
|
+
isBuild?: boolean;
|
|
14
17
|
}): void;
|
|
15
18
|
export declare function augmentProgramWithVersioning(program: ts.Program): void;
|
|
16
19
|
export declare function augmentHostWithCaching(host: ts.CompilerHost, cache: Map<string, ts.SourceFile>): void;
|
package/src/lib/host.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { debugStyles } from "./utils/debug.js";
|
|
2
|
-
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
|
|
3
1
|
import { normalizeStylesheetDependencies } from "./style-preprocessor.js";
|
|
4
2
|
import { preprocessStylesheetResult, registerStylesheetContent } from "./stylesheet-registry.js";
|
|
3
|
+
import { debugStyles } from "./utils/debug.js";
|
|
4
|
+
import { reportStylesheetError } from "./utils/stylesheet-warning.js";
|
|
5
|
+
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
|
|
5
6
|
import { createHash } from "node:crypto";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { normalizePath } from "vite";
|
|
8
9
|
import * as ts from "typescript";
|
|
9
|
-
|
|
10
|
+
// packages/vite-plugin-angular/src/lib/host.ts
|
|
10
11
|
function augmentHostWithModuleResolution(host, options) {
|
|
11
12
|
const resolutionCache = ts.createModuleResolutionCache(host.getCurrentDirectory(), host.getCanonicalFileName.bind(host), options);
|
|
12
13
|
host.getModuleResolutionCache = () => resolutionCache;
|
|
@@ -80,6 +81,7 @@ function augmentHostWithResources(host, transform, options) {
|
|
|
80
81
|
resourceFile: context.resourceFile ?? "(inline)",
|
|
81
82
|
error: String(e)
|
|
82
83
|
});
|
|
84
|
+
reportStylesheetError(options.logger, filename, e, !!options.isBuild);
|
|
83
85
|
}
|
|
84
86
|
if (!stylesheetResult?.code) return null;
|
|
85
87
|
return { content: stylesheetResult.code };
|
|
@@ -130,7 +132,6 @@ function hasStyleExtension(file) {
|
|
|
130
132
|
default: return false;
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
//#endregion
|
|
134
135
|
export { augmentHostWithCaching, augmentHostWithModuleResolution, augmentHostWithResources, augmentProgramWithVersioning, mergeTransformers };
|
|
135
136
|
|
|
136
137
|
//# sourceMappingURL=host.js.map
|
package/src/lib/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","names":[],"sources":["../../../src/lib/host.ts"],"sourcesContent":["import type { CompilerHost } from '@angular/compiler-cli';\nimport { normalizePath } from 'vite';\n\nimport * as ts from 'typescript';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\nimport {\n normalizeStylesheetDependencies,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n} from './stylesheet-registry.js';\nimport { debugStyles } from './utils/debug.js';\nimport type { SourceFileCache } from './utils/source-file-cache.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\nexport function augmentHostWithModuleResolution(\n host: ts.CompilerHost,\n options: ts.CompilerOptions,\n): void {\n const resolutionCache = ts.createModuleResolutionCache(\n host.getCurrentDirectory(),\n host.getCanonicalFileName.bind(host),\n options,\n );\n host.getModuleResolutionCache = () => resolutionCache;\n host.resolveModuleNameLiterals = (\n literals,\n containingFile,\n redirectedReference,\n compilerOptions,\n containingSourceFile,\n ) =>\n literals.map((literal) => {\n const resolution: ts.ResolvedModuleWithFailedLookupLocations =\n ts.resolveModuleName(\n literal.text,\n containingFile,\n compilerOptions,\n host,\n resolutionCache,\n redirectedReference,\n ts.getModeForUsageLocation(\n containingSourceFile,\n literal,\n compilerOptions,\n ),\n );\n const resolvedModule = resolution.resolvedModule;\n if (\n resolvedModule?.isExternalLibraryImport &&\n TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !EXCLUDED_TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !normalizePath(resolvedModule.resolvedFileName).includes(\n '/node_modules/',\n )\n ) {\n // A workspace symlink resolves to source outside node_modules.\n // Classify it before program creation so TypeScript emits it.\n return {\n ...resolution,\n resolvedModule: {\n ...resolvedModule,\n isExternalLibraryImport: false,\n },\n };\n }\n return resolution;\n });\n}\n\nexport function augmentHostWithResources(\n host: ts.CompilerHost,\n transform: (\n code: string,\n id: string,\n options?: { ssr?: boolean },\n ) => ReturnType<any> | null,\n options: {\n inlineStylesExtension: string;\n isProd?: boolean;\n stylesheetRegistry?: AnalogStylesheetRegistry;\n sourceFileCache?: SourceFileCache;\n stylePreprocessor?: StylePreprocessor;\n },\n): void {\n const resourceHost = host as CompilerHost;\n\n resourceHost.readResource = async function (fileName: string) {\n const filePath = normalizePath(fileName);\n\n const content = (this as any).readFile(filePath);\n\n if (content === undefined) {\n throw new Error('Unable to locate component resource: ' + fileName);\n }\n\n return content;\n };\n\n resourceHost.getModifiedResourceFiles = function () {\n return options?.sourceFileCache?.modifiedFiles;\n };\n\n resourceHost.transformResource = async function (data, context) {\n // Only style resources are supported currently\n if (context.type !== 'style') {\n return null;\n }\n\n const filename =\n context.resourceFile ??\n context.containingFile.replace(\n '.ts',\n `.${options?.inlineStylesExtension}`,\n );\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n options.stylePreprocessor,\n {\n filename,\n containingFile: context.containingFile,\n resourceFile: context.resourceFile ?? undefined,\n className: context.className,\n order: context.order,\n inline: !context.resourceFile,\n },\n );\n\n // Externalized path: store preprocessed CSS for Vite's serve-time pipeline.\n // CSS must NOT be transformed here — the load hook returns it into\n // Vite's transform pipeline where PostCSS / Tailwind process it once.\n if (options.stylesheetRegistry) {\n const stylesheetId = registerStylesheetContent(\n options.stylesheetRegistry,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile: context.containingFile,\n className: context.className,\n order: context.order,\n inlineStylesExtension: options.inlineStylesExtension,\n resourceFile: context.resourceFile ?? undefined,\n },\n );\n debugStyles('NgtscProgram: stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: context.resourceFile ?? '(inline)',\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n });\n return { content: stylesheetId };\n }\n\n // Non-externalized: CSS is returned directly to the Angular compiler\n // and never re-enters Vite's pipeline, so transform eagerly.\n debugStyles('NgtscProgram: stylesheet processed inline via transform', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n let stylesheetResult;\n\n try {\n stylesheetResult = await transform(\n preprocessed.code,\n `${filename}?direct`,\n );\n } catch (e) {\n debugStyles('NgtscProgram: stylesheet transform error', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n if (!stylesheetResult?.code) {\n return null;\n }\n\n return { content: stylesheetResult.code };\n };\n\n resourceHost.resourceNameToFileName = function (\n resourceName,\n containingFile,\n fallbackResolve,\n ) {\n // Angular's fallbackResolve callback expects (resourceUrl, containingFile),\n // NOT (directory, resourceName). Use it correctly or fall back to\n // path.join for simple relative paths.\n let resolved: string | null = null;\n if (fallbackResolve) {\n resolved = fallbackResolve(path.dirname(containingFile), resourceName);\n }\n const resolvedPath = normalizePath(\n resolved ?? path.join(path.dirname(containingFile), resourceName),\n );\n\n // All resource names that have template file extensions are assumed to be templates\n if (!options.stylesheetRegistry || !hasStyleExtension(resolvedPath)) {\n return resolvedPath;\n }\n\n // Register the hash-based external mapping so the resolveId hook can\n // resolve Angular's compiled stylesheet references back to the source.\n const externalId = createHash('sha256').update(resolvedPath).digest('hex');\n const filename = externalId + path.extname(resolvedPath);\n\n options.stylesheetRegistry.registerExternalRequest(filename, resolvedPath);\n debugStyles('NgtscProgram: external stylesheet ID mapped for resolveId', {\n resourceName,\n resolvedPath,\n filename,\n });\n\n // Return the real path so Angular can read the file during analysis.\n // Previously, returning the hash-based filename caused \"Could not find\n // stylesheet file\" errors because the hash doesn't exist on disk,\n // preventing AOT compilation for any component with styleUrls. (#2293)\n return resolvedPath;\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] =\n baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n file.version ??= createHash('sha256').update(file.text).digest('hex');\n }\n\n return files;\n };\n}\n\nexport function augmentHostWithCaching(\n host: ts.CompilerHost,\n cache: Map<string, ts.SourceFile>,\n): void {\n const baseGetSourceFile = host.getSourceFile;\n host.getSourceFile = function (\n fileName,\n languageVersion,\n onError,\n shouldCreateNewSourceFile,\n ...parameters\n ) {\n if (!shouldCreateNewSourceFile && cache.has(fileName)) {\n return cache.get(fileName);\n }\n\n const file = baseGetSourceFile.call(\n host,\n fileName,\n languageVersion,\n onError,\n true,\n ...parameters,\n );\n\n if (file) {\n cache.set(fileName, file);\n }\n\n return file;\n };\n}\n\nexport function mergeTransformers(\n first: ts.CustomTransformers,\n second: ts.CustomTransformers,\n): ts.CustomTransformers {\n const result: ts.CustomTransformers = {};\n\n if (first.before || second.before) {\n result.before = [...(first.before || []), ...(second.before || [])];\n }\n\n if (first.after || second.after) {\n result.after = [...(first.after || []), ...(second.after || [])];\n }\n\n if (first.afterDeclarations || second.afterDeclarations) {\n result.afterDeclarations = [\n ...(first.afterDeclarations || []),\n ...(second.afterDeclarations || []),\n ];\n }\n\n return result;\n}\n\nfunction hasStyleExtension(file: string): boolean {\n const extension = path.extname(file).toLowerCase();\n\n switch (extension) {\n case '.css':\n case '.scss':\n return true;\n default:\n return false;\n }\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,gCACd,MACA,SACM;CACN,MAAM,kBAAkB,GAAG,4BACzB,KAAK,oBAAoB,GACzB,KAAK,qBAAqB,KAAK,IAAI,GACnC,OACF;CACA,KAAK,iCAAiC;CACtC,KAAK,6BACH,UACA,gBACA,qBACA,iBACA,yBAEA,SAAS,KAAK,YAAY;EACxB,MAAM,aACJ,GAAG,kBACD,QAAQ,MACR,gBACA,iBACA,MACA,iBACA,qBACA,GAAG,wBACD,sBACA,SACA,eACF,CACF;EACF,MAAM,iBAAiB,WAAW;EAClC,IACE,gBAAgB,2BAChB,aAAa,KAAK,eAAe,gBAAgB,KACjD,CAAC,sBAAsB,KAAK,eAAe,gBAAgB,KAC3D,CAAC,cAAc,eAAe,gBAAgB,CAAC,CAAC,SAC9C,gBACF,GAIA,OAAO;GACL,GAAG;GACH,gBAAgB;IACd,GAAG;IACH,yBAAyB;GAC3B;EACF;EAEF,OAAO;CACT,CAAC;AACL;AAEA,SAAgB,yBACd,MACA,WAKA,SAOM;CACN,MAAM,eAAe;CAErB,aAAa,eAAe,eAAgB,UAAkB;EAC5D,MAAM,WAAW,cAAc,QAAQ;EAEvC,MAAM,UAAW,KAAa,SAAS,QAAQ;EAE/C,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,0CAA0C,QAAQ;EAGpE,OAAO;CACT;CAEA,aAAa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AAO,QAAQ,CAAC,GAAI,MAAM,SAAS,CAAC,GAAI,GAAI,OAAO,SAAS,CAAC,CAAE;CAGjE,IAAI,MAAM,qBAAqB,OAAO,mBACpC,OAAO,oBAAoB,CACzB,GAAI,MAAM,qBAAqB,CAAC,GAChC,GAAI,OAAO,qBAAqB,CAAC,CACnC;CAGF,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAuB;CAGhD,QAFkB,KAAK,QAAQ,IAAI,CAAC,CAAC,YAE7B,GAAR;EACE,KAAK;EACL,KAAK,SACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
|
|
1
|
+
{"version":3,"file":"host.js","names":[],"sources":["../../../src/lib/host.ts"],"sourcesContent":["import type { CompilerHost } from '@angular/compiler-cli';\nimport { normalizePath, type Logger } from 'vite';\n\nimport * as ts from 'typescript';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\nimport {\n normalizeStylesheetDependencies,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n} from './stylesheet-registry.js';\nimport { debugStyles } from './utils/debug.js';\nimport { reportStylesheetError } from './utils/stylesheet-warning.js';\nimport type { SourceFileCache } from './utils/source-file-cache.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\nexport function augmentHostWithModuleResolution(\n host: ts.CompilerHost,\n options: ts.CompilerOptions,\n): void {\n const resolutionCache = ts.createModuleResolutionCache(\n host.getCurrentDirectory(),\n host.getCanonicalFileName.bind(host),\n options,\n );\n host.getModuleResolutionCache = () => resolutionCache;\n host.resolveModuleNameLiterals = (\n literals,\n containingFile,\n redirectedReference,\n compilerOptions,\n containingSourceFile,\n ) =>\n literals.map((literal) => {\n const resolution: ts.ResolvedModuleWithFailedLookupLocations =\n ts.resolveModuleName(\n literal.text,\n containingFile,\n compilerOptions,\n host,\n resolutionCache,\n redirectedReference,\n ts.getModeForUsageLocation(\n containingSourceFile,\n literal,\n compilerOptions,\n ),\n );\n const resolvedModule = resolution.resolvedModule;\n if (\n resolvedModule?.isExternalLibraryImport &&\n TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !EXCLUDED_TS_EXT_REGEX.test(resolvedModule.resolvedFileName) &&\n !normalizePath(resolvedModule.resolvedFileName).includes(\n '/node_modules/',\n )\n ) {\n // A workspace symlink resolves to source outside node_modules.\n // Classify it before program creation so TypeScript emits it.\n return {\n ...resolution,\n resolvedModule: {\n ...resolvedModule,\n isExternalLibraryImport: false,\n },\n };\n }\n return resolution;\n });\n}\n\nexport function augmentHostWithResources(\n host: ts.CompilerHost,\n transform: (\n code: string,\n id: string,\n options?: { ssr?: boolean },\n ) => ReturnType<any> | null,\n options: {\n inlineStylesExtension: string;\n isProd?: boolean;\n stylesheetRegistry?: AnalogStylesheetRegistry;\n sourceFileCache?: SourceFileCache;\n stylePreprocessor?: StylePreprocessor;\n logger?: Logger;\n isBuild?: boolean;\n },\n): void {\n const resourceHost = host as CompilerHost;\n\n resourceHost.readResource = async function (fileName: string) {\n const filePath = normalizePath(fileName);\n\n const content = (this as any).readFile(filePath);\n\n if (content === undefined) {\n throw new Error('Unable to locate component resource: ' + fileName);\n }\n\n return content;\n };\n\n resourceHost.getModifiedResourceFiles = function () {\n return options?.sourceFileCache?.modifiedFiles;\n };\n\n resourceHost.transformResource = async function (data, context) {\n // Only style resources are supported currently\n if (context.type !== 'style') {\n return null;\n }\n\n const filename =\n context.resourceFile ??\n context.containingFile.replace(\n '.ts',\n `.${options?.inlineStylesExtension}`,\n );\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n options.stylePreprocessor,\n {\n filename,\n containingFile: context.containingFile,\n resourceFile: context.resourceFile ?? undefined,\n className: context.className,\n order: context.order,\n inline: !context.resourceFile,\n },\n );\n\n // Externalized path: store preprocessed CSS for Vite's serve-time pipeline.\n // CSS must NOT be transformed here — the load hook returns it into\n // Vite's transform pipeline where PostCSS / Tailwind process it once.\n if (options.stylesheetRegistry) {\n const stylesheetId = registerStylesheetContent(\n options.stylesheetRegistry,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile: context.containingFile,\n className: context.className,\n order: context.order,\n inlineStylesExtension: options.inlineStylesExtension,\n resourceFile: context.resourceFile ?? undefined,\n },\n );\n debugStyles('NgtscProgram: stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: context.resourceFile ?? '(inline)',\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n });\n return { content: stylesheetId };\n }\n\n // Non-externalized: CSS is returned directly to the Angular compiler\n // and never re-enters Vite's pipeline, so transform eagerly.\n debugStyles('NgtscProgram: stylesheet processed inline via transform', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n let stylesheetResult;\n\n try {\n stylesheetResult = await transform(\n preprocessed.code,\n `${filename}?direct`,\n );\n } catch (e) {\n debugStyles('NgtscProgram: stylesheet transform error', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n error: String(e),\n });\n reportStylesheetError(options.logger, filename, e, !!options.isBuild);\n }\n\n if (!stylesheetResult?.code) {\n return null;\n }\n\n return { content: stylesheetResult.code };\n };\n\n resourceHost.resourceNameToFileName = function (\n resourceName,\n containingFile,\n fallbackResolve,\n ) {\n // Angular's fallbackResolve callback expects (resourceUrl, containingFile),\n // NOT (directory, resourceName). Use it correctly or fall back to\n // path.join for simple relative paths.\n let resolved: string | null = null;\n if (fallbackResolve) {\n resolved = fallbackResolve(path.dirname(containingFile), resourceName);\n }\n const resolvedPath = normalizePath(\n resolved ?? path.join(path.dirname(containingFile), resourceName),\n );\n\n // All resource names that have template file extensions are assumed to be templates\n if (!options.stylesheetRegistry || !hasStyleExtension(resolvedPath)) {\n return resolvedPath;\n }\n\n // Register the hash-based external mapping so the resolveId hook can\n // resolve Angular's compiled stylesheet references back to the source.\n const externalId = createHash('sha256').update(resolvedPath).digest('hex');\n const filename = externalId + path.extname(resolvedPath);\n\n options.stylesheetRegistry.registerExternalRequest(filename, resolvedPath);\n debugStyles('NgtscProgram: external stylesheet ID mapped for resolveId', {\n resourceName,\n resolvedPath,\n filename,\n });\n\n // Return the real path so Angular can read the file during analysis.\n // Previously, returning the hash-based filename caused \"Could not find\n // stylesheet file\" errors because the hash doesn't exist on disk,\n // preventing AOT compilation for any component with styleUrls. (#2293)\n return resolvedPath;\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] =\n baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n file.version ??= createHash('sha256').update(file.text).digest('hex');\n }\n\n return files;\n };\n}\n\nexport function augmentHostWithCaching(\n host: ts.CompilerHost,\n cache: Map<string, ts.SourceFile>,\n): void {\n const baseGetSourceFile = host.getSourceFile;\n host.getSourceFile = function (\n fileName,\n languageVersion,\n onError,\n shouldCreateNewSourceFile,\n ...parameters\n ) {\n if (!shouldCreateNewSourceFile && cache.has(fileName)) {\n return cache.get(fileName);\n }\n\n const file = baseGetSourceFile.call(\n host,\n fileName,\n languageVersion,\n onError,\n true,\n ...parameters,\n );\n\n if (file) {\n cache.set(fileName, file);\n }\n\n return file;\n };\n}\n\nexport function mergeTransformers(\n first: ts.CustomTransformers,\n second: ts.CustomTransformers,\n): ts.CustomTransformers {\n const result: ts.CustomTransformers = {};\n\n if (first.before || second.before) {\n result.before = [...(first.before || []), ...(second.before || [])];\n }\n\n if (first.after || second.after) {\n result.after = [...(first.after || []), ...(second.after || [])];\n }\n\n if (first.afterDeclarations || second.afterDeclarations) {\n result.afterDeclarations = [\n ...(first.afterDeclarations || []),\n ...(second.afterDeclarations || []),\n ];\n }\n\n return result;\n}\n\nfunction hasStyleExtension(file: string): boolean {\n const extension = path.extname(file).toLowerCase();\n\n switch (extension) {\n case '.css':\n case '.scss':\n return true;\n default:\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;AAqBA,SAAgB,gCACd,MACA,SACM;CACN,MAAM,kBAAkB,GAAG,4BACzB,KAAK,oBAAoB,GACzB,KAAK,qBAAqB,KAAK,IAAI,GACnC,OACF;CACA,KAAK,iCAAiC;CACtC,KAAK,6BACH,UACA,gBACA,qBACA,iBACA,yBAEA,SAAS,KAAK,YAAY;EACxB,MAAM,aACJ,GAAG,kBACD,QAAQ,MACR,gBACA,iBACA,MACA,iBACA,qBACA,GAAG,wBACD,sBACA,SACA,eACF,CACF;EACF,MAAM,iBAAiB,WAAW;EAClC,IACE,gBAAgB,2BAChB,aAAa,KAAK,eAAe,gBAAgB,KACjD,CAAC,sBAAsB,KAAK,eAAe,gBAAgB,KAC3D,CAAC,cAAc,eAAe,gBAAgB,CAAC,CAAC,SAC9C,gBACF,GAIA,OAAO;GACL,GAAG;GACH,gBAAgB;IACd,GAAG;IACH,yBAAyB;GAC3B;EACF;EAEF,OAAO;CACT,CAAC;AACL;AAEA,SAAgB,yBACd,MACA,WAKA,SASM;CACN,MAAM,eAAe;CAErB,aAAa,eAAe,eAAgB,UAAkB;EAC5D,MAAM,WAAW,cAAc,QAAQ;EAEvC,MAAM,UAAW,KAAa,SAAS,QAAQ;EAE/C,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,0CAA0C,QAAQ;EAGpE,OAAO;CACT;CAEA,aAAa,2BAA2B,WAAY;EAClD,OAAO,SAAS,iBAAiB;CACnC;CAEA,aAAa,oBAAoB,eAAgB,MAAM,SAAS;EAE9D,IAAI,QAAQ,SAAS,SACnB,OAAO;EAGT,MAAM,WACJ,QAAQ,gBACR,QAAQ,eAAe,QACrB,OACA,IAAI,SAAS,uBACf;EACF,MAAM,eAAe,2BACnB,MACA,UACA,QAAQ,mBACR;GACE;GACA,gBAAgB,QAAQ;GACxB,cAAc,QAAQ,gBAA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AS,kBAAkB,MAAuB;CAGhD,QAFkB,KAAK,QAAQ,IAAI,CAAC,CAAC,YAE7B,GAAR;EACE,KAAK;EACL,KAAK,SACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizePath } from "vite";
|
|
2
|
-
|
|
2
|
+
// packages/vite-plugin-angular/src/lib/hot-update-batch.ts
|
|
3
3
|
var HOT_UPDATE_DEBOUNCE_MS = 100;
|
|
4
4
|
function createHotUpdateBatcher(compile) {
|
|
5
5
|
let scheduledBatch;
|
|
@@ -170,7 +170,6 @@ function createHotUpdateNotifications(hasPendingCompilations) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
//#endregion
|
|
174
173
|
export { createHotUpdateBatcher };
|
|
175
174
|
|
|
176
175
|
//# sourceMappingURL=hot-update-batch.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
|
+
import { type AngularBuildContext } from "./angular-build-context.js";
|
|
2
3
|
import { EmitFileResult } from "./models.js";
|
|
3
|
-
export
|
|
4
|
+
export interface ComponentUpdates {
|
|
4
5
|
classNames: Map<string, string>;
|
|
5
|
-
fileEmitter: (file: string) => EmitFileResult | undefined;
|
|
6
|
-
|
|
6
|
+
fileEmitter: (file: string, className: string) => Pick<EmitFileResult, "hmrUpdateCode"> | undefined;
|
|
7
|
+
rootDir?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function liveReloadPlugin(ctxOrUpdates?: AngularBuildContext | ComponentUpdates): Plugin;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import { isAngularBuildContext } from "./angular-build-context.js";
|
|
1
2
|
import { debugHmr } from "./utils/debug.js";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { normalizePath } from "vite";
|
|
4
|
-
|
|
5
|
+
// packages/vite-plugin-angular/src/lib/live-reload-plugin.ts
|
|
5
6
|
var ANGULAR_COMPONENT_PREFIX = "/@ng/component";
|
|
6
7
|
var FILE_PREFIX = "file:";
|
|
7
|
-
function liveReloadPlugin(
|
|
8
|
+
function liveReloadPlugin(ctxOrUpdates) {
|
|
9
|
+
const updates = isAngularBuildContext(ctxOrUpdates) ? ctxOrUpdates.hmr : ctxOrUpdates ?? {
|
|
10
|
+
classNames: /* @__PURE__ */ new Map(),
|
|
11
|
+
fileEmitter: () => void 0
|
|
12
|
+
};
|
|
13
|
+
const resolveFileId = (fileId) => normalizePath(resolve(updates.rootDir ?? process.cwd(), fileId));
|
|
8
14
|
return {
|
|
9
15
|
name: "analogjs-live-reload-plugin",
|
|
10
16
|
apply: "serve",
|
|
@@ -25,16 +31,16 @@ function liveReloadPlugin({ classNames, fileEmitter }) {
|
|
|
25
31
|
res.end();
|
|
26
32
|
return;
|
|
27
33
|
}
|
|
28
|
-
const [fileId] = decodeURIComponent(componentId).split("@");
|
|
29
|
-
const resolvedId =
|
|
30
|
-
if (!(!!server.moduleGraph.getModuleById(resolvedId)?.lastInvalidationTimestamp && classNames.get(resolvedId))) {
|
|
34
|
+
const [fileId, className] = decodeURIComponent(componentId).split("@");
|
|
35
|
+
const resolvedId = resolveFileId(fileId);
|
|
36
|
+
if (!(!!server.moduleGraph.getModuleById(resolvedId)?.lastInvalidationTimestamp && updates.classNames.get(resolvedId))) {
|
|
31
37
|
debugHmr("middleware: skipped (not invalidated)", { resolvedId });
|
|
32
38
|
res.setHeader("Content-Type", "text/javascript");
|
|
33
39
|
res.setHeader("Cache-Control", "no-cache");
|
|
34
40
|
res.end("");
|
|
35
41
|
return;
|
|
36
42
|
}
|
|
37
|
-
const result = fileEmitter(resolvedId);
|
|
43
|
+
const result = updates.fileEmitter(resolvedId, className);
|
|
38
44
|
debugHmr("middleware: served component update", {
|
|
39
45
|
resolvedId,
|
|
40
46
|
hasCode: !!result?.hmrUpdateCode
|
|
@@ -52,12 +58,12 @@ function liveReloadPlugin({ classNames, fileEmitter }) {
|
|
|
52
58
|
if (options?.ssr && id.includes(ANGULAR_COMPONENT_PREFIX)) {
|
|
53
59
|
const componentId = new URL(id.slice(1), "http://localhost").searchParams.get("c");
|
|
54
60
|
if (!componentId) return;
|
|
55
|
-
|
|
61
|
+
const [fileId, className] = decodeURIComponent(componentId).split("@");
|
|
62
|
+
return updates.fileEmitter(resolveFileId(fileId), className)?.hmrUpdateCode || "";
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
};
|
|
59
66
|
}
|
|
60
|
-
//#endregion
|
|
61
67
|
export { liveReloadPlugin };
|
|
62
68
|
|
|
63
69
|
//# sourceMappingURL=live-reload-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-reload-plugin.js","names":[],"sources":["../../../src/lib/live-reload-plugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { ServerResponse } from 'node:http';\nimport { Connect, normalizePath, Plugin, ViteDevServer } from 'vite';\n\nimport { EmitFileResult } from './models.js';\nimport { debugHmr } from './utils/debug.js';\n\nconst ANGULAR_COMPONENT_PREFIX = '/@ng/component';\nconst FILE_PREFIX = 'file:';\n\nexport
|
|
1
|
+
{"version":3,"file":"live-reload-plugin.js","names":[],"sources":["../../../src/lib/live-reload-plugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { ServerResponse } from 'node:http';\nimport { Connect, normalizePath, Plugin, ViteDevServer } from 'vite';\n\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { EmitFileResult } from './models.js';\nimport { debugHmr } from './utils/debug.js';\n\nconst ANGULAR_COMPONENT_PREFIX = '/@ng/component';\nconst FILE_PREFIX = 'file:';\n\nexport interface ComponentUpdates {\n classNames: Map<string, string>;\n fileEmitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined;\n rootDir?: string;\n}\n\nexport function liveReloadPlugin(\n ctxOrUpdates?: AngularBuildContext | ComponentUpdates,\n): Plugin {\n const updates: ComponentUpdates = isAngularBuildContext(ctxOrUpdates)\n ? ctxOrUpdates.hmr\n : (ctxOrUpdates ?? {\n classNames: new Map<string, string>(),\n fileEmitter: () => undefined,\n });\n\n const resolveFileId = (fileId: string): string =>\n normalizePath(resolve(updates.rootDir ?? process.cwd(), fileId));\n\n return {\n name: 'analogjs-live-reload-plugin',\n apply: 'serve',\n configureServer(server: ViteDevServer) {\n if (server.config.server.hmr === false) {\n debugHmr('middleware disabled: vite server.hmr is false');\n return;\n }\n\n const angularComponentMiddleware: Connect.HandleFunction = async (\n req: Connect.IncomingMessage,\n res: ServerResponse<Connect.IncomingMessage>,\n next: Connect.NextFunction,\n ) => {\n if (req.url === undefined || res.writableEnded) {\n return;\n }\n\n if (!req.url.includes(ANGULAR_COMPONENT_PREFIX)) {\n next();\n\n return;\n }\n\n const requestUrl = new URL(req.url, 'http://localhost');\n const componentId = requestUrl.searchParams.get('c');\n\n if (!componentId) {\n res.statusCode = 400;\n res.end();\n\n return;\n }\n\n const [fileId, className] = decodeURIComponent(componentId).split('@');\n const resolvedId = resolveFileId(fileId);\n const invalidated =\n !!server.moduleGraph.getModuleById(resolvedId)\n ?.lastInvalidationTimestamp && updates.classNames.get(resolvedId);\n\n // don't send an HMR update until the file has been invalidated\n if (!invalidated) {\n debugHmr('middleware: skipped (not invalidated)', { resolvedId });\n res.setHeader('Content-Type', 'text/javascript');\n res.setHeader('Cache-Control', 'no-cache');\n res.end('');\n return;\n }\n\n const result = updates.fileEmitter(resolvedId, className);\n debugHmr('middleware: served component update', {\n resolvedId,\n hasCode: !!result?.hmrUpdateCode,\n });\n res.setHeader('Content-Type', 'text/javascript');\n res.setHeader('Cache-Control', 'no-cache');\n res.end(`${result?.hmrUpdateCode || ''}`);\n };\n\n server.middlewares.use(angularComponentMiddleware);\n },\n resolveId(id, _importer, options) {\n if (\n options?.ssr &&\n id.startsWith(FILE_PREFIX) &&\n id.includes(ANGULAR_COMPONENT_PREFIX)\n ) {\n return `\\0${id}`;\n }\n\n return undefined;\n },\n load(id, options) {\n if (options?.ssr && id.includes(ANGULAR_COMPONENT_PREFIX)) {\n const requestUrl = new URL(id.slice(1), 'http://localhost');\n const componentId = requestUrl.searchParams.get('c');\n\n if (!componentId) {\n return;\n }\n\n const [fileId, className] = decodeURIComponent(componentId).split('@');\n const result = updates.fileEmitter(resolveFileId(fileId), className);\n\n return result?.hmrUpdateCode || '';\n }\n\n return;\n },\n };\n}\n"],"mappings":";;;;;AAWA,IAAM,2BAA2B;AACjC,IAAM,cAAc;AAWpB,SAAgB,iBACd,cACQ;CACR,MAAM,UAA4B,sBAAsB,YAAY,IAChE,aAAa,MACZ,gBAAgB;EACf,4BAAY,IAAI,IAAoB;EACpC,mBAAmB,KAAA;CACrB;CAEJ,MAAM,iBAAiB,WACrB,cAAc,QAAQ,QAAQ,WAAW,QAAQ,IAAI,GAAG,MAAM,CAAC;CAEjE,OAAO;EACL,MAAM;EACN,OAAO;EACP,gBAAgB,QAAuB;GACrC,IAAI,OAAO,OAAO,OAAO,QAAQ,OAAO;IACtC,SAAS,+CAA+C;IACxD;GACF;GAEA,MAAM,6BAAqD,OACzD,KACA,KACA,SACG;IACH,IAAI,IAAI,QAAQ,KAAA,KAAa,IAAI,eAC/B;IAGF,IAAI,CAAC,IAAI,IAAI,SAAS,wBAAwB,GAAG;KAC/C,KAAK;KAEL;IACF;IAGA,MAAM,cAAc,IADG,IAAI,IAAI,KAAK,kBAChB,CAAA,CAAW,aAAa,IAAI,GAAG;IAEnD,IAAI,CAAC,aAAa;KAChB,IAAI,aAAa;KACjB,IAAI,IAAI;KAER;IACF;IAEA,MAAM,CAAC,QAAQ,aAAa,mBAAmB,WAAW,CAAC,CAAC,MAAM,GAAG;IACrE,MAAM,aAAa,cAAc,MAAM;IAMvC,IAAI,EAJF,CAAC,CAAC,OAAO,YAAY,cAAc,UAAU,CAAC,EAC1C,6BAA6B,QAAQ,WAAW,IAAI,UAAU,IAGlD;KAChB,SAAS,yCAAyC,EAAE,WAAW,CAAC;KAChE,IAAI,UAAU,gBAAgB,iBAAiB;KAC/C,IAAI,UAAU,iBAAiB,UAAU;KACzC,IAAI,IAAI,EAAE;KACV;IACF;IAEA,MAAM,SAAS,QAAQ,YAAY,YAAY,SAAS;IACxD,SAAS,uCAAuC;KAC9C;KACA,SAAS,CAAC,CAAC,QAAQ;IACrB,CAAC;IACD,IAAI,UAAU,gBAAgB,iBAAiB;IAC/C,IAAI,UAAU,iBAAiB,UAAU;IACzC,IAAI,IAAI,GAAG,QAAQ,iBAAiB,IAAI;GAC1C;GAEA,OAAO,YAAY,IAAI,0BAA0B;EACnD;EACA,UAAU,IAAI,WAAW,SAAS;GAChC,IACE,SAAS,OACT,GAAG,WAAW,WAAW,KACzB,GAAG,SAAS,wBAAwB,GAEpC,OAAO,KAAK;EAIhB;EACA,KAAK,IAAI,SAAS;GAChB,IAAI,SAAS,OAAO,GAAG,SAAS,wBAAwB,GAAG;IAEzD,MAAM,cAAc,IADG,IAAI,GAAG,MAAM,CAAC,GAAG,kBACpB,CAAA,CAAW,aAAa,IAAI,GAAG;IAEnD,IAAI,CAAC,aACH;IAGF,MAAM,CAAC,QAAQ,aAAa,mBAAmB,WAAW,CAAC,CAAC,MAAM,GAAG;IAGrE,OAFe,QAAQ,YAAY,cAAc,MAAM,GAAG,SAEnD,CAAA,EAAQ,iBAAiB;GAClC;EAGF;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, moduleSpecifier?: string, containingFile?: 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,11 @@
|
|
|
1
|
+
// 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
|
+
export { findNgpCompileApi };
|
|
10
|
+
|
|
11
|
+
//# 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(\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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as vite from "vite";
|
|
2
|
+
import { type AngularBuildContext, type AngularBuildContextOptions } from "./angular-build-context.js";
|
|
3
|
+
import type { FastCompilePluginOptions } from "./fast-compile-plugin.js";
|
|
4
|
+
export declare function ngpCompilePlugin(optionsOrCtx?: AngularBuildContext | FastCompilePluginOptions | AngularBuildContextOptions): vite.Plugin;
|