@analogjs/vite-plugin-angular 3.0.0-beta.38 → 3.0.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/analog-plugin-interop.js +1 -1
- package/src/lib/angular-build-context.d.ts +215 -0
- package/src/lib/angular-build-context.js +361 -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 +4 -2
- 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 +14 -6
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +6 -124
- package/src/lib/angular-vite-plugin.js +8 -1276
- 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 +5 -3
- 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 +38 -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 +154 -285
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/component-styles-plugin.d.ts +52 -0
- package/src/lib/component-styles-plugin.js +353 -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 +31 -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 +23 -0
- package/src/lib/dev-server-mode-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +3 -1
- package/src/lib/fast-compile-plugin.js +93 -49
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.js +3 -3
- package/src/lib/live-reload-plugin.d.ts +3 -1
- package/src/lib/live-reload-plugin.js +11 -5
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-plugin.d.ts +2 -1
- package/src/lib/ngp-compile-plugin.js +90 -24
- package/src/lib/ngp-compile-plugin.js.map +1 -1
- package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
- package/src/lib/ngtsc-compile-plugin.js +762 -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 +12 -7
- 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 +1 -0
- 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 +13 -4
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +1 -1
- package/src/lib/utils/devkit.js +1 -1
- package/src/lib/utils/lsp-type-checker.js +1 -1
- package/src/lib/utils/plugin-config.d.ts +6 -8
- package/src/lib/utils/plugin-config.js +8 -4
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +11 -3
- package/src/lib/virtual-modules-plugin.js +43 -12
- 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 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 compile,\n scanFile,\n declaresNonStandaloneComponent,\n scanPackageDts,\n collectImportedPackages,\n collectRelativeReExports,\n collectReExports,\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';\nimport { warnStylesheetError } from './utils/stylesheet-warning.js';\n\nimport {\n TS_EXT_REGEX,\n EXCLUDED_TS_EXT_REGEX,\n getTsConfigPath,\n createDepOptimizerConfig,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { 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 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';\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}\n\ntype ResolveImport = (spec: string, importer: string) => Promise<string | null>;\n\n/**\n * Directory that `compilerOptions.paths` targets resolve against. Mirrors\n * TypeScript: `baseUrl` when set, otherwise the directory of the config\n * that declares `paths` (`pathsBasePath`, since `baseUrl` is optional\n * from TS 4.1).\n */\nexport function getPathsBasePath(\n options: { baseUrl?: string; pathsBasePath?: string } | undefined,\n fallback: string,\n): string {\n return options?.baseUrl ?? options?.pathsBasePath ?? fallback;\n}\n\nexport function fastCompilePlugin(\n pluginOptions: FastCompilePluginOptions,\n): Plugin {\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // fast-compile plugin state\n const registry: ComponentRegistry = new Map();\n const resourceToSource = new Map<string, string>();\n const scannedDtsPackages = new Set<string>();\n let projectRoot = '';\n let useDefineForClassFields = true;\n let tsConfig: ReturnType<typeof compilerCli.readConfiguration>;\n\n // Files scanned on demand (mapped to the barrel chain they pulled in), which\n // modules were compiled against each scanned file, and the one-time\n // whole-project scan non-standalone components fall back to.\n const lazyScans = new Map<string, Promise<Set<string>>>();\n const importersByFile = new Map<string, Set<string>>();\n let projectScan: Promise<void> | undefined;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code =\n fileContents?.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents?.set(file, code);\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: failed to read %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return;\n }\n // Single parse shared by scanFile and collectRelativeReExports. On a\n // parse error each consumer re-parses on its own, preserving their\n // individual failure semantics (scanFile throws past its pre-filter;\n // collectRelativeReExports swallows and returns []).\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults?.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults?.set(file, entries);\n }\n for (const entry of entries) {\n // At buildStart we want stable registry entries (don't overwrite\n // an earlier scan with a barrel re-scan); HMR explicitly asks\n // for overwrite so updated metadata replaces stale entries.\n if (overwrite || !registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n // Collect every relative re-export specifier via OXC AST so\n // recursive scans can't trip over each other (a shared `/g` regex\n // would have its `lastIndex` reset by each recursive call and\n // silently skip half of an outer barrel's re-exports, which\n // previously left directives like `HlmRadioGroup` unregistered).\n const dir = dirname(file);\n for (const rel of collectRelativeReExports(code, file, program)) {\n // NodeNext-style libraries write `export * from './foo.js'`\n // even though the source is `./foo.ts`. Strip the ESM\n // extension before probing or the candidates would be\n // `foo.js.ts` / `foo.js/index.ts`, which never exist.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const reExportCandidates = [\n resolve(dir, normalizedRel + '.ts'),\n resolve(dir, normalizedRel, 'index.ts'),\n ];\n let resolved = false;\n for (const candidate of reExportCandidates) {\n try {\n await fsPromises.access(candidate);\n await scanBarrelExports(\n candidate,\n visited,\n overwrite,\n fileContents,\n scanResults,\n );\n resolved = true;\n break;\n } catch {\n // try next candidate\n }\n }\n if (!resolved && debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: %s re-export %s did not resolve to %o',\n file,\n rel,\n reExportCandidates,\n );\n }\n }\n }\n\n async function initFastCompile() {\n if (pluginOptions.jit) return; // JIT: no registry scan needed\n\n registry.clear();\n scannedDtsPackages.clear();\n lazyScans.clear();\n importersByFile.clear();\n projectScan = undefined;\n const resolvedTsConfigPath = resolveTsConfigPath();\n projectRoot = dirname(resolvedTsConfigPath);\n tsConfig = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = tsConfig.options?.useDefineForClassFields ?? true;\n }\n\n /** Scan all source files reachable from the tsconfig into the registry. */\n async function scanProject() {\n const config = tsConfig;\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 = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults.set(file, entries);\n }\n for (const entry of entries) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n // Pre-scan the `.d.ts` of every external package this file imports (and,\n // transitively, packages those packages' NgModules re-export — e.g.\n // BrowserModule → CommonModule → NgIf). Doing this at buildStart means the\n // registry is complete before any component transforms, so non-standalone\n // component scope resolves regardless of file transform order.\n for (const pkg of collectImportedPackages(code, file, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n try {\n for (const entry of scanPackageDts(\n pkg,\n projectRoot,\n scannedDtsPackages,\n )) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n const dir = dirname(file);\n const targets = await Promise.all(\n collectAllImports(code, file, program).map((spec) => {\n if (spec.startsWith('.')) {\n return resolveToSource(\n resolve(dir, spec.replace(/\\.(?:js|mjs)$/u, '')),\n );\n }\n let resolved = bareSpecResolveCache.get(spec);\n if (!resolved) {\n resolved = resolveFirstSource(resolvePathSpecifier(spec));\n bareSpecResolveCache.set(spec, resolved);\n }\n return resolved;\n }),\n );\n await Promise.all(\n targets.filter((t): t is string => !!t).map((t) => walkImports(t)),\n );\n };\n 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 /**\n * Scan the source files `id` imports into the registry on demand and record\n * `id` as their importer, so a metadata change in any of them recompiles it.\n */\n async function resolveImportedDeclarations(\n code: string,\n id: string,\n program: ReturnType<typeof parseSync>['program'],\n resolveImport: ResolveImport,\n ) {\n await Promise.all(\n collectAllImports(code, id, program).map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await scanOnDemand(file, resolveImport)) {\n let importers = importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n function scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = lazyScans.get(file);\n if (!scan) {\n scan = scanWithReExports(file, resolveImport);\n lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n async function scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: ReturnType<typeof parseSync>['program'];\n try {\n code = await fsPromises.readFile(current, 'utf-8');\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n\n function registryEntriesOf(file: string) {\n return [...registry.values()].filter((e) => e.fileName === file);\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\n resolveImport: ResolveImport,\n ): Promise<{ code: string; map: any } | undefined> {\n if (!ANGULAR_DECORATOR_CALL_RE.test(code)) {\n // Non-Angular file — strip TS-only syntax ourselves so barrels\n // like `export { Foo, type Bar } from './x'` and other TS-only\n // forms don't leak unstripped to Rolldown. In rolldown-vite the\n // built-in `vite:oxc` strip is registered as a Rust-side native\n // plugin (`viteTransformPlugin` from `rolldown/experimental`); if\n // its hook-filter treats files our `transform.filter.id.include`\n // claimed as already-handled, no JS-side fallback runs and raw\n // TS reaches the parser → `SyntaxError: Unexpected identifier`.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(code, id, {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n })\n : await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n sourcemap: true,\n });\n return { code: stripped.code, map: stripped.map };\n }\n\n // JIT mode\n if (pluginOptions.jit) {\n const result = jitTransform(code, id);\n // Strip TypeScript-only syntax (e.g. `readonly`, parameter property\n // modifiers, type annotations on fields) so the output is valid JS\n // for Rolldown. `angularVitestSourcemapPlugin` normally runs this\n // strip downstream in tests, but it is intentionally skipped on\n // StackBlitz / WebContainer — and the production build pipeline\n // does not register it either — so the JIT path must self-strip\n // to stay safe across environments.\n //\n // Pass the jitTransform map as `inMap` so OXC/esbuild emit a map\n // composed with the original `.ts` source — without this, debug\n // stack traces and breakpoints land on the wrong lines once the\n // strip removes any TS-only token. `jitTransform` returns\n // `map: null` for files with no Angular class (no edits made);\n // passing that to OXC/esbuild as `inMap` throws, so coerce to\n // `undefined` in that case.\n const inMap = result.map ?? undefined;\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n inMap,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n inMap,\n );\n return { code: stripped.code, map: stripped.map };\n }\n\n // Inline external templateUrl/styleUrl(s) into the source before compilation.\n // `stylePaths` carries the source path of each inlined external style so\n // it is preprocessed as its own file (e.g. an external `.scss` styleUrl or\n // a relative `@import`) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { stylePaths } = inlined;\n\n // Track inlined resources for HMR. `compile()` only reports resources it\n // reads through its own fallback (a templateUrl/styleUrl the inliner did\n // NOT already inline), so files inlined here must be recorded here or a\n // later edit to them never invalidates the owning module.\n for (const dep of inlined.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Single OXC parse of the post-inline source, shared by every AST\n // consumer below. `inlineResourceUrls` parsed the PRE-inline string,\n // so its program can never be reused here.\n const { program: oxcProgram } = parseOxc(id, code);\n\n // Pre-resolve component styles through the registered style preprocessor\n // and Vite's CSS pipeline (Sass/Less, PostCSS, Tailwind), like ngtsc does.\n // External styleUrls are processed as their own file; truly inline\n // `styles: [...]` use `inlineStylesExtension`.\n let resolvedInlineStyles: Map<number, string> | undefined;\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n for (let i = 0; i < styleStrings.length; i++) {\n const stylePath =\n stylePaths.get(i) ??\n id.replace(\n /\\.ts$/,\n `.inline-${i}.${pluginOptions.inlineStylesExtension || 'css'}`,\n );\n try {\n const preprocessed = preprocessStylesheet(\n styleStrings[i],\n stylePath,\n stylePreprocessor,\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 resolvedConfig,\n );\n resolvedInlineStyles.set(i, processed.code);\n } catch (e) {\n warnStylesheetError(resolvedConfig.logger, stylePath, e);\n }\n }\n if (resolvedInlineStyles.size === 0) resolvedInlineStyles = undefined;\n }\n\n ensureDtsRegistryForSource(code, id, oxcProgram);\n\n for (const entry of scanFile(code, id, oxcProgram)) {\n registry.set(entry.className, entry);\n }\n await resolveImportedDeclarations(code, id, oxcProgram, resolveImport);\n if (declaresNonStandaloneComponent(oxcProgram)) {\n projectScan ??= scanProject();\n await projectScan;\n }\n\n // Merge registries contributed through `analog.setup()` into this\n // compile's lookup view. Out-of-tree compilers register directive\n // metadata for classes fastCompile can't reach through its\n // tsconfig-driven scan (e.g. `.tsrx` files compiled by `@tsrx/analog`).\n // Without this merge, a TS `@Component({ imports: [X] })` that\n // references such a class hits `_unresolved-${className}` as its\n // selector and the tag never matches at runtime.\n 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 = registryEntriesOf(id);\n if (fileDeclarations.length > 0) {\n const localDepClassNames = fileDeclarations.map((e) => e.className);\n outputCode += generateHmrCode(fileDeclarations, localDepClassNames);\n }\n }\n\n return { code: outputCode, map: stripped.map };\n }\n\n function resolveTsConfigPath() {\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 stylePreprocessor = integrations.stylePreprocessor;\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 = registryEntriesOf(fileId);\n for (const entry of oldEntries) {\n registry.delete(entry.className);\n }\n\n // Rescan the changed file via the barrel-aware scanner so an\n // edited barrel re-export picks up newly-referenced files.\n // Pass overwrite=true so updated metadata replaces stale\n // entries from the previous scan.\n await scanBarrelExports(fileId, new Set(), true);\n\n // Importers compiled the old selector/inputs/outputs into their\n // templates, so recompile them when this file's metadata changed.\n // Cached scans that pulled in this file may now be incomplete.\n lazyScans.clear();\n const metadataChanged =\n JSON.stringify(oldEntries) !==\n JSON.stringify(registryEntriesOf(fileId));\n if (metadataChanged) {\n const importerModules = [\n ...(importersByFile.get(fileId) ?? []),\n ].flatMap((importer) => [\n ...(ctx.server.moduleGraph.getModulesByFile(importer) ?? []),\n ]);\n return [...ctx.modules, ...importerModules];\n }\n }\n\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n 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, async (spec, importer) => {\n const resolved = await this.resolve(spec, importer, {\n skipSelf: true,\n });\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n // Package declarations come from the lazy `.d.ts` scanner instead.\n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ugin.js","names":[],"sources":["../../../src/lib/fast-compile-plugin.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { parseSync } from 'oxc-parser';\nimport { parseOxc } from './compiler/utils.js';\nimport * as vite from 'vite';\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { normalizePath, Plugin, preprocessCSS, ResolvedConfig } from 'vite';\n\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport {\n compile,\n scanFile,\n declaresNonStandaloneComponent,\n scanPackageDts,\n collectImportedPackages,\n collectRelativeReExports,\n collectReExports,\n collectAllImports,\n jitTransform,\n inlineResourceUrls,\n extractInlineStyles,\n generateHmrCode,\n debugRegistry,\n ANGULAR_DECORATOR_CALL_RE,\n type ComponentRegistry,\n} from './compiler/index.js';\nimport { warnStylesheetError } from './utils/stylesheet-warning.js';\n\nimport {\n TS_EXT_REGEX,\n EXCLUDED_TS_EXT_REGEX,\n getTsConfigPath,\n createDepOptimizerConfig,\n isProdMode,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport { TsconfigResolver } from './utils/tsconfig-resolver.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { TypeCheckerOption } from './utils/lsp-type-checker.js';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\nexport interface FastCompilePluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n fastCompileMode?: 'full' | 'partial';\n disableTypeChecking?: boolean;\n typeChecker?: TypeCheckerOption;\n include?: string[];\n}\n\nfunction isFastCompilePluginOptions(\n value: unknown,\n): value is FastCompilePluginOptions {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isAngularBuildContext(value) &&\n 'tsconfigGetter' in value &&\n typeof (value as FastCompilePluginOptions).tsconfigGetter === 'function'\n );\n}\n\ntype ResolveImport = (spec: string, importer: string) => Promise<string | null>;\n\n/**\n * Directory that `compilerOptions.paths` targets resolve against. Mirrors\n * TypeScript: `baseUrl` when set, otherwise the directory of the config\n * that declares `paths` (`pathsBasePath`, since `baseUrl` is optional\n * from TS 4.1).\n */\nexport function getPathsBasePath(\n options: { baseUrl?: string; pathsBasePath?: string } | undefined,\n fallback: string,\n): string {\n return options?.baseUrl ?? options?.pathsBasePath ?? fallback;\n}\n\nexport function fastCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompilePluginOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n ...optionsOrCtx,\n compilationBackend: 'fast',\n });\n\n const pluginOptions: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n const tsconfigResolver =\n sharedCtx?.tsconfigResolver ??\n new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include ?? [],\n liveReload: pluginOptions.liveReload,\n isTest: pluginOptions.isTest,\n });\n\n let resolvedConfig: ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n\n // fast-compile plugin state\n const registry: ComponentRegistry = new Map();\n const resourceToSource = new Map<string, string>();\n const scannedDtsPackages = new Set<string>();\n const emittedMaps = new Map<string, string>();\n let projectRoot = '';\n let useDefineForClassFields = true;\n let tsConfig: ReturnType<typeof compilerCli.readConfiguration>;\n\n // Files scanned on demand (mapped to the barrel chain they pulled in), which\n // modules were compiled against each scanned file, and the one-time\n // whole-project scan non-standalone components fall back to.\n const lazyScans = new Map<string, Promise<Set<string>>>();\n const importersByFile = new Map<string, Set<string>>();\n let projectScan: Promise<void> | undefined;\n\n /**\n * Scan a file into the registry, then recursively walk its relative\n * `export *` / `export { … } from './x'` chain so any underlying\n * directive classes also land in the registry. Used both at\n * `buildStart` (for tsconfig path entries) and at dev time (file\n * `add` and `handleHotUpdate`) so newly added barrels stay in sync\n * without requiring a server restart.\n *\n * The `visited` set prevents infinite recursion within a single\n * top-level call. Each fresh scan should pass an empty set (so HMR\n * re-scans aren't blocked by buildStart's earlier visits).\n *\n * `fileContents`/`scanResults` are cold-start dedup caches scoped to a\n * single `initFastCompile` call. HMR/watcher callers must omit them so\n * an edited file is always re-read from disk.\n */\n async function scanBarrelExports(\n file: string,\n visited: Set<string> = new Set(),\n overwrite = false,\n fileContents?: Map<string, string>,\n scanResults?: Map<string, ReturnType<typeof scanFile>>,\n ): Promise<void> {\n if (visited.has(file)) return;\n visited.add(file);\n let code: string;\n try {\n code =\n fileContents?.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents?.set(file, code);\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: failed to read %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return;\n }\n // Single parse shared by scanFile and collectRelativeReExports. On a\n // parse error each consumer re-parses on its own, preserving their\n // individual failure semantics (scanFile throws past its pre-filter;\n // collectRelativeReExports swallows and returns []).\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults?.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults?.set(file, entries);\n }\n for (const entry of entries) {\n // At buildStart we want stable registry entries (don't overwrite\n // an earlier scan with a barrel re-scan); HMR explicitly asks\n // for overwrite so updated metadata replaces stale entries.\n if (overwrite || !registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n // Collect every relative re-export specifier via OXC AST so\n // recursive scans can't trip over each other (a shared `/g` regex\n // would have its `lastIndex` reset by each recursive call and\n // silently skip half of an outer barrel's re-exports, which\n // previously left directives like `HlmRadioGroup` unregistered).\n const dir = dirname(file);\n for (const rel of collectRelativeReExports(code, file, program)) {\n // NodeNext-style libraries write `export * from './foo.js'`\n // even though the source is `./foo.ts`. Strip the ESM\n // extension before probing or the candidates would be\n // `foo.js.ts` / `foo.js/index.ts`, which never exist.\n const normalizedRel = rel.replace(/\\.(?:js|mjs)$/u, '');\n const reExportCandidates = [\n resolve(dir, normalizedRel + '.ts'),\n resolve(dir, normalizedRel, 'index.ts'),\n ];\n let resolved = false;\n for (const candidate of reExportCandidates) {\n try {\n await fsPromises.access(candidate);\n await scanBarrelExports(\n candidate,\n visited,\n overwrite,\n fileContents,\n scanResults,\n );\n resolved = true;\n break;\n } catch {\n // try next candidate\n }\n }\n if (!resolved && debugRegistry.enabled) {\n debugRegistry(\n 'scanBarrelExports: %s re-export %s did not resolve to %o',\n file,\n rel,\n reExportCandidates,\n );\n }\n }\n }\n\n async function initFastCompile(): Promise<void> {\n emittedMaps.clear();\n if (pluginOptions.jit) return; // JIT: no registry scan needed\n\n registry.clear();\n scannedDtsPackages.clear();\n lazyScans.clear();\n importersByFile.clear();\n projectScan = undefined;\n const resolvedTsConfigPath = resolveTsConfigPath();\n projectRoot = dirname(resolvedTsConfigPath);\n tsConfig = compilerCli.readConfiguration(resolvedTsConfigPath);\n useDefineForClassFields = tsConfig.options?.useDefineForClassFields ?? true;\n }\n\n /** Scan all source files reachable from the tsconfig into the registry. */\n async function scanProject(): Promise<void> {\n const config = tsConfig;\n const extraIncludes = tsconfigResolver.ensureIncludeCache();\n // Collect candidate files: tsconfig rootNames PLUS explicit/integration\n // include globs PLUS the entry points named in `compilerOptions.paths`.\n // App tsconfigs typically only include the app's own sources, so workspace\n // library entry barrels (e.g. `HlmSelectImports = [HlmSelect,\n // HlmSelectContent, ...] as const`) live outside `rootNames` and would\n // otherwise miss the initial scan. The compiler then can't see that\n // `HlmSelectImports` is a tuple barrel and emits the bare identifier into\n // the parent component's `dependencies()` list, where Angular's runtime\n // silently drops it because arrays don't have a directive def.\n const candidates = new Set<string>([...config.rootNames, ...extraIncludes]);\n const tsPaths = config.options?.paths;\n const baseUrl = getPathsBasePath(config.options, projectRoot);\n // Cold-start dedup caches shared by the three scan phases below\n // (candidates scan, walkImports, scanBarrelExports). Scoped to this\n // init call only — HMR/watcher re-scans must hit disk fresh.\n const fileContents = new Map<string, string>();\n const scanResults = new Map<string, ReturnType<typeof scanFile>>();\n if (tsPaths) {\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n // Skip wildcard patterns — entry barrels are normally exact\n // file paths like \"libs/helm/select/src/index.ts\".\n if (target.includes('*')) continue;\n candidates.add(resolve(baseUrl, target));\n }\n }\n }\n const results = await Promise.all(\n Array.from(candidates).map(async (file) => {\n try {\n const code = await fsPromises.readFile(file, 'utf-8');\n fileContents.set(file, code);\n const entries = scanFile(code, file);\n scanResults.set(file, entries);\n return entries;\n } catch (e) {\n if (debugRegistry.enabled) {\n debugRegistry(\n 'initFastCompile: skipping unreadable %s: %s',\n file,\n (e as Error)?.message,\n );\n }\n return []; // Skip unreadable files\n }\n }),\n );\n\n for (const entries of results) {\n for (const entry of entries) {\n registry.set(entry.className, entry);\n }\n }\n\n // Walk the transitive import graph from the root files so the registry also\n // contains declarations that live in files not directly in tsconfig\n // `files`/`include` (transitively-imported app sources) and in workspace\n // libraries reached through wildcard `paths` (e.g. `@bitwarden/*`). Without\n // this, a non-standalone component's owning module can't classify its\n // declarations and `ɵɵsetComponentScope` is never emitted for it. Only\n // relative imports and `paths`-mapped (project/workspace) bare specifiers are\n // followed; true `node_modules` packages are left to the lazy `.d.ts` scanner.\n // Return *all* candidate base paths a bare specifier maps to. A `paths`\n // entry can list several fallback targets (e.g. a built `dist` path first\n // and the workspace `src` second); the caller probes them in order.\n const resolvePathSpecifier = (spec: string): string[] => {\n if (!tsPaths) return [];\n for (const [key, targets] of Object.entries(tsPaths)) {\n const list = targets as string[];\n if (key.endsWith('/*')) {\n const prefix = key.slice(0, -1);\n if (spec.startsWith(prefix)) {\n // `split('*').join(...)` substitutes the single tsconfig `*`\n // wildcard without `String.replace`'s first-match-only behavior or\n // `$`-pattern interpretation of the replacement.\n return list.map((t) =>\n resolve(baseUrl, t.split('*').join(spec.slice(prefix.length))),\n );\n }\n } else if (key === spec) {\n return list.map((t) => resolve(baseUrl, t));\n }\n }\n return [];\n };\n const probeToSource = async (base: string): Promise<string | null> => {\n const candidates = base.endsWith('.ts')\n ? [base]\n : [base + '.ts', resolve(base, 'index.ts')];\n for (const candidate of candidates) {\n try {\n await fsPromises.access(candidate);\n return candidate;\n } catch {\n // try next candidate\n }\n }\n return null;\n };\n // Memoize fs probes per absolute base path. The cache stores the\n // Promise (not the settled value) so concurrent walks racing on the\n // same base collapse into a single probe.\n const baseResolveCache = new Map<string, Promise<string | null>>();\n const resolveToSource = (base: string): Promise<string | null> => {\n let probe = baseResolveCache.get(base);\n if (!probe) {\n probe = probeToSource(base);\n baseResolveCache.set(base, probe);\n }\n return probe;\n };\n // Probe each `paths` target in order; first one that resolves to source wins.\n const resolveFirstSource = async (\n bases: string[],\n ): Promise<string | null> => {\n for (const base of bases) {\n const resolved = await resolveToSource(base);\n if (resolved) return resolved;\n }\n return null;\n };\n const importWalkVisited = new Set<string>();\n // Paths-mapped resolution doesn't depend on the importer, so bare\n // specifiers can be memoized by their raw text. Relative specifiers\n // must NOT be — the same './foo' resolves differently per directory.\n const bareSpecResolveCache = new Map<string, Promise<string | null>>();\n const walkImports = async (file: string): Promise<void> => {\n if (importWalkVisited.has(file)) return;\n importWalkVisited.add(file);\n let code: string;\n try {\n code =\n fileContents.get(file) ?? (await fsPromises.readFile(file, 'utf-8'));\n fileContents.set(file, code);\n } catch {\n return;\n }\n // Single parse shared by scanFile, collectImportedPackages, and\n // collectAllImports. On a parse error each consumer re-parses on\n // its own, preserving their individual failure semantics.\n let program: ReturnType<typeof parseSync>['program'] | undefined;\n try {\n program = parseOxc(file, code).program;\n } catch {\n program = undefined;\n }\n let entries = scanResults.get(file);\n if (!entries) {\n entries = scanFile(code, file, program);\n scanResults.set(file, entries);\n }\n for (const entry of entries) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n // Pre-scan the `.d.ts` of every external package this file imports (and,\n // transitively, packages those packages' NgModules re-export — e.g.\n // BrowserModule → CommonModule → NgIf). Doing this at buildStart means the\n // registry is complete before any component transforms, so non-standalone\n // component scope resolves regardless of file transform order.\n for (const pkg of collectImportedPackages(code, file, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n try {\n for (const entry of scanPackageDts(\n pkg,\n projectRoot,\n scannedDtsPackages,\n )) {\n if (!registry.has(entry.className))\n registry.set(entry.className, entry);\n }\n } catch {\n // Package may not have .d.ts or not be Angular\n }\n }\n const dir = dirname(file);\n const targets = await Promise.all(\n collectAllImports(code, file, program).map((spec) => {\n if (spec.startsWith('.')) {\n return resolveToSource(\n resolve(dir, spec.replace(/\\.(?:js|mjs)$/u, '')),\n );\n }\n let resolved = bareSpecResolveCache.get(spec);\n if (!resolved) {\n resolved = resolveFirstSource(resolvePathSpecifier(spec));\n bareSpecResolveCache.set(spec, resolved);\n }\n return resolved;\n }),\n );\n await Promise.all(\n targets.filter((t): t is string => !!t).map((t) => walkImports(t)),\n );\n };\n const walkRoots = [...new Set([...config.rootNames, ...extraIncludes])];\n await Promise.all(walkRoots.map((file) => walkImports(file)));\n\n // Library barrels typically `export * from './lib/...'` rather than\n // declaring directives directly, so the entry file alone gives us\n // the tuple consts but not the directive classes they reference.\n // Walk the relative `export *` chain so the underlying classes also\n // land in the registry. Use a SHARED visited set across all\n // barrels so recursive walks don't double-scan a file that's\n // re-exported from multiple entry points.\n const buildStartVisited = new Set<string>();\n if (tsPaths) {\n const barrelCandidates: string[] = [];\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n if (target.includes('*')) continue;\n barrelCandidates.push(resolve(baseUrl, target));\n }\n }\n await Promise.all(\n barrelCandidates.map((c) =>\n scanBarrelExports(\n c,\n buildStartVisited,\n false,\n fileContents,\n scanResults,\n ),\n ),\n );\n }\n debugRegistry(\n 'initFastCompile done: %d entries from %d candidate files',\n registry.size,\n candidates.size,\n );\n }\n\n function ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: ReturnType<typeof parseSync>['program'],\n ): void {\n for (const pkg of collectImportedPackages(code, id, program)) {\n if (scannedDtsPackages.has(pkg)) continue;\n scannedDtsPackages.add(pkg);\n\n try {\n const dtsEntries = scanPackageDts(pkg, projectRoot, scannedDtsPackages);\n for (const entry of dtsEntries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n /**\n * Scan the source files `id` imports into the registry on demand and record\n * `id` as their importer, so a metadata change in any of them recompiles it.\n */\n async function resolveImportedDeclarations(\n code: string,\n id: string,\n program: ReturnType<typeof parseSync>['program'],\n resolveImport: ResolveImport,\n ): Promise<void> {\n await Promise.all(\n collectAllImports(code, id, program).map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await scanOnDemand(file, resolveImport)) {\n let importers = importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n function scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = lazyScans.get(file);\n if (!scan) {\n scan = scanWithReExports(file, resolveImport);\n lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n async function scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: ReturnType<typeof parseSync>['program'];\n try {\n code = await fsPromises.readFile(current, 'utf-8');\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n if (!registry.has(entry.className)) {\n registry.set(entry.className, entry);\n }\n }\n ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n\n function registryEntriesOf(file: string) {\n return [...registry.values()].filter((e) => e.fileName === file);\n }\n\n async function handleFastCompileTransform(\n code: string,\n id: string,\n resolveImport: ResolveImport,\n ): Promise<{ code: string; map: any } | undefined> {\n if (!ANGULAR_DECORATOR_CALL_RE.test(code)) {\n // Non-Angular file — strip TS-only syntax ourselves so barrels\n // like `export { Foo, type Bar } from './x'` and other TS-only\n // forms don't leak unstripped to Rolldown. In rolldown-vite the\n // built-in `vite:oxc` strip is registered as a Rust-side native\n // plugin (`viteTransformPlugin` from `rolldown/experimental`); if\n // its hook-filter treats files our `transform.filter.id.include`\n // claimed as already-handled, no JS-side fallback runs and raw\n // TS reaches the parser → `SyntaxError: Unexpected identifier`.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(code, id, {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n })\n : await vite.transformWithEsbuild(code, id, {\n loader: 'ts',\n sourcemap: true,\n });\n return { code: stripped.code, map: stripped.map };\n }\n\n // JIT mode\n if (pluginOptions.jit) {\n const result = jitTransform(code, id);\n // Strip TypeScript-only syntax (e.g. `readonly`, parameter property\n // modifiers, type annotations on fields) so the output is valid JS\n // for Rolldown. `angularVitestSourcemapPlugin` normally runs this\n // strip downstream in tests, but it is intentionally skipped on\n // StackBlitz / WebContainer — and the production build pipeline\n // does not register it either — so the JIT path must self-strip\n // to stay safe across environments.\n //\n // Pass the jitTransform map as `inMap` so OXC/esbuild emit a map\n // composed with the original `.ts` source — without this, debug\n // stack traces and breakpoints land on the wrong lines once the\n // strip removes any TS-only token. `jitTransform` returns\n // `map: null` for files with no Angular class (no edits made);\n // passing that to OXC/esbuild as `inMap` throws, so coerce to\n // `undefined` in that case.\n const inMap = result.map ?? undefined;\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n inMap,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n inMap,\n );\n return { code: stripped.code, map: stripped.map };\n }\n\n // Inline external templateUrl/styleUrl(s) into the source before compilation.\n // `stylePaths` carries the source path of each inlined external style so\n // it is preprocessed as its own file (e.g. an external `.scss` styleUrl or\n // a relative `@import`) regardless of the `inlineStylesExtension` option.\n const inlined = await inlineResourceUrls(code, id);\n code = inlined.code;\n const { stylePaths } = inlined;\n\n // Track inlined resources for HMR. `compile()` only reports resources it\n // reads through its own fallback (a templateUrl/styleUrl the inliner did\n // NOT already inline), so files inlined here must be recorded here or a\n // later edit to them never invalidates the owning module.\n for (const dep of inlined.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Single OXC parse of the post-inline source, shared by every AST\n // consumer below. `inlineResourceUrls` parsed the PRE-inline string,\n // so its program can never be reused here.\n const { program: oxcProgram } = parseOxc(id, code);\n\n // Pre-resolve component styles through the registered style preprocessor\n // and Vite's CSS pipeline (Sass/Less, PostCSS, Tailwind), like ngtsc does.\n // External styleUrls are processed as their own file; truly inline\n // `styles: [...]` use `inlineStylesExtension`.\n let resolvedInlineStyles: Map<number, string> | undefined;\n const styleStrings = extractInlineStyles(code, id, oxcProgram);\n\n if (styleStrings.length > 0) {\n resolvedInlineStyles = new Map();\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n for (let i = 0; i < styleStrings.length; i++) {\n const stylePath =\n stylePaths.get(i) ??\n id.replace(\n /\\.ts$/,\n `.inline-${i}.${pluginOptions.inlineStylesExtension || 'css'}`,\n );\n try {\n const preprocessed = preprocessStylesheet(\n styleStrings[i],\n stylePath,\n activeStylePreprocessor,\n {\n filename: stylePath,\n containingFile: id,\n order: i,\n inline: !stylePaths.has(i),\n },\n );\n const processed = await preprocessCSS(\n preprocessed,\n stylePath,\n activeConfig,\n );\n resolvedInlineStyles.set(i, processed.code);\n } catch (e) {\n warnStylesheetError(activeConfig?.logger, stylePath, e);\n }\n }\n if (resolvedInlineStyles.size === 0) resolvedInlineStyles = undefined;\n }\n\n ensureDtsRegistryForSource(code, id, oxcProgram);\n\n for (const entry of scanFile(code, id, oxcProgram)) {\n registry.set(entry.className, entry);\n }\n await resolveImportedDeclarations(code, id, oxcProgram, resolveImport);\n if (declaresNonStandaloneComponent(oxcProgram)) {\n projectScan ??= scanProject();\n await projectScan;\n }\n\n // Merge registries contributed through `analog.setup()` into this\n // compile's lookup view. Out-of-tree compilers register directive\n // metadata for classes fastCompile can't reach through its\n // tsconfig-driven scan (e.g. `.tsrx` files compiled by `@tsrx/analog`).\n // Without this merge, a TS `@Component({ imports: [X] })` that\n // references such a class hits `_unresolved-${className}` as its\n // selector and the tag never matches at runtime.\n const activeComponentRegistries = sharedCtx\n ? sharedCtx.componentRegistries\n : componentRegistries;\n let compileRegistry: ComponentRegistry = registry;\n if (activeComponentRegistries.some((external) => external.size > 0)) {\n compileRegistry = new Map(registry);\n for (const external of activeComponentRegistries) {\n for (const [k, v] of external) compileRegistry.set(k, v);\n }\n }\n\n const result = compile(code, id, {\n registry: compileRegistry,\n resolvedInlineStyles,\n useDefineForClassFields,\n compilationMode: pluginOptions.fastCompileMode,\n oxcProgram,\n });\n\n // Track resource dependencies for HMR\n for (const dep of result.resourceDependencies) {\n resourceToSource.set(dep, id);\n }\n\n // Strip TypeScript-only syntax and compose the compiler map with the\n // final generated code so downstream breakpoints map back to the source.\n const stripped = vite.transformWithOxc\n ? await vite.transformWithOxc(\n result.code,\n id,\n {\n lang: 'ts',\n sourcemap: true,\n decorator: { legacy: false, emitDecoratorMetadata: false },\n },\n result.map,\n )\n : await vite.transformWithEsbuild(\n result.code,\n id,\n { loader: 'ts', sourcemap: true },\n result.map,\n );\n let outputCode = stripped.code;\n\n // Append HMR code in dev mode\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (activeWatchMode && pluginOptions.liveReload) {\n const fileDeclarations = registryEntriesOf(id);\n if (fileDeclarations.length > 0) {\n const localDepClassNames = fileDeclarations.map((e) => e.className);\n outputCode += generateHmrCode(fileDeclarations, localDepClassNames);\n }\n }\n\n return { code: outputCode, map: stripped.map };\n }\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const resolution = tsConfigResolutionContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n resolution.root,\n pluginOptions.tsconfigGetter(),\n resolution.isProd,\n pluginOptions.isTest,\n resolution.isLib,\n pluginOptions.workspaceRoot,\n );\n }\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(normalizePath(id)),\n hasEmitted: (id: string): boolean => emittedMaps.has(normalizePath(id)),\n };\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-fast-compile',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n return {\n name: '@analogjs/vite-plugin-angular-fast-compile',\n api: compilerApi,\n enforce: 'pre' as const,\n async config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n }\n\n const preliminaryTsConfigPath = resolveTsConfigPath();\n\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: preliminaryTsConfigPath,\n isProd,\n jit: pluginOptions.jit,\n watchMode,\n isTest: pluginOptions.isTest,\n isAstroIntegration: pluginOptions.isAstroIntegration,\n });\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`.\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n if (sharedCtx) {\n const integrations = await sharedCtx.resolveConfig(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n } else {\n const integrations = await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n }\n },\n async buildStart() {\n await initFastCompile();\n },\n closeBundle() {\n const activeWatchMode = sharedCtx ? sharedCtx.watchMode : watchMode;\n if (!activeWatchMode) {\n emittedMaps.clear();\n releaseCssPreprocessorWorkers();\n }\n },\n async handleHotUpdate(ctx) {\n if (\n sharedCtx\n ? sharedCtx.hmr.isIgnoredFile(ctx.file)\n : isIgnoredHmrFile(ctx.file)\n ) {\n return [];\n }\n\n // Resource file changes → invalidate parent .ts module\n if (resourceToSource.has(ctx.file)) {\n const parentSource = resourceToSource.get(ctx.file)!;\n const parentModule = ctx.server.moduleGraph.getModuleById(parentSource);\n if (parentModule) {\n return [parentModule];\n }\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n\n // Remove old entries from this file\n const oldEntries = registryEntriesOf(fileId);\n for (const entry of oldEntries) {\n registry.delete(entry.className);\n }\n\n // Rescan the changed file via the barrel-aware scanner so an\n // edited barrel re-export picks up newly-referenced files.\n // Pass overwrite=true so updated metadata replaces stale\n // entries from the previous scan.\n await scanBarrelExports(fileId, new Set(), true);\n\n // Importers compiled the old selector/inputs/outputs into their\n // templates, so recompile them when this file's metadata changed.\n // Cached scans that pulled in this file may now be incomplete.\n lazyScans.clear();\n const metadataChanged =\n JSON.stringify(oldEntries) !==\n JSON.stringify(registryEntriesOf(fileId));\n if (metadataChanged) {\n const importerModules = [\n ...(importersByFile.get(fileId) ?? []),\n ].flatMap((importer) => [\n ...(ctx.server.moduleGraph.getModulesByFile(importer) ?? []),\n ]);\n return [...ctx.modules, ...importerModules];\n }\n }\n\n // Let Vite handle the rest — the transform hook will recompile\n return ctx.modules;\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: pluginOptions.jit,\n resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? resolvedConfig,\n );\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n // `?raw` ids already carry Vite's native raw-loader output\n // (`export default \"<source>\"`). Recompiling them as Angular/TS\n // would strip that default export, so leave them to Vite (#2356).\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n if (activeTransformFilter && !activeTransformFilter(code, id)) {\n return;\n }\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n const transformed = await handleFastCompileTransform(\n code,\n id,\n async (spec, importer) => {\n const resolved = await this.resolve(spec, importer, {\n skipSelf: true,\n });\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n // Package declarations come from the lazy `.d.ts` scanner instead.\n return TS_EXT_REGEX.test(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n },\n );\n if (transformed?.map) {\n emittedMaps.set(\n normalizePath(id),\n typeof transformed.map === 'string'\n ? transformed.map\n : JSON.stringify(transformed.map),\n );\n }\n return transformed;\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAS,2BACP,OACmC;CACnC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,sBAAsB,KAAK,KAC5B,oBAAoB,SACpB,OAAQ,MAAmC,mBAAmB;AAElE;;;;;;;AAUA,SAAgB,iBACd,SACA,UACQ;CACR,OAAO,SAAS,WAAW,SAAS,iBAAiB;AACvD;AAEA,SAAgB,kBACd,cAIQ;CACR,MAAM,YAAY,sBAAsB,YAAY,IAChD,eACA,2BAA2B,YAAY,IACrC,KAAA,IACA,0BAA0B;EACxB,GAAG;EACH,oBAAoB;CACtB,CAAC;CAEP,MAAM,gBAA0C,YAC5C,UAAU,UACT;CAEL,MAAM,mBACJ,WAAW,oBACX,IAAI,iBAAiB;EACnB,eAAe,cAAc;EAC7B,SAAS,cAAc,WAAW,CAAC;EACnC,YAAY,cAAc;EAC1B,QAAQ,cAAc;CACxB,CAAC;CAEH,IAAI;CACJ,IAAI;CACJ,IAAI,sBAAkD,CAAC;CACvD,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAGhB,MAAM,2BAA8B,IAAI,IAAI;CAC5C,MAAM,mCAAmB,IAAI,IAAoB;CACjD,MAA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ACf,YAAY,IACV,cAAc,EAAE,GAChB,OAAO,YAAY,QAAQ,WACvB,YAAY,MACZ,KAAK,UAAU,YAAY,GAAG,CACpC;IAEF,OAAO;GACT;EACF;CACF;AACF"}
|
package/src/lib/host.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { debugStyles } from "./utils/debug.js";
|
|
2
|
-
import { warnStylesheetError } from "./utils/stylesheet-warning.js";
|
|
3
|
-
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
|
|
4
1
|
import { normalizeStylesheetDependencies } from "./style-preprocessor.js";
|
|
2
|
+
import { debugStyles } from "./utils/debug.js";
|
|
5
3
|
import { preprocessStylesheetResult, registerStylesheetContent } from "./stylesheet-registry.js";
|
|
4
|
+
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
|
|
5
|
+
import { warnStylesheetError } from "./utils/stylesheet-warning.js";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { normalizePath } from "vite";
|
|
@@ -1,7 +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
4
|
export interface ComponentUpdates {
|
|
4
5
|
classNames: Map<string, string>;
|
|
5
6
|
fileEmitter: (file: string, className: string) => Pick<EmitFileResult, "hmrUpdateCode"> | undefined;
|
|
7
|
+
rootDir?: string;
|
|
6
8
|
}
|
|
7
|
-
export declare function liveReloadPlugin(
|
|
9
|
+
export declare function liveReloadPlugin(ctxOrUpdates?: AngularBuildContext | ComponentUpdates): Plugin;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { debugHmr } from "./utils/debug.js";
|
|
2
|
+
import { isAngularBuildContext } from "./angular-build-context.js";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { normalizePath } from "vite";
|
|
4
5
|
//#region 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",
|
|
@@ -26,15 +32,15 @@ function liveReloadPlugin({ classNames, fileEmitter }) {
|
|
|
26
32
|
return;
|
|
27
33
|
}
|
|
28
34
|
const [fileId, className] = decodeURIComponent(componentId).split("@");
|
|
29
|
-
const resolvedId =
|
|
30
|
-
if (!(!!server.moduleGraph.getModuleById(resolvedId)?.lastInvalidationTimestamp && classNames.get(resolvedId))) {
|
|
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, className);
|
|
43
|
+
const result = updates.fileEmitter(resolvedId, className);
|
|
38
44
|
debugHmr("middleware: served component update", {
|
|
39
45
|
resolvedId,
|
|
40
46
|
hasCode: !!result?.hmrUpdateCode
|
|
@@ -53,7 +59,7 @@ function liveReloadPlugin({ classNames, fileEmitter }) {
|
|
|
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("@");
|
|
56
|
-
return fileEmitter(
|
|
62
|
+
return updates.fileEmitter(resolveFileId(fileId), className)?.hmrUpdateCode || "";
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
};
|
|
@@ -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 interface ComponentUpdates {\n classNames: Map<string, string>;\n fileEmitter: (\n file: string,\n className: string,\n ) => Pick<EmitFileResult, 'hmrUpdateCode'> | undefined;\n}\n\nexport function liveReloadPlugin({\n classNames,\n
|
|
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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as vite from "vite";
|
|
2
|
+
import { type AngularBuildContext, type AngularBuildContextOptions } from "./angular-build-context.js";
|
|
2
3
|
import type { FastCompilePluginOptions } from "./fast-compile-plugin.js";
|
|
3
|
-
export declare function ngpCompilePlugin(
|
|
4
|
+
export declare function ngpCompilePlugin(optionsOrCtx?: AngularBuildContext | FastCompilePluginOptions | AngularBuildContextOptions): vite.Plugin;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
import { discoverAnalogIntegrations } from "./analog-plugin-interop.js";
|
|
2
|
+
import { preprocessStylesheet } from "./stylesheet-registry.js";
|
|
3
|
+
import { isIgnoredHmrFile } from "./utils/compilation-shared.js";
|
|
1
4
|
import { angularFullVersion } from "./utils/devkit.js";
|
|
5
|
+
import { isRolldown } from "./utils/rolldown.js";
|
|
2
6
|
import { TS_EXT_REGEX, createDepOptimizerConfig, getTsConfigPath, isProdMode } from "./utils/plugin-config.js";
|
|
3
|
-
import {
|
|
7
|
+
import { createAngularBuildContext, isAngularBuildContext } from "./angular-build-context.js";
|
|
4
8
|
import { releaseCssPreprocessorWorkers } from "./utils/css-preprocessor-workers.js";
|
|
9
|
+
import { loadAngularVirtualModule, resolveAngularVirtualId } from "./virtual-modules-plugin.js";
|
|
5
10
|
import { findHmrComponentUpdates } from "./utils/hmr-component-updates.js";
|
|
6
11
|
import { LspTypeChecker } from "./utils/lsp-type-checker.js";
|
|
7
|
-
import { resolve } from "node:path";
|
|
8
12
|
import { createRequire } from "node:module";
|
|
13
|
+
import { resolve } from "node:path";
|
|
9
14
|
import * as vite from "vite";
|
|
10
15
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
16
|
//#region packages/vite-plugin-angular/src/lib/ngp-compile-plugin.ts
|
|
17
|
+
function isFastCompileOptions(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && !isAngularBuildContext(value) && "tsconfigGetter" in value && typeof value.tsconfigGetter === "function";
|
|
19
|
+
}
|
|
12
20
|
var BUNDLED_NGP = new URL("../../ngp/", "" + import.meta.url);
|
|
13
21
|
async function loadNgp(tsconfig) {
|
|
14
22
|
const nativeBinding = process.env["ANALOG_NGP_NATIVE_BINDING"];
|
|
@@ -39,11 +47,18 @@ function transpile(source, filePath, map) {
|
|
|
39
47
|
sourcemap: true
|
|
40
48
|
}, map);
|
|
41
49
|
}
|
|
42
|
-
function ngpCompilePlugin(
|
|
50
|
+
function ngpCompilePlugin(optionsOrCtx) {
|
|
51
|
+
const sharedCtx = isAngularBuildContext(optionsOrCtx) ? optionsOrCtx : isFastCompileOptions(optionsOrCtx) ? void 0 : createAngularBuildContext({
|
|
52
|
+
jit: false,
|
|
53
|
+
...optionsOrCtx,
|
|
54
|
+
compilationBackend: "ngp"
|
|
55
|
+
});
|
|
56
|
+
const options = sharedCtx ? sharedCtx.options : optionsOrCtx;
|
|
43
57
|
if (options.jit || options.fastCompileMode === "partial") throw new Error("compilation: 'ngp' requires jit: false and fastCompileMode: 'full'.");
|
|
44
58
|
let configContext;
|
|
45
59
|
let resolvedConfig;
|
|
46
60
|
let transformFilter;
|
|
61
|
+
let stylePreprocessor;
|
|
47
62
|
let watchMode = false;
|
|
48
63
|
let hmr = false;
|
|
49
64
|
let activeBuilds = 0;
|
|
@@ -54,12 +69,16 @@ function ngpCompilePlugin(options) {
|
|
|
54
69
|
const filesByPath = /* @__PURE__ */ new Map();
|
|
55
70
|
const chunkContexts = /* @__PURE__ */ new Map();
|
|
56
71
|
const output = /* @__PURE__ */ new Map();
|
|
72
|
+
const emittedMaps = /* @__PURE__ */ new Map();
|
|
57
73
|
const sources = /* @__PURE__ */ new Map();
|
|
58
74
|
const dependents = /* @__PURE__ */ new Map();
|
|
59
75
|
const hmrUpdateCode = /* @__PURE__ */ new Map();
|
|
76
|
+
const classNames = sharedCtx ? sharedCtx.hmr.classNames : /* @__PURE__ */ new Map();
|
|
77
|
+
const fileEmitter = (file, className) => ({ hmrUpdateCode: hmrUpdateCode.get(`${file}@${className}`) });
|
|
78
|
+
sharedCtx?.hmr.setFileEmitter(fileEmitter);
|
|
60
79
|
const componentUpdates = {
|
|
61
|
-
classNames
|
|
62
|
-
fileEmitter
|
|
80
|
+
classNames,
|
|
81
|
+
fileEmitter
|
|
63
82
|
};
|
|
64
83
|
let pending = Promise.resolve();
|
|
65
84
|
const filter = vite.createFilter(TS_EXT_REGEX, [
|
|
@@ -69,10 +88,33 @@ function ngpCompilePlugin(options) {
|
|
|
69
88
|
/@ng\/component/
|
|
70
89
|
]);
|
|
71
90
|
function resolveTsConfigPath() {
|
|
72
|
-
|
|
91
|
+
if (sharedCtx) return sharedCtx.resolveTsConfigPath();
|
|
92
|
+
const ctx = configContext ?? {
|
|
93
|
+
root: resolvedConfig?.root || ".",
|
|
94
|
+
isProd: isProdMode(resolvedConfig?.mode),
|
|
95
|
+
isLib: !!resolvedConfig?.build?.lib
|
|
96
|
+
};
|
|
97
|
+
return getTsConfigPath(ctx.root, options.tsconfigGetter(), ctx.isProd, options.isTest, ctx.isLib, options.workspaceRoot);
|
|
73
98
|
}
|
|
99
|
+
const compilerApi = {
|
|
100
|
+
angularCompiler: true,
|
|
101
|
+
getTsConfigPath: resolveTsConfigPath,
|
|
102
|
+
getSourceMap: (id) => emittedMaps.get(vite.normalizePath(id)),
|
|
103
|
+
hasEmitted: (id) => filesByPath.has(vite.normalizePath(id)),
|
|
104
|
+
output,
|
|
105
|
+
ready: () => pending,
|
|
106
|
+
componentUpdates
|
|
107
|
+
};
|
|
108
|
+
sharedCtx?.registerCompiler({
|
|
109
|
+
name: "@analogjs/vite-plugin-angular-ngp",
|
|
110
|
+
getTsConfigPath: compilerApi.getTsConfigPath,
|
|
111
|
+
getSourceMap: compilerApi.getSourceMap,
|
|
112
|
+
hasEmitted: compilerApi.hasEmitted
|
|
113
|
+
});
|
|
74
114
|
async function prepareResources(file, watch) {
|
|
75
115
|
watch(file.filePath);
|
|
116
|
+
const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;
|
|
117
|
+
const activeStylePreprocessor = sharedCtx?.stylePreprocessor ?? stylePreprocessor;
|
|
76
118
|
return {
|
|
77
119
|
...file,
|
|
78
120
|
classes: await Promise.all(file.classes.map(async (metadata, classIndex) => {
|
|
@@ -80,8 +122,16 @@ function ngpCompilePlugin(options) {
|
|
|
80
122
|
if (!component) return metadata;
|
|
81
123
|
if (component.templateUrl) watch(component.templateUrl.resolvedPath);
|
|
82
124
|
for (const style of component.styleUrls ?? []) watch(style.resolvedPath);
|
|
83
|
-
const preprocess = async (content, path) => {
|
|
84
|
-
const
|
|
125
|
+
const preprocess = async (content, path, order, inline) => {
|
|
126
|
+
const preprocessed = preprocessStylesheet(content, path, activeStylePreprocessor, {
|
|
127
|
+
filename: path,
|
|
128
|
+
containingFile: file.filePath,
|
|
129
|
+
resourceFile: inline ? void 0 : path,
|
|
130
|
+
className: metadata.className,
|
|
131
|
+
order,
|
|
132
|
+
inline
|
|
133
|
+
});
|
|
134
|
+
const result = await vite.preprocessCSS(preprocessed, path, activeConfig);
|
|
85
135
|
result.deps?.forEach(watch);
|
|
86
136
|
return result.code;
|
|
87
137
|
};
|
|
@@ -89,8 +139,8 @@ function ngpCompilePlugin(options) {
|
|
|
89
139
|
...metadata,
|
|
90
140
|
component: {
|
|
91
141
|
...component,
|
|
92
|
-
styles: component.styles && await Promise.all(component.styles.map((style, index) => preprocess(style, `${file.filePath}.inline-${classIndex}-${index}.${options.inlineStylesExtension}
|
|
93
|
-
stylesFromUrls: component.stylesFromUrls && await Promise.all(component.stylesFromUrls.map((style, index) => preprocess(style, component.styleUrls[index].resolvedPath)))
|
|
142
|
+
styles: component.styles && await Promise.all(component.styles.map((style, index) => preprocess(style, `${file.filePath}.inline-${classIndex}-${index}.${options.inlineStylesExtension}`, index, true))),
|
|
143
|
+
stylesFromUrls: component.stylesFromUrls && await Promise.all(component.stylesFromUrls.map((style, index) => preprocess(style, component.styleUrls[index].resolvedPath, index, false)))
|
|
94
144
|
}
|
|
95
145
|
};
|
|
96
146
|
}))
|
|
@@ -217,36 +267,38 @@ function ngpCompilePlugin(options) {
|
|
|
217
267
|
return {
|
|
218
268
|
name: "@analogjs/vite-plugin-angular-ngp",
|
|
219
269
|
enforce: "pre",
|
|
220
|
-
api:
|
|
221
|
-
|
|
222
|
-
output,
|
|
223
|
-
ready: () => pending,
|
|
224
|
-
componentUpdates
|
|
225
|
-
},
|
|
226
|
-
config(config, { command }) {
|
|
270
|
+
api: compilerApi,
|
|
271
|
+
config(config, { command, mode }) {
|
|
227
272
|
watchMode = command === "serve";
|
|
228
|
-
|
|
273
|
+
const isProd = isProdMode(config.mode);
|
|
274
|
+
if (sharedCtx) sharedCtx.initConfig(config, {
|
|
275
|
+
command,
|
|
276
|
+
mode
|
|
277
|
+
});
|
|
278
|
+
else configContext = {
|
|
229
279
|
root: config.root || ".",
|
|
230
|
-
isProd
|
|
280
|
+
isProd,
|
|
231
281
|
isLib: !!config.build?.lib
|
|
232
282
|
};
|
|
233
283
|
const depOptimizer = createDepOptimizerConfig({
|
|
234
284
|
tsconfig: resolveTsConfigPath(),
|
|
235
|
-
isProd
|
|
285
|
+
isProd,
|
|
236
286
|
jit: false,
|
|
237
287
|
watchMode,
|
|
238
288
|
isTest: options.isTest,
|
|
239
289
|
isAstroIntegration: options.isAstroIntegration
|
|
240
290
|
});
|
|
241
291
|
return {
|
|
242
|
-
...
|
|
292
|
+
...isRolldown() ? { oxc: {} } : { esbuild: false },
|
|
243
293
|
...depOptimizer
|
|
244
294
|
};
|
|
245
295
|
},
|
|
246
296
|
async configResolved(config) {
|
|
247
297
|
resolvedConfig = config;
|
|
248
298
|
hmr = watchMode && options.liveReload && !options.isTest && config.server.hmr !== false;
|
|
249
|
-
|
|
299
|
+
const integrations = sharedCtx ? await sharedCtx.resolveConfig(config) : await discoverAnalogIntegrations(config);
|
|
300
|
+
transformFilter = integrations.transformFilter;
|
|
301
|
+
stylePreprocessor = integrations.stylePreprocessor;
|
|
250
302
|
},
|
|
251
303
|
configureServer(server) {
|
|
252
304
|
const changeTypes = {
|
|
@@ -281,8 +333,18 @@ function ngpCompilePlugin(options) {
|
|
|
281
333
|
await pending;
|
|
282
334
|
for (const path of dependents.keys()) this.addWatchFile(path);
|
|
283
335
|
},
|
|
336
|
+
resolveId(id, importer) {
|
|
337
|
+
return resolveAngularVirtualId(id, importer, {
|
|
338
|
+
jit: false,
|
|
339
|
+
resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig
|
|
340
|
+
});
|
|
341
|
+
},
|
|
342
|
+
async load(id) {
|
|
343
|
+
return loadAngularVirtualModule(this, id, sharedCtx?.resolvedConfig ?? resolvedConfig);
|
|
344
|
+
},
|
|
284
345
|
async transform(code, id) {
|
|
285
|
-
|
|
346
|
+
const activeTransformFilter = sharedCtx?.transformFilter ?? transformFilter;
|
|
347
|
+
if (!filter(id) || activeTransformFilter?.(code, id) === false) return;
|
|
286
348
|
const filePath = vite.normalizePath(id.split("?")[0]);
|
|
287
349
|
await pending;
|
|
288
350
|
let result = await compileFile(filePath, (path) => this.addWatchFile(path));
|
|
@@ -299,9 +361,12 @@ function ngpCompilePlugin(options) {
|
|
|
299
361
|
includeContent: true,
|
|
300
362
|
hires: true
|
|
301
363
|
});
|
|
302
|
-
|
|
364
|
+
const transpiled = await transpile(source, filePath, map);
|
|
365
|
+
if (transpiled?.map) emittedMaps.set(filePath, typeof transpiled.map === "string" ? transpiled.map : JSON.stringify(transpiled.map));
|
|
366
|
+
return transpiled;
|
|
303
367
|
},
|
|
304
368
|
async handleHotUpdate(ctx) {
|
|
369
|
+
if (sharedCtx ? sharedCtx.hmr.isIgnoredFile(ctx.file) : isIgnoredHmrFile(ctx.file)) return [];
|
|
305
370
|
const normPath = vite.normalizePath(ctx.file);
|
|
306
371
|
const updates = hmr ? await findComponentUpdates(normPath, ctx.read) : [];
|
|
307
372
|
await enqueueIndex(() => analyzer.invalidateFiles([{
|
|
@@ -332,6 +397,7 @@ function ngpCompilePlugin(options) {
|
|
|
332
397
|
filesByPath.clear();
|
|
333
398
|
chunkContexts.clear();
|
|
334
399
|
output.clear();
|
|
400
|
+
emittedMaps.clear();
|
|
335
401
|
sources.clear();
|
|
336
402
|
dependents.clear();
|
|
337
403
|
releaseCssPreprocessorWorkers();
|