@analogjs/vite-plugin-angular 3.0.0 → 3.0.1-beta.1
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/angular-build-context.d.ts +6 -4
- package/src/lib/angular-build-context.js +16 -2
- package/src/lib/angular-build-context.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.js +15 -11
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +3 -3
- package/src/lib/live-reload-plugin.js +32 -3
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/models.d.ts +4 -1
- package/src/lib/ngp-compile-plugin.js +6 -1
- package/src/lib/ngp-compile-plugin.js.map +1 -1
- package/src/lib/ngtsc-compile-plugin.d.ts +3 -3
- package/src/lib/ngtsc-compile-plugin.js +30 -26
- package/src/lib/ngtsc-compile-plugin.js.map +1 -1
- package/src/lib/utils/compilation-shared.d.ts +1 -4
- package/src/lib/utils/compilation-shared.js +6 -4
- package/src/lib/utils/compilation-shared.js.map +1 -1
|
@@ -441,7 +441,12 @@ function ngpCompilePlugin(optionsOrCtx) {
|
|
|
441
441
|
updates.forEach(({ file, className }, index) => {
|
|
442
442
|
const moduleFile = sourceModules.get(file)?.sourceFile ?? file;
|
|
443
443
|
hmrUpdateCode.set(`${moduleFile}@${className}`, codes[index]);
|
|
444
|
-
componentUpdates.classNames.
|
|
444
|
+
let fileClasses = componentUpdates.classNames.get(moduleFile);
|
|
445
|
+
if (!fileClasses) {
|
|
446
|
+
fileClasses = /* @__PURE__ */ new Set();
|
|
447
|
+
componentUpdates.classNames.set(moduleFile, fileClasses);
|
|
448
|
+
}
|
|
449
|
+
fileClasses.add(className);
|
|
445
450
|
server.moduleGraph.getModulesByFile(moduleFile)?.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
446
451
|
server.ws.send("angular:component-update", {
|
|
447
452
|
id: encodeURIComponent(`${moduleFile}@${className}`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngp-compile-plugin.js","names":["fsPromises"],"sources":["../../../src/lib/ngp-compile-plugin.ts"],"sourcesContent":["import * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, promises as fsPromises, realpathSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport type MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport * as vite from 'vite';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport { ComponentScanner } from './component-scanner.js';\nimport type { FastCompileResolve } from './fast-compile-api.js';\nimport type { FastCompilePluginOptions } from './fast-compile-plugin.js';\nimport type {\n NgpCompileApi,\n NgpLoweredModule,\n NgpSourceFormat,\n} from './ngp-compile-api.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport {\n createDepOptimizerConfig,\n getTsConfigPath,\n isProdMode,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { angularFullVersion } from './utils/devkit.js';\nimport { findHmrComponentUpdates } from './utils/hmr-component-updates.js';\nimport {\n LspTypeChecker,\n type FileChangeType,\n type SourceLocation,\n} from './utils/lsp-type-checker.js';\nimport {\n canonicalPath,\n createNgpHostFs,\n fromWasmPath,\n toWasmPath,\n type NgpHostFs,\n} from './utils/ngp-host-fs.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport type { ComponentUpdates } from './live-reload-plugin.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\n// The unpublished NGP API is loaded at runtime. Model only the surface we use.\ninterface NgpDiagnostic {\n category: number;\n messageText: string;\n}\n\ninterface NgpFile {\n filePath: string;\n diagnostics?: NgpDiagnostic[];\n classes: {\n className?: string;\n component?: {\n templateUrl?: { resolvedPath: string };\n styleUrls?: { resolvedPath: string }[];\n stylesFromUrls?: string[];\n styles?: string[];\n };\n }[];\n}\n\ninterface NgpChunk {\n files: NgpFile[];\n removedFiles?: string[];\n}\n\ninterface NgpResult {\n magicString: MagicString;\n diagnostics?: NgpDiagnostic[];\n tcb?: { code: string } | null;\n hmrUpdateModule?: string | null;\n}\n\ninterface NgpAnalyzer {\n getFileContent(path: string): Promise<string>;\n updateFileContent(\n updates: { filePath: string; content: string }[],\n ): Promise<string[]>;\n invalidateFiles(\n updates: { filePath: string; updateType: number }[],\n ): Promise<string[]>;\n close(): void;\n}\n\ninterface NgpCompiler {\n // Parsed templates by file, cleared by NGP's own update methods\n fileCache: Map<string, unknown>;\n analyzeOptimized(): AsyncIterable<NgpChunk>;\n analyzeOptimizedDelta(): AsyncIterable<NgpChunk>;\n prepareChunk(chunk: NgpChunk): Promise<unknown>;\n processFile(\n path: string,\n content: string,\n ...args: [undefined, NgpFile, unknown] | [NgpFile, unknown]\n ): Promise<NgpResult>;\n}\n\ninterface ComponentUpdate {\n file: string;\n className: string;\n}\n\ninterface NgpAnalyzerOptions {\n nativeBinding?: string;\n backend?: 'wasm';\n wasmBinding?: string;\n enableHmr?: boolean;\n hostFs?: NgpHostFs;\n}\n\n/** NGP's `FileUpdateType`. */\nconst FILE_CREATED = 0;\nconst FILE_DELETED = 1;\nconst FILE_CHANGED = 2;\n\n/** A module of a registered source format, lowered to its program file. */\ninterface SourceModule {\n sourceFile: string;\n /** The source it was lowered from. */\n source: string;\n format: NgpSourceFormat;\n lowered: NgpLoweredModule;\n}\n\ninterface NgpApi {\n createAnalyzer(\n tsconfig: string,\n options: NgpAnalyzerOptions,\n ): Promise<NgpAnalyzer>;\n HybridCompiler: new (\n analyzer: NgpAnalyzer,\n options: Record<string, unknown> & {\n optimize: boolean;\n enableHmr: boolean;\n },\n ) => NgpCompiler;\n buildTypeCheckingConfig(options: Record<string, unknown>): unknown;\n}\n\nfunction isFastCompileOptions(\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// Interim NGP build bundled with this package until @angular/ngp is published\nconst BUNDLED_NGP = new URL('../../ngp/', import.meta.url);\n\n/**\n * @param needsHostFs Whether source formats are registered, which only the\n * WebAssembly backend can read through `hostFs`.\n */\nasync function loadNgp(\n tsconfig: string,\n needsHostFs: boolean,\n): Promise<{ api: NgpApi; analyzerOptions: NgpAnalyzerOptions }> {\n const nativeBinding = process.env['ANALOG_NGP_NATIVE_BINDING'];\n if (nativeBinding && needsHostFs) {\n throw new Error(\n \"[@analogjs/vite-plugin-angular]: Source formats such as TSRX can't be compiled with a native NGP analyzer build. Unset ANALOG_NGP_NATIVE_BINDING to use NGP's default WebAssembly analyzer.\",\n );\n }\n let modulePath = process.env['ANALOG_NGP_COMPILER'];\n if (!modulePath) {\n try {\n modulePath = createRequire(tsconfig).resolve('@angular/ngp');\n } catch {\n if (angularFullVersion < 220200) {\n throw new Error(\n \"[@analogjs/vite-plugin-angular]: compilation: 'ngp' requires Angular v22.2 or later.\",\n );\n }\n return {\n api: await import(new URL('api.mjs', BUNDLED_NGP).href),\n analyzerOptions: nativeBinding\n ? { nativeBinding }\n : {\n backend: 'wasm',\n wasmBinding: fileURLToPath(\n new URL('ng_analyze.cjs', BUNDLED_NGP),\n ),\n },\n };\n }\n }\n return {\n api: await import(pathToFileURL(resolve(modulePath)).href),\n analyzerOptions: nativeBinding\n ? { nativeBinding }\n : needsHostFs\n ? { backend: 'wasm' }\n : {},\n };\n}\n\nfunction transpile(\n source: string,\n filePath: string,\n map?: Parameters<typeof vite.transformWithEsbuild>[3],\n) {\n return vite.transformWithOxc\n ? vite.transformWithOxc(\n source,\n filePath,\n { lang: 'ts', sourcemap: true },\n map,\n )\n : vite.transformWithEsbuild(\n source,\n filePath,\n { loader: 'ts', sourcemap: true },\n map,\n );\n}\n\nexport function ngpCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): vite.Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompileOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n jit: false,\n ...optionsOrCtx,\n compilationBackend: 'ngp',\n });\n\n const options: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n if (options.jit || options.fastCompileMode === 'partial') {\n throw new Error(\n \"compilation: 'ngp' requires jit: false and fastCompileMode: 'full'.\",\n );\n }\n\n let configContext: TsConfigResolutionContext | undefined;\n let resolvedConfig: vite.ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let watchMode = false;\n let hmr = false;\n let activeBuilds = 0;\n let analyzer: NgpAnalyzer | undefined;\n let compiler: NgpCompiler | undefined;\n let typeChecker: LspTypeChecker | undefined;\n let api: NgpApi;\n let toAnalyzerPath = (path: string) => path;\n let fromAnalyzerPath = vite.normalizePath;\n const filesByPath = new Map<string, { file: NgpFile; chunk: NgpChunk }>();\n const chunkContexts = new Map<NgpChunk, Promise<unknown>>();\n const output = new Map<string, Promise<NgpResult>>();\n const emittedMaps = new Map<string, string>();\n // Last compiled source of each file, compared on edits for HMR\n const sources = new Map<string, string>();\n // Watched files mapped to the source files that depend on them\n const dependents = new Map<string, Set<string>>();\n const hmrUpdateCode = new Map<string, string>();\n const classNames = sharedCtx\n ? sharedCtx.hmr.classNames\n : new Map<string, string>();\n const fileEmitter = (file: string, className: string) => ({\n hmrUpdateCode: hmrUpdateCode.get(`${file}@${className}`),\n });\n sharedCtx?.hmr.setFileEmitter(fileEmitter);\n\n const componentUpdates: ComponentUpdates = {\n classNames,\n fileEmitter,\n };\n let pending = Promise.resolve();\n const excluded = [\n /node_modules/,\n /[?&]raw\\b/,\n /type=script/,\n /@ng\\/component/,\n ];\n const filter = vite.createFilter(TS_EXT_REGEX, excluded);\n const sourceFilter = vite.createFilter(null, excluded);\n\n // Source formats registered through `api.ngp`, the component registry their\n // lowering looks selectors up in, and their modules by program file\n // (`x.tsrx` → `x.tsrx.ts`)\n const sourceFormats: NgpSourceFormat[] = [];\n const scanner = new ComponentScanner();\n const sourceModules = new Map<string, SourceModule>();\n // Per program file: how often it was removed, which cancels a lowering in\n // progress, and the lowered code the analyzer has\n const removals = new Map<string, number>();\n const analyzed = new Map<string, string>();\n // Which modules of each format NGP compiles: its `include` under the tsconfig's directory\n const includes = new Map<NgpSourceFormat, (file: string) => boolean>();\n const moduleFormatOf = (file: string): NgpSourceFormat | undefined =>\n sourceFormats.find(\n (format) => format.test(file) && includes.get(format)?.(file),\n );\n let devServer: vite.ViteDevServer | undefined;\n // The program files a file change lowered again, for the hot update after it\n const reloweredByChange = new Map<string, string[]>();\n const programFileOf = (file: string): string | undefined => {\n const programFile = `${file}.ts`;\n return sourceModules.has(programFile) ? programFile : undefined;\n };\n const sourceFileOf = (file: string): string =>\n sourceModules.get(file)?.sourceFile ?? file;\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const ctx = configContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n ctx.root,\n options.tsconfigGetter(),\n ctx.isProd,\n options.isTest,\n ctx.isLib,\n options.workspaceRoot,\n );\n }\n\n const ngp: NgpCompileApi = {\n registerSourceFormat(format) {\n if (!sourceFormats.includes(format)) {\n sourceFormats.push(format);\n scanner.registerSourceFormat(format);\n }\n },\n };\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(vite.normalizePath(id)),\n hasEmitted: (id: string): boolean =>\n filesByPath.has(vite.normalizePath(id)),\n output,\n ready: (): Promise<void> => pending,\n componentUpdates,\n ngp,\n };\n\n /** Lowers a module of a source format. Returns whether its TypeScript changed. */\n async function lowerSourceModule(\n sourceFile: string,\n source: string,\n format: NgpSourceFormat,\n resolve: FastCompileResolve,\n ): Promise<boolean> {\n const programFile = `${sourceFile}.ts`;\n if (existsSync(programFile)) {\n throw new Error(\n `[@analogjs/vite-plugin-angular]: ${programFile} has the name NGP compiles ${sourceFile} as. Rename one of them.`,\n );\n }\n const removed = removals.get(programFile);\n const lowered = await format.lower(source, sourceFile, {\n scanImports: (specifiers) =>\n scanner.scanImports(specifiers, sourceFile, resolve),\n resolveSelector: (className, moduleSpecifier, containingFile) =>\n scanner.lookupSelector(\n className,\n sharedCtx?.componentRegistries ?? componentRegistries,\n moduleSpecifier !== undefined\n ? {\n moduleSpecifier,\n containingFile: containingFile ?? sourceFile,\n }\n : undefined,\n ),\n });\n // Removed while it was lowered\n if (removals.get(programFile) !== removed) return false;\n const changed =\n sourceModules.get(programFile)?.lowered.code !== lowered.code;\n sourceModules.set(programFile, { sourceFile, source, format, lowered });\n return changed;\n }\n\n /** Lowers every module of the registered source formats under `root`. */\n async function lowerSourceModules(\n root: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n scanner.reset(root);\n sourceModules.clear();\n const sourceRoot = vite.normalizePath(realpathSync(root));\n await Promise.all(\n sourceFormats.map(async (format) => {\n includes.set(\n format,\n vite.createFilter(format.include, '**/node_modules/**', {\n resolve: sourceRoot,\n }),\n );\n const files = await glob(format.include, {\n cwd: sourceRoot,\n absolute: true,\n ignore: ['**/node_modules/**'],\n });\n await Promise.all(\n files.map(async (file) => {\n const sourceFile = canonicalPath(file);\n const source = await fsPromises.readFile(sourceFile, 'utf-8');\n await lowerSourceModule(sourceFile, source, format, resolve);\n }),\n );\n }),\n );\n // The analyzer reads them through `hostFs` when it's created\n analyzed.clear();\n for (const [programFile, { lowered }] of sourceModules) {\n analyzed.set(programFile, lowered.code);\n }\n }\n\n /**\n * Lowers the source modules a change to `file` affects again: the module\n * itself, and those that looked up selectors in it. Returns the program\n * files whose TypeScript changed.\n */\n async function relowerSourceModules(\n file: string,\n resolve: FastCompileResolve,\n ): Promise<string[]> {\n const affected = [file, ...(scanner.importersByFile.get(file) ?? [])]\n .map(programFileOf)\n .filter((programFile) => programFile !== undefined);\n scanner.invalidate(file);\n const changed = await Promise.all(\n affected.map(async (programFile) => {\n const sourceModule = sourceModules.get(programFile);\n if (!sourceModule) return [];\n const { sourceFile, format } = sourceModule;\n const source = await readSource(sourceFile);\n if (source === undefined) return [];\n const relowered = await lowerSourceModule(\n sourceFile,\n source,\n format,\n resolve,\n );\n return relowered ? [programFile] : [];\n }),\n );\n return changed.flat();\n }\n\n // Lowering and the analyzer updates that follow it, one change at a time, so\n // the modules a change lowers again reach the analyzer together\n let sourceWork: Promise<unknown> = Promise.resolve();\n function withSourceLock<T>(work: () => Promise<T>): Promise<T> {\n const run = sourceWork.catch(() => undefined).then(work);\n sourceWork = run;\n return run;\n }\n\n /** Sends the analyzer the lowered modules it doesn't have yet. */\n async function syncProgramFiles(): Promise<void> {\n const updates = [...sourceModules]\n .filter(\n ([filePath, { lowered }]) => analyzed.get(filePath) !== lowered.code,\n )\n .map(([filePath, { lowered }]) => ({ filePath, content: lowered.code }));\n if (updates.length === 0) return;\n for (const { filePath, content } of updates)\n analyzed.set(filePath, content);\n await enqueueIndex(() =>\n analyzer!.updateFileContent(\n updates.map(({ filePath, content }) => ({\n filePath: toAnalyzerPath(filePath),\n content,\n })),\n ),\n );\n }\n\n /** Reads a source file, or `undefined` if it was removed. */\n function readSource(file: string): Promise<string | undefined> {\n return fsPromises\n .readFile(file, 'utf-8')\n .catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n }\n\n /** Lowers a module added after the build started, if NGP compiles it. */\n async function addSourceModule(\n sourceFile: string,\n format: NgpSourceFormat,\n source: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n const programFile = `${sourceFile}.ts`;\n await lowerSourceModule(sourceFile, source, format, resolve);\n const sourceModule = sourceModules.get(programFile);\n // Removed while it was lowered\n if (!sourceModule) return;\n // The analyzer reads it through `hostFs`\n analyzed.set(programFile, sourceModule.lowered.code);\n await enqueueIndex(() =>\n analyzer!.invalidateFiles([\n { filePath: toAnalyzerPath(programFile), updateType: FILE_CREATED },\n ]),\n );\n }\n\n /** Drops a removed module, and any lowering of it still in progress. */\n async function removeSourceModule(sourceFile: string): Promise<void> {\n const programFile = `${sourceFile}.ts`;\n removals.set(programFile, (removals.get(programFile) ?? 0) + 1);\n analyzed.delete(programFile);\n if (!sourceModules.delete(programFile)) return;\n await enqueueIndex(() =>\n analyzer!.invalidateFiles([\n { filePath: toAnalyzerPath(programFile), updateType: FILE_DELETED },\n ]),\n );\n }\n\n /**\n * Lowers a module for its transform, as fast compile does on every\n * transform, so the selectors it looks up are current. A transform that\n * started before a hot update can carry the previous code; it compiles the\n * latest lowering instead.\n */\n async function lowerForTransform(\n sourceFile: string,\n format: NgpSourceFormat,\n code: string,\n resolve: FastCompileResolve,\n ): Promise<NgpLoweredModule | undefined> {\n const programFile = `${sourceFile}.ts`;\n if (!sourceModules.has(programFile)) {\n // Requested before its `create` event, or added during `vite build --watch`\n await addSourceModule(sourceFile, format, code, resolve);\n } else if (code === (await readSource(sourceFile))) {\n await lowerSourceModule(sourceFile, code, format, resolve);\n }\n return sourceModules.get(programFile)?.lowered;\n }\n\n /** Maps a type error in a program file to the source module's location. */\n function toSourceLocation(location: SourceLocation): SourceLocation {\n const sourceModule = sourceModules.get(vite.normalizePath(location.file));\n const mapped = sourceModule?.lowered.toSourceLocation(\n location.line - 1,\n location.character - 1,\n );\n return mapped\n ? {\n file: sourceModule!.sourceFile,\n line: mapped.line + 1,\n character: mapped.column + 1,\n }\n : location;\n }\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-ngp',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n async function prepareResources(\n file: NgpFile,\n watch: (path: string) => void,\n ): Promise<NgpFile> {\n const hostFilePath = fromAnalyzerPath(file.filePath);\n watch(hostFilePath);\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n\n return {\n ...file,\n classes: await Promise.all(\n file.classes.map(async (metadata, classIndex) => {\n const component = metadata.component;\n if (!component) return metadata;\n if (component.templateUrl)\n watch(fromAnalyzerPath(component.templateUrl.resolvedPath));\n for (const style of component.styleUrls ?? [])\n watch(fromAnalyzerPath(style.resolvedPath));\n const preprocess = async (\n content: string,\n path: string,\n order: number,\n inline: boolean,\n ) => {\n const preprocessed = preprocessStylesheet(\n content,\n path,\n activeStylePreprocessor,\n {\n filename: path,\n containingFile: hostFilePath,\n resourceFile: inline ? undefined : path,\n className: metadata.className,\n order,\n inline,\n },\n );\n const result = await vite.preprocessCSS(\n preprocessed,\n path,\n activeConfig,\n );\n result.deps?.forEach(watch);\n return result.code;\n };\n return {\n ...metadata,\n component: {\n ...component,\n styles:\n component.styles &&\n (await Promise.all(\n component.styles.map((style, index) =>\n preprocess(\n style,\n `${hostFilePath}.inline-${classIndex}-${index}.${options.inlineStylesExtension}`,\n index,\n true,\n ),\n ),\n )),\n stylesFromUrls:\n component.stylesFromUrls &&\n (await Promise.all(\n component.stylesFromUrls.map((style, index) =>\n preprocess(\n style,\n fromAnalyzerPath(\n component.styleUrls![index].resolvedPath,\n ),\n index,\n false,\n ),\n ),\n )),\n },\n };\n }),\n ),\n };\n }\n\n async function indexChunks(update?: () => Promise<string[]>): Promise<void> {\n if (update) {\n const invalidated = await update();\n for (const filePath of invalidated) {\n output.delete(fromAnalyzerPath(filePath));\n compiler!.fileCache.delete(filePath);\n }\n chunkContexts.clear();\n } else {\n filesByPath.clear();\n chunkContexts.clear();\n output.clear();\n const angularOptions = compilerCli.readConfiguration(\n resolveTsConfigPath(),\n ).options as Record<string, unknown>;\n compiler = new api.HybridCompiler(analyzer!, {\n ...angularOptions,\n optimize: true,\n enableHmr: hmr,\n tcbConfig: api.buildTypeCheckingConfig(angularOptions),\n });\n }\n const chunks = update\n ? compiler!.analyzeOptimizedDelta()\n : compiler!.analyzeOptimized();\n for await (const chunk of chunks) {\n for (const file of chunk.files) {\n const normPath = fromAnalyzerPath(file.filePath);\n filesByPath.set(normPath, { file, chunk });\n output.delete(normPath);\n compiler!.fileCache.delete(file.filePath);\n }\n for (const removed of chunk.removedFiles ?? []) {\n const normPath = fromAnalyzerPath(removed);\n filesByPath.delete(normPath);\n output.delete(normPath);\n }\n }\n }\n\n function enqueueIndex(update: () => Promise<string[]>): Promise<void> {\n pending = pending.catch(() => {}).then(() => indexChunks(update));\n return pending;\n }\n\n function getChunkContext(chunk: NgpChunk): Promise<unknown> {\n let context = chunkContexts.get(chunk);\n if (!context) {\n context = compiler!.prepareChunk(chunk);\n chunkContexts.set(chunk, context);\n }\n return context;\n }\n\n async function checkTypes(\n filePath: string,\n sourceCode: string,\n tcbCode?: string | null,\n ): Promise<void> {\n typeChecker ??= new LspTypeChecker(\n resolveTsConfigPath(),\n options.typeChecker,\n {\n inMemoryFiles: () =>\n new Map(\n [...sourceModules].map(([file, { lowered }]) => [\n file,\n lowered.code,\n ]),\n ),\n mapLocation: toSourceLocation,\n },\n );\n typeChecker.queueFile(filePath, sourceCode, tcbCode);\n if (!watchMode) return;\n const typeErrors = await typeChecker.flushQueue(true);\n if (typeErrors.length) {\n throw new Error(typeErrors.join('\\n'));\n }\n }\n\n async function processFile(\n normPath: string,\n activeCompiler: NgpCompiler,\n watch: (path: string) => void,\n ) {\n const { file: analyzed, chunk } = filesByPath.get(normPath)!;\n const [file, context, content] = await Promise.all([\n prepareResources(analyzed, (path) => {\n const key = sourceFileOf(vite.normalizePath(path));\n dependents.set(key, (dependents.get(key) ?? new Set()).add(normPath));\n watch(key);\n }),\n getChunkContext(chunk),\n analyzer!.getFileContent(analyzed.filePath),\n ]);\n sources.set(normPath, content);\n const result =\n activeCompiler.processFile.length >= 5\n ? await activeCompiler.processFile(\n file.filePath,\n content,\n undefined,\n file,\n context,\n )\n : await activeCompiler.processFile(\n file.filePath,\n content,\n file,\n context,\n );\n return { file, content, result };\n }\n\n function compileFile(\n normPath: string,\n watch: (path: string) => void,\n ): Promise<NgpResult> | undefined {\n if (!filesByPath.has(normPath)) return undefined;\n let task = output.get(normPath);\n if (!task) {\n task = (async () => {\n // Analyzer updates queued before this compile land first\n await pending;\n if (!filesByPath.has(normPath)) {\n throw new Error(`${sourceFileOf(normPath)} was removed.`);\n }\n const { file, content, result } = await processFile(\n normPath,\n compiler!,\n watch,\n );\n const errors = [\n ...(file.diagnostics ?? []),\n ...(result.diagnostics ?? []),\n ].filter((diagnostic) => diagnostic.category === 1);\n if (errors.length) {\n throw new Error(\n `${sourceFileOf(normPath)}: ${errors.map((error) => error.messageText).join('\\n')}`,\n );\n }\n if (options.disableTypeChecking !== true) {\n await checkTypes(\n fromAnalyzerPath(file.filePath),\n content,\n result.tcb?.code,\n );\n }\n return result;\n })();\n output.set(normPath, task);\n }\n return task;\n }\n\n function componentNames(normPath: string): string[] {\n return (filesByPath.get(normPath)?.file.classes ?? []).flatMap(\n ({ className, component }) => (component && className ? [className] : []),\n );\n }\n\n // Components to update in place, following the Angular CLI's rule\n async function findComponentUpdates(\n normPath: string,\n read: () => string | Promise<string>,\n ): Promise<ComponentUpdate[]> {\n if (!TS_EXT_REGEX.test(normPath)) {\n return [...(dependents.get(normPath) ?? [])].flatMap((file) =>\n componentNames(file).map((className) => ({ file, className })),\n );\n }\n const stale = sources.get(normPath);\n if (stale === undefined) return [];\n const matchedClassNames = findHmrComponentUpdates(\n normPath,\n stale,\n await read(),\n new Set(componentNames(normPath)),\n );\n return (matchedClassNames ?? []).map((className) => ({\n file: normPath,\n className,\n }));\n }\n\n async function emitHmrUpdate(file: string, className: string) {\n // NGP emits only the update module of the class named by `hmrUpdateTarget`,\n // and only when it doesn't reuse the file's previously processed output\n const target = Object.assign(\n Object.create(Object.getPrototypeOf(compiler)),\n compiler,\n { hmrUpdateTarget: className, reuseProcessedFiles: false },\n );\n const { result } = await processFile(file, target, () => {});\n return (\n result.hmrUpdateModule &&\n (await transpile(result.hmrUpdateModule, file)).code\n );\n }\n\n async function sendComponentUpdates(\n updates: ComponentUpdate[],\n server: vite.ViteDevServer,\n ): Promise<boolean> {\n try {\n for (const file of new Set(updates.map((update) => update.file))) {\n await compileFile(file, () => {});\n }\n const codes = await Promise.all(\n updates.map(({ file, className }) => emitHmrUpdate(file, className)),\n );\n if (codes.some((code) => !code)) return false;\n updates.forEach(({ file, className }, index) => {\n // Components of a source module update through the module itself\n const sourceFile = sourceModules.get(file)?.sourceFile;\n const moduleFile = sourceFile ?? file;\n hmrUpdateCode.set(`${moduleFile}@${className}`, codes[index]!);\n componentUpdates.classNames.set(moduleFile, className);\n server.moduleGraph\n .getModulesByFile(moduleFile)\n ?.forEach((mod) => server.moduleGraph.invalidateModule(mod));\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(`${moduleFile}@${className}`),\n timestamp: Date.now(),\n });\n });\n return true;\n } catch {\n // A full reload reports the compilation error\n return false;\n }\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-ngp',\n enforce: 'pre',\n api: compilerApi,\n config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n configContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config.build?.lib,\n };\n }\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: resolveTsConfigPath(),\n isProd,\n jit: false,\n watchMode,\n isTest: options.isTest,\n isAstroIntegration: options.isAstroIntegration,\n });\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n hmr =\n watchMode &&\n options.liveReload &&\n !options.isTest &&\n config.server.hmr !== false;\n const integrations = sharedCtx\n ? await sharedCtx.resolveConfig(config)\n : await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n },\n configureServer(server) {\n const changeTypes: Record<string, FileChangeType> = {\n add: 1,\n change: 2,\n unlink: 3,\n };\n devServer = server;\n server.watcher.on('all', (event, path) => {\n const type = changeTypes[event];\n if (type) typeChecker?.notifyFileChanged(path, type);\n });\n server.httpServer?.on('close', () => {\n typeChecker?.close();\n typeChecker = undefined;\n analyzer?.close();\n analyzer = undefined;\n compiler = undefined;\n });\n },\n // Runs on the dev server with or without HMR, and in `vite build --watch`\n async watchChange(id, { event }) {\n if (!analyzer || sourceFormats.length === 0) return;\n const file = canonicalPath(id);\n const resolve: FastCompileResolve = (spec, importer) =>\n this.resolve(spec, importer, { skipSelf: true });\n await withSourceLock(async () => {\n scanner.invalidate(file);\n const format = moduleFormatOf(file);\n if (event === 'update') {\n reloweredByChange.set(\n file,\n await relowerSourceModules(file, resolve),\n );\n } else if (event === 'delete') {\n await removeSourceModule(file);\n } else if (\n event === 'create' &&\n format &&\n !sourceModules.has(`${file}.ts`)\n ) {\n const source = await readSource(file);\n if (source !== undefined) {\n await addSourceModule(file, format, source, resolve);\n }\n }\n await syncProgramFiles();\n });\n // Modules that looked up selectors in `file` lower again when transformed\n for (const importer of scanner.importersByFile.get(file) ?? []) {\n devServer?.moduleGraph\n .getModulesByFile(importer)\n ?.forEach((mod) => devServer!.moduleGraph.invalidateModule(mod));\n }\n },\n async buildStart() {\n activeBuilds++;\n if (!analyzer) {\n const tsconfig = resolveTsConfigPath();\n const hasSourceFormats = sourceFormats.length > 0;\n const ngp = await loadNgp(tsconfig, hasSourceFormats);\n const isWasm = ngp.analyzerOptions.backend === 'wasm';\n toAnalyzerPath = isWasm ? toWasmPath : (path) => path;\n fromAnalyzerPath = isWasm ? fromWasmPath : vite.normalizePath;\n api = ngp.api;\n if (hasSourceFormats) {\n await lowerSourceModules(dirname(tsconfig), (specifier, importer) =>\n this.resolve(specifier, importer, { skipSelf: true }),\n );\n }\n analyzer = await api.createAnalyzer(toAnalyzerPath(tsconfig), {\n ...ngp.analyzerOptions,\n enableHmr: hmr,\n hostFs:\n hasSourceFormats || isWasm\n ? createNgpHostFs(\n hasSourceFormats\n ? (path) => sourceModules.get(path)?.lowered.code\n : undefined,\n )\n : undefined,\n });\n pending = indexChunks();\n }\n await pending;\n for (const path of dependents.keys()) {\n this.addWatchFile(path);\n }\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: false,\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 async transform(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n const filePath = vite.normalizePath(id.split('?')[0]);\n const sourceFormat = scanner.sourceFormatOf(filePath);\n if (\n !(sourceFormat ? sourceFilter(id) : filter(id)) ||\n activeTransformFilter?.(code, id) === false\n ) {\n return;\n }\n await pending;\n let lowered: NgpLoweredModule | undefined;\n let compiledFile = filePath;\n if (sourceFormat) {\n const sourceFile = canonicalPath(filePath);\n const format = moduleFormatOf(sourceFile);\n if (!format) {\n this.error(\n `${filePath} is outside ${dirname(resolveTsConfigPath())}, where '${sourceFormat.name}' modules are compiled from.`,\n );\n }\n lowered = await withSourceLock(async () => {\n const result = await lowerForTransform(\n sourceFile,\n format,\n code,\n (spec, importer) =>\n this.resolve(spec, importer, { skipSelf: true }),\n );\n await syncProgramFiles();\n return result;\n });\n if (!lowered) {\n this.error(`${filePath} was removed while it was compiled.`);\n }\n if (lowered.error) {\n this.error({\n message: lowered.error.message,\n id: filePath,\n loc: lowered.error.loc && { file: filePath, ...lowered.error.loc },\n });\n }\n compiledFile = `${sourceFile}.ts`;\n // Transform the module again when a component it looked up changes\n for (const dependency of scanner.dependenciesOf(sourceFile)) {\n this.addWatchFile(dependency);\n }\n }\n const compiledCode = lowered ? lowered.code : code;\n const watch = (path: string) => this.addWatchFile(path);\n let result: NgpResult | undefined;\n try {\n result = await compileFile(compiledFile, watch);\n } catch (error) {\n // A failed compile stays cached until its file is updated, so only\n // report it if it compiled this content\n if (\n !sources.has(compiledFile) ||\n sources.get(compiledFile) === compiledCode\n ) {\n throw error;\n }\n }\n if (\n filesByPath.has(compiledFile) &&\n sources.get(compiledFile) !== compiledCode\n ) {\n if (lowered) analyzed.set(compiledFile, compiledCode);\n await enqueueIndex(() =>\n analyzer!.updateFileContent([\n {\n filePath: toAnalyzerPath(compiledFile),\n content: compiledCode,\n },\n ]),\n );\n result = await compileFile(compiledFile, watch);\n } else if (!result && lowered) {\n this.error(\n `${filePath} is not part of the TypeScript program of ${resolveTsConfigPath()}. Import it, or add it to the tsconfig's \\`include\\`.`,\n );\n } else if (!result && options.disableTypeChecking !== true) {\n await checkTypes(filePath, code);\n }\n let source = result?.magicString.toString() ?? code;\n if (result) {\n const analyzerFile = filesByPath.get(compiledFile)!.file.filePath;\n if (analyzerFile !== filePath) {\n // Component HMR ids name the analyzer's file; the dev server knows the module\n source = source.replaceAll(\n encodeURIComponent(`${analyzerFile}@`),\n encodeURIComponent(`${filePath}@`),\n );\n }\n }\n const map = result?.magicString.generateMap({\n source: compiledFile,\n includeContent: true,\n hires: true,\n });\n const transpiled = await transpile(source, compiledFile, map);\n const outputMap =\n lowered && transpiled.map\n ? lowered.mapToSource(JSON.stringify(transpiled.map))\n : transpiled.map;\n if (outputMap) {\n emittedMaps.set(\n filePath,\n typeof outputMap === 'string' ? outputMap : JSON.stringify(outputMap),\n );\n }\n return {\n code: transpiled.code,\n map: outputMap as vite.Rollup.SourceMapInput,\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 const normPath = vite.normalizePath(ctx.file);\n const sourceFile = canonicalPath(ctx.file);\n const programFile = programFileOf(sourceFile);\n const updates = await withSourceLock(async () => {\n // Lowered again in `watchChange`, which runs first\n const relowered = reloweredByChange.get(sourceFile) ?? [];\n reloweredByChange.delete(sourceFile);\n const lowered = programFile\n ? sourceModules.get(programFile)?.lowered\n : undefined;\n // In place only for a module that lowered without errors, which no\n // other module was lowered again against\n const componentUpdates =\n hmr &&\n !lowered?.error &&\n relowered.every((file) => file === programFile)\n ? await findComponentUpdates(\n programFile ?? normPath,\n lowered ? () => lowered.code : ctx.read,\n )\n : [];\n if (!programFile) {\n await enqueueIndex(() =>\n analyzer!.invalidateFiles([\n { filePath: toAnalyzerPath(ctx.file), updateType: FILE_CHANGED },\n ]),\n );\n }\n await syncProgramFiles();\n return componentUpdates;\n });\n if (updates.length && (await sendComponentUpdates(updates, ctx.server))) {\n return [];\n }\n hmrUpdateCode.clear();\n componentUpdates.classNames.clear();\n ctx.server.moduleGraph.invalidateAll();\n ctx.server.ws.send({ type: 'full-reload' });\n return [];\n },\n async buildEnd(error) {\n if (error || watchMode || !typeChecker) return;\n const typeErrors = await typeChecker.flushQueue();\n if (typeErrors.length) {\n throw new Error(typeErrors.join('\\n'));\n }\n },\n async closeBundle() {\n activeBuilds = Math.max(0, activeBuilds - 1);\n if (watchMode || activeBuilds > 0) return;\n await pending.catch(() => {});\n typeChecker?.close();\n typeChecker = undefined;\n analyzer?.close();\n analyzer = undefined;\n compiler = undefined;\n filesByPath.clear();\n chunkContexts.clear();\n output.clear();\n emittedMaps.clear();\n sources.clear();\n dependents.clear();\n sourceMod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ACf,gBAAgB,QAAQ,OAAO,IAAI,IACrC,IACA,CAAC;IACP,IAAI,CAAC,aACH,MAAM,mBACJ,SAAU,gBAAgB,CACxB;KAAE,UAAU,eAAe,IAAI,IAAI;KAAG,YAAY;IAAa,CACjE,CAAC,CACH;IAEF,MAAM,iBAAiB;IACvB,OAAO;GACT,CAAC;GACD,IAAI,QAAQ,UAAW,MAAM,qBAAqB,SAAS,IAAI,MAAM,GACnE,OAAO,CAAC;GAEV,cAAc,MAAM;GACpB,iBAAiB,WAAW,MAAM;GAClC,IAAI,OAAO,YAAY,cAAc;GACrC,IAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;GAC1C,OAAO,CAAC;EACV;EACA,MAAM,SAAS,OAAO;GACpB,IAAI,SAAS,aAAa,CAAC,aAAa;GACxC,MAAM,aAAa,MAAM,YAAY,WAAW;GAChD,IAAI,WAAW,QACb,MAAM,IAAI,MAAM,WAAW,KAAK,IAAI,CAAC;EAEzC;EACA,MAAM,cAAc;GAClB,eAAe,KAAK,IAAI,GAAG,eAAe,CAAC;GAC3C,IAAI,aAAa,eAAe,GAAG;GACnC,MAAM,QAAQ,YAAY,CAAC,CAAC;GAC5B,aAAa,MAAM;GACnB,cAAc,KAAA;GACd,UAAU,MAAM;GAChB,WAAW,KAAA;GACX,WAAW,KAAA;GACX,YAAY,MAAM;GAClB,cAAc,MAAM;GACpB,OAAO,MAAM;GACb,YAAY,MAAM;GAClB,QAAQ,MAAM;GACd,WAAW,MAAM;GACjB,cAAc,MAAM;GACpB,SAAS,MAAM;GACf,8BAA8B;EAChC;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"ngp-compile-plugin.js","names":["fsPromises"],"sources":["../../../src/lib/ngp-compile-plugin.ts"],"sourcesContent":["import * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, promises as fsPromises, realpathSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport type MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport * as vite from 'vite';\nimport {\n discoverAnalogIntegrations,\n type ComponentRegistryEntries,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport { ComponentScanner } from './component-scanner.js';\nimport type { FastCompileResolve } from './fast-compile-api.js';\nimport type { FastCompilePluginOptions } from './fast-compile-plugin.js';\nimport type {\n NgpCompileApi,\n NgpLoweredModule,\n NgpSourceFormat,\n} from './ngp-compile-api.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport {\n createDepOptimizerConfig,\n getTsConfigPath,\n isProdMode,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { angularFullVersion } from './utils/devkit.js';\nimport { findHmrComponentUpdates } from './utils/hmr-component-updates.js';\nimport {\n LspTypeChecker,\n type FileChangeType,\n type SourceLocation,\n} from './utils/lsp-type-checker.js';\nimport {\n canonicalPath,\n createNgpHostFs,\n fromWasmPath,\n toWasmPath,\n type NgpHostFs,\n} from './utils/ngp-host-fs.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport type { ComponentUpdates } from './live-reload-plugin.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\n// The unpublished NGP API is loaded at runtime. Model only the surface we use.\ninterface NgpDiagnostic {\n category: number;\n messageText: string;\n}\n\ninterface NgpFile {\n filePath: string;\n diagnostics?: NgpDiagnostic[];\n classes: {\n className?: string;\n component?: {\n templateUrl?: { resolvedPath: string };\n styleUrls?: { resolvedPath: string }[];\n stylesFromUrls?: string[];\n styles?: string[];\n };\n }[];\n}\n\ninterface NgpChunk {\n files: NgpFile[];\n removedFiles?: string[];\n}\n\ninterface NgpResult {\n magicString: MagicString;\n diagnostics?: NgpDiagnostic[];\n tcb?: { code: string } | null;\n hmrUpdateModule?: string | null;\n}\n\ninterface NgpAnalyzer {\n getFileContent(path: string): Promise<string>;\n updateFileContent(\n updates: { filePath: string; content: string }[],\n ): Promise<string[]>;\n invalidateFiles(\n updates: { filePath: string; updateType: number }[],\n ): Promise<string[]>;\n close(): void;\n}\n\ninterface NgpCompiler {\n // Parsed templates by file, cleared by NGP's own update methods\n fileCache: Map<string, unknown>;\n analyzeOptimized(): AsyncIterable<NgpChunk>;\n analyzeOptimizedDelta(): AsyncIterable<NgpChunk>;\n prepareChunk(chunk: NgpChunk): Promise<unknown>;\n processFile(\n path: string,\n content: string,\n ...args: [undefined, NgpFile, unknown] | [NgpFile, unknown]\n ): Promise<NgpResult>;\n}\n\ninterface ComponentUpdate {\n file: string;\n className: string;\n}\n\ninterface NgpAnalyzerOptions {\n nativeBinding?: string;\n backend?: 'wasm';\n wasmBinding?: string;\n enableHmr?: boolean;\n hostFs?: NgpHostFs;\n}\n\n/** NGP's `FileUpdateType`. */\nconst FILE_CREATED = 0;\nconst FILE_DELETED = 1;\nconst FILE_CHANGED = 2;\n\n/** A module of a registered source format, lowered to its program file. */\ninterface SourceModule {\n sourceFile: string;\n /** The source it was lowered from. */\n source: string;\n format: NgpSourceFormat;\n lowered: NgpLoweredModule;\n}\n\ninterface NgpApi {\n createAnalyzer(\n tsconfig: string,\n options: NgpAnalyzerOptions,\n ): Promise<NgpAnalyzer>;\n HybridCompiler: new (\n analyzer: NgpAnalyzer,\n options: Record<string, unknown> & {\n optimize: boolean;\n enableHmr: boolean;\n },\n ) => NgpCompiler;\n buildTypeCheckingConfig(options: Record<string, unknown>): unknown;\n}\n\nfunction isFastCompileOptions(\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// Interim NGP build bundled with this package until @angular/ngp is published\nconst BUNDLED_NGP = new URL('../../ngp/', import.meta.url);\n\n/**\n * @param needsHostFs Whether source formats are registered, which only the\n * WebAssembly backend can read through `hostFs`.\n */\nasync function loadNgp(\n tsconfig: string,\n needsHostFs: boolean,\n): Promise<{ api: NgpApi; analyzerOptions: NgpAnalyzerOptions }> {\n const nativeBinding = process.env['ANALOG_NGP_NATIVE_BINDING'];\n if (nativeBinding && needsHostFs) {\n throw new Error(\n \"[@analogjs/vite-plugin-angular]: Source formats such as TSRX can't be compiled with a native NGP analyzer build. Unset ANALOG_NGP_NATIVE_BINDING to use NGP's default WebAssembly analyzer.\",\n );\n }\n let modulePath = process.env['ANALOG_NGP_COMPILER'];\n if (!modulePath) {\n try {\n modulePath = createRequire(tsconfig).resolve('@angular/ngp');\n } catch {\n if (angularFullVersion < 220200) {\n throw new Error(\n \"[@analogjs/vite-plugin-angular]: compilation: 'ngp' requires Angular v22.2 or later.\",\n );\n }\n return {\n api: await import(new URL('api.mjs', BUNDLED_NGP).href),\n analyzerOptions: nativeBinding\n ? { nativeBinding }\n : {\n backend: 'wasm',\n wasmBinding: fileURLToPath(\n new URL('ng_analyze.cjs', BUNDLED_NGP),\n ),\n },\n };\n }\n }\n return {\n api: await import(pathToFileURL(resolve(modulePath)).href),\n analyzerOptions: nativeBinding\n ? { nativeBinding }\n : needsHostFs\n ? { backend: 'wasm' }\n : {},\n };\n}\n\nfunction transpile(\n source: string,\n filePath: string,\n map?: Parameters<typeof vite.transformWithEsbuild>[3],\n) {\n return vite.transformWithOxc\n ? vite.transformWithOxc(\n source,\n filePath,\n { lang: 'ts', sourcemap: true },\n map,\n )\n : vite.transformWithEsbuild(\n source,\n filePath,\n { loader: 'ts', sourcemap: true },\n map,\n );\n}\n\nexport function ngpCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): vite.Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompileOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n jit: false,\n ...optionsOrCtx,\n compilationBackend: 'ngp',\n });\n\n const options: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n if (options.jit || options.fastCompileMode === 'partial') {\n throw new Error(\n \"compilation: 'ngp' requires jit: false and fastCompileMode: 'full'.\",\n );\n }\n\n let configContext: TsConfigResolutionContext | undefined;\n let resolvedConfig: vite.ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let componentRegistries: ComponentRegistryEntries[] = [];\n let stylePreprocessor: StylePreprocessor | undefined;\n let watchMode = false;\n let hmr = false;\n let activeBuilds = 0;\n let analyzer: NgpAnalyzer | undefined;\n let compiler: NgpCompiler | undefined;\n let typeChecker: LspTypeChecker | undefined;\n let api: NgpApi;\n let toAnalyzerPath = (path: string) => path;\n let fromAnalyzerPath = vite.normalizePath;\n const filesByPath = new Map<string, { file: NgpFile; chunk: NgpChunk }>();\n const chunkContexts = new Map<NgpChunk, Promise<unknown>>();\n const output = new Map<string, Promise<NgpResult>>();\n const emittedMaps = new Map<string, string>();\n // Last compiled source of each file, compared on edits for HMR\n const sources = new Map<string, string>();\n // Watched files mapped to the source files that depend on them\n const dependents = new Map<string, Set<string>>();\n const hmrUpdateCode = new Map<string, string>();\n const classNames = sharedCtx\n ? sharedCtx.hmr.classNames\n : new Map<string, Set<string>>();\n const fileEmitter = (file: string, className: string) => ({\n hmrUpdateCode: hmrUpdateCode.get(`${file}@${className}`),\n });\n sharedCtx?.hmr.setFileEmitter(fileEmitter);\n\n const componentUpdates: ComponentUpdates = {\n classNames,\n fileEmitter,\n };\n let pending = Promise.resolve();\n const excluded = [\n /node_modules/,\n /[?&]raw\\b/,\n /type=script/,\n /@ng\\/component/,\n ];\n const filter = vite.createFilter(TS_EXT_REGEX, excluded);\n const sourceFilter = vite.createFilter(null, excluded);\n\n // Source formats registered through `api.ngp`, the component registry their\n // lowering looks selectors up in, and their modules by program file\n // (`x.tsrx` → `x.tsrx.ts`)\n const sourceFormats: NgpSourceFormat[] = [];\n const scanner = new ComponentScanner();\n const sourceModules = new Map<string, SourceModule>();\n // Per program file: how often it was removed, which cancels a lowering in\n // progress, and the lowered code the analyzer has\n const removals = new Map<string, number>();\n const analyzed = new Map<string, string>();\n // Which modules of each format NGP compiles: its `include` under the tsconfig's directory\n const includes = new Map<NgpSourceFormat, (file: string) => boolean>();\n const moduleFormatOf = (file: string): NgpSourceFormat | undefined =>\n sourceFormats.find(\n (format) => format.test(file) && includes.get(format)?.(file),\n );\n let devServer: vite.ViteDevServer | undefined;\n // The program files a file change lowered again, for the hot update after it\n const reloweredByChange = new Map<string, string[]>();\n const programFileOf = (file: string): string | undefined => {\n const programFile = `${file}.ts`;\n return sourceModules.has(programFile) ? programFile : undefined;\n };\n const sourceFileOf = (file: string): string =>\n sourceModules.get(file)?.sourceFile ?? file;\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const ctx = configContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n ctx.root,\n options.tsconfigGetter(),\n ctx.isProd,\n options.isTest,\n ctx.isLib,\n options.workspaceRoot,\n );\n }\n\n const ngp: NgpCompileApi = {\n registerSourceFormat(format) {\n if (!sourceFormats.includes(format)) {\n sourceFormats.push(format);\n scanner.registerSourceFormat(format);\n }\n },\n };\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(vite.normalizePath(id)),\n hasEmitted: (id: string): boolean =>\n filesByPath.has(vite.normalizePath(id)),\n output,\n ready: (): Promise<void> => pending,\n componentUpdates,\n ngp,\n };\n\n /** Lowers a module of a source format. Returns whether its TypeScript changed. */\n async function lowerSourceModule(\n sourceFile: string,\n source: string,\n format: NgpSourceFormat,\n resolve: FastCompileResolve,\n ): Promise<boolean> {\n const programFile = `${sourceFile}.ts`;\n if (existsSync(programFile)) {\n throw new Error(\n `[@analogjs/vite-plugin-angular]: ${programFile} has the name NGP compiles ${sourceFile} as. Rename one of them.`,\n );\n }\n const removed = removals.get(programFile);\n const lowered = await format.lower(source, sourceFile, {\n scanImports: (specifiers) =>\n scanner.scanImports(specifiers, sourceFile, resolve),\n resolveSelector: (className, moduleSpecifier, containingFile) =>\n scanner.lookupSelector(\n className,\n sharedCtx?.componentRegistries ?? componentRegistries,\n moduleSpecifier !== undefined\n ? {\n moduleSpecifier,\n containingFile: containingFile ?? sourceFile,\n }\n : undefined,\n ),\n });\n // Removed while it was lowered\n if (removals.get(programFile) !== removed) return false;\n const changed =\n sourceModules.get(programFile)?.lowered.code !== lowered.code;\n sourceModules.set(programFile, { sourceFile, source, format, lowered });\n return changed;\n }\n\n /** Lowers every module of the registered source formats under `root`. */\n async function lowerSourceModules(\n root: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n scanner.reset(root);\n sourceModules.clear();\n const sourceRoot = vite.normalizePath(realpathSync(root));\n await Promise.all(\n sourceFormats.map(async (format) => {\n includes.set(\n format,\n vite.createFilter(format.include, '**/node_modules/**', {\n resolve: sourceRoot,\n }),\n );\n const files = await glob(format.include, {\n cwd: sourceRoot,\n absolute: true,\n ignore: ['**/node_modules/**'],\n });\n await Promise.all(\n files.map(async (file) => {\n const sourceFile = canonicalPath(file);\n const source = await fsPromises.readFile(sourceFile, 'utf-8');\n await lowerSourceModule(sourceFile, source, format, resolve);\n }),\n );\n }),\n );\n // The analyzer reads them through `hostFs` when it's created\n analyzed.clear();\n for (const [programFile, { lowered }] of sourceModules) {\n analyzed.set(programFile, lowered.code);\n }\n }\n\n /**\n * Lowers the source modules a change to `file` affects again: the module\n * itself, and those that looked up selectors in it. Returns the program\n * files whose TypeScript changed.\n */\n async function relowerSourceModules(\n file: string,\n resolve: FastCompileResolve,\n ): Promise<string[]> {\n const affected = [file, ...(scanner.importersByFile.get(file) ?? [])]\n .map(programFileOf)\n .filter((programFile) => programFile !== undefined);\n scanner.invalidate(file);\n const changed = await Promise.all(\n affected.map(async (programFile) => {\n const sourceModule = sourceModules.get(programFile);\n if (!sourceModule) return [];\n const { sourceFile, format } = sourceModule;\n const source = await readSource(sourceFile);\n if (source === undefined) return [];\n const relowered = await lowerSourceModule(\n sourceFile,\n source,\n format,\n resolve,\n );\n return relowered ? [programFile] : [];\n }),\n );\n return changed.flat();\n }\n\n // Lowering and the analyzer updates that follow it, one change at a time, so\n // the modules a change lowers again reach the analyzer together\n let sourceWork: Promise<unknown> = Promise.resolve();\n function withSourceLock<T>(work: () => Promise<T>): Promise<T> {\n const run = sourceWork.catch(() => undefined).then(work);\n sourceWork = run;\n return run;\n }\n\n /** Sends the analyzer the lowered modules it doesn't have yet. */\n async function syncProgramFiles(): Promise<void> {\n const updates = [...sourceModules]\n .filter(\n ([filePath, { lowered }]) => analyzed.get(filePath) !== lowered.code,\n )\n .map(([filePath, { lowered }]) => ({ filePath, content: lowered.code }));\n if (updates.length === 0) return;\n for (const { filePath, content } of updates)\n analyzed.set(filePath, content);\n await enqueueIndex(() =>\n analyzer!.updateFileContent(\n updates.map(({ filePath, content }) => ({\n filePath: toAnalyzerPath(filePath),\n content,\n })),\n ),\n );\n }\n\n /** Reads a source file, or `undefined` if it was removed. */\n function readSource(file: string): Promise<string | undefined> {\n return fsPromises\n .readFile(file, 'utf-8')\n .catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n }\n\n /** Lowers a module added after the build started, if NGP compiles it. */\n async function addSourceModule(\n sourceFile: string,\n format: NgpSourceFormat,\n source: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n const programFile = `${sourceFile}.ts`;\n await lowerSourceModule(sourceFile, source, format, resolve);\n const sourceModule = sourceModules.get(programFile);\n // Removed while it was lowered\n if (!sourceModule) return;\n // The analyzer reads it through `hostFs`\n analyzed.set(programFile, sourceModule.lowered.code);\n await enqueueIndex(() =>\n analyzer!.invalidateFiles([\n { filePath: toAnalyzerPath(programFile), updateType: FILE_CREATED },\n ]),\n );\n }\n\n /** Drops a removed module, and any lowering of it still in progress. */\n async function removeSourceModule(sourceFile: string): Promise<void> {\n const programFile = `${sourceFile}.ts`;\n removals.set(programFile, (removals.get(programFile) ?? 0) + 1);\n analyzed.delete(programFile);\n if (!sourceModules.delete(programFile)) return;\n await enqueueIndex(() =>\n analyzer!.invalidateFiles([\n { filePath: toAnalyzerPath(programFile), updateType: FILE_DELETED },\n ]),\n );\n }\n\n /**\n * Lowers a module for its transform, as fast compile does on every\n * transform, so the selectors it looks up are current. A transform that\n * started before a hot update can carry the previous code; it compiles the\n * latest lowering instead.\n */\n async function lowerForTransform(\n sourceFile: string,\n format: NgpSourceFormat,\n code: string,\n resolve: FastCompileResolve,\n ): Promise<NgpLoweredModule | undefined> {\n const programFile = `${sourceFile}.ts`;\n if (!sourceModules.has(programFile)) {\n // Requested before its `create` event, or added during `vite build --watch`\n await addSourceModule(sourceFile, format, code, resolve);\n } else if (code === (await readSource(sourceFile))) {\n await lowerSourceModule(sourceFile, code, format, resolve);\n }\n return sourceModules.get(programFile)?.lowered;\n }\n\n /** Maps a type error in a program file to the source module's location. */\n function toSourceLocation(location: SourceLocation): SourceLocation {\n const sourceModule = sourceModules.get(vite.normalizePath(location.file));\n const mapped = sourceModule?.lowered.toSourceLocation(\n location.line - 1,\n location.character - 1,\n );\n return mapped\n ? {\n file: sourceModule!.sourceFile,\n line: mapped.line + 1,\n character: mapped.column + 1,\n }\n : location;\n }\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-ngp',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n async function prepareResources(\n file: NgpFile,\n watch: (path: string) => void,\n ): Promise<NgpFile> {\n const hostFilePath = fromAnalyzerPath(file.filePath);\n watch(hostFilePath);\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n\n return {\n ...file,\n classes: await Promise.all(\n file.classes.map(async (metadata, classIndex) => {\n const component = metadata.component;\n if (!component) return metadata;\n if (component.templateUrl)\n watch(fromAnalyzerPath(component.templateUrl.resolvedPath));\n for (const style of component.styleUrls ?? [])\n watch(fromAnalyzerPath(style.resolvedPath));\n const preprocess = async (\n content: string,\n path: string,\n order: number,\n inline: boolean,\n ) => {\n const preprocessed = preprocessStylesheet(\n content,\n path,\n activeStylePreprocessor,\n {\n filename: path,\n containingFile: hostFilePath,\n resourceFile: inline ? undefined : path,\n className: metadata.className,\n order,\n inline,\n },\n );\n const result = await vite.preprocessCSS(\n preprocessed,\n path,\n activeConfig,\n );\n result.deps?.forEach(watch);\n return result.code;\n };\n return {\n ...metadata,\n component: {\n ...component,\n styles:\n component.styles &&\n (await Promise.all(\n component.styles.map((style, index) =>\n preprocess(\n style,\n `${hostFilePath}.inline-${classIndex}-${index}.${options.inlineStylesExtension}`,\n index,\n true,\n ),\n ),\n )),\n stylesFromUrls:\n component.stylesFromUrls &&\n (await Promise.all(\n component.stylesFromUrls.map((style, index) =>\n preprocess(\n style,\n fromAnalyzerPath(\n component.styleUrls![index].resolvedPath,\n ),\n index,\n false,\n ),\n ),\n )),\n },\n };\n }),\n ),\n };\n }\n\n async function indexChunks(update?: () => Promise<string[]>): Promise<void> {\n if (update) {\n const invalidated = await update();\n for (const filePath of invalidated) {\n output.delete(fromAnalyzerPath(filePath));\n compiler!.fileCache.delete(filePath);\n }\n chunkContexts.clear();\n } else {\n filesByPath.clear();\n chunkContexts.clear();\n output.clear();\n const angularOptions = compilerCli.readConfiguration(\n resolveTsConfigPath(),\n ).options as Record<string, unknown>;\n compiler = new api.HybridCompiler(analyzer!, {\n ...angularOptions,\n optimize: true,\n enableHmr: hmr,\n tcbConfig: api.buildTypeCheckingConfig(angularOptions),\n });\n }\n const chunks = update\n ? compiler!.analyzeOptimizedDelta()\n : compiler!.analyzeOptimized();\n for await (const chunk of chunks) {\n for (const file of chunk.files) {\n const normPath = fromAnalyzerPath(file.filePath);\n filesByPath.set(normPath, { file, chunk });\n output.delete(normPath);\n compiler!.fileCache.delete(file.filePath);\n }\n for (const removed of chunk.removedFiles ?? []) {\n const normPath = fromAnalyzerPath(removed);\n filesByPath.delete(normPath);\n output.delete(normPath);\n }\n }\n }\n\n function enqueueIndex(update: () => Promise<string[]>): Promise<void> {\n pending = pending.catch(() => {}).then(() => indexChunks(update));\n return pending;\n }\n\n function getChunkContext(chunk: NgpChunk): Promise<unknown> {\n let context = chunkContexts.get(chunk);\n if (!context) {\n context = compiler!.prepareChunk(chunk);\n chunkContexts.set(chunk, context);\n }\n return context;\n }\n\n async function checkTypes(\n filePath: string,\n sourceCode: string,\n tcbCode?: string | null,\n ): Promise<void> {\n typeChecker ??= new LspTypeChecker(\n resolveTsConfigPath(),\n options.typeChecker,\n {\n inMemoryFiles: () =>\n new Map(\n [...sourceModules].map(([file, { lowered }]) => [\n file,\n lowered.code,\n ]),\n ),\n mapLocation: toSourceLocation,\n },\n );\n typeChecker.queueFile(filePath, sourceCode, tcbCode);\n if (!watchMode) return;\n const typeErrors = await typeChecker.flushQueue(true);\n if (typeErrors.length) {\n throw new Error(typeErrors.join('\\n'));\n }\n }\n\n async function processFile(\n normPath: string,\n activeCompiler: NgpCompiler,\n watch: (path: string) => void,\n ) {\n const { file: analyzed, chunk } = filesByPath.get(normPath)!;\n const [file, context, content] = await Promise.all([\n prepareResources(analyzed, (path) => {\n const key = sourceFileOf(vite.normalizePath(path));\n dependents.set(key, (dependents.get(key) ?? new Set()).add(normPath));\n watch(key);\n }),\n getChunkContext(chunk),\n analyzer!.getFileContent(analyzed.filePath),\n ]);\n sources.set(normPath, content);\n const result =\n activeCompiler.processFile.length >= 5\n ? await activeCompiler.processFile(\n file.filePath,\n content,\n undefined,\n file,\n context,\n )\n : await activeCompiler.processFile(\n file.filePath,\n content,\n file,\n context,\n );\n return { file, content, result };\n }\n\n function compileFile(\n normPath: string,\n watch: (path: string) => void,\n ): Promise<NgpResult> | undefined {\n if (!filesByPath.has(normPath)) return undefined;\n let task = output.get(normPath);\n if (!task) {\n task = (async () => {\n // Analyzer updates queued before this compile land first\n await pending;\n if (!filesByPath.has(normPath)) {\n throw new Error(`${sourceFileOf(normPath)} was removed.`);\n }\n const { file, content, result } = await processFile(\n normPath,\n compiler!,\n watch,\n );\n const errors = [\n ...(file.diagnostics ?? []),\n ...(result.diagnostics ?? []),\n ].filter((diagnostic) => diagnostic.category === 1);\n if (errors.length) {\n throw new Error(\n `${sourceFileOf(normPath)}: ${errors.map((error) => error.messageText).join('\\n')}`,\n );\n }\n if (options.disableTypeChecking !== true) {\n await checkTypes(\n fromAnalyzerPath(file.filePath),\n content,\n result.tcb?.code,\n );\n }\n return result;\n })();\n output.set(normPath, task);\n }\n return task;\n }\n\n function componentNames(normPath: string): string[] {\n return (filesByPath.get(normPath)?.file.classes ?? []).flatMap(\n ({ className, component }) => (component && className ? [className] : []),\n );\n }\n\n // Components to update in place, following the Angular CLI's rule\n async function findComponentUpdates(\n normPath: string,\n read: () => string | Promise<string>,\n ): Promise<ComponentUpdate[]> {\n if (!TS_EXT_REGEX.test(normPath)) {\n return [...(dependents.get(normPath) ?? [])].flatMap((file) =>\n componentNames(file).map((className) => ({ file, className })),\n );\n }\n const stale = sources.get(normPath);\n if (stale === undefined) return [];\n const matchedClassNames = findHmrComponentUpdates(\n normPath,\n stale,\n await read(),\n new Set(componentNames(normPath)),\n );\n return (matchedClassNames ?? []).map((className) => ({\n file: normPath,\n className,\n }));\n }\n\n async function emitHmrUpdate(file: string, className: string) {\n // NGP emits only the update module of the class named by `hmrUpdateTarget`,\n // and only when it doesn't reuse the file's previously processed output\n const target = Object.assign(\n Object.create(Object.getPrototypeOf(compiler)),\n compiler,\n { hmrUpdateTarget: className, reuseProcessedFiles: false },\n );\n const { result } = await processFile(file, target, () => {});\n return (\n result.hmrUpdateModule &&\n (await transpile(result.hmrUpdateModule, file)).code\n );\n }\n\n async function sendComponentUpdates(\n updates: ComponentUpdate[],\n server: vite.ViteDevServer,\n ): Promise<boolean> {\n try {\n for (const file of new Set(updates.map((update) => update.file))) {\n await compileFile(file, () => {});\n }\n const codes = await Promise.all(\n updates.map(({ file, className }) => emitHmrUpdate(file, className)),\n );\n if (codes.some((code) => !code)) return false;\n updates.forEach(({ file, className }, index) => {\n // Components of a source module update through the module itself\n const sourceFile = sourceModules.get(file)?.sourceFile;\n const moduleFile = sourceFile ?? file;\n hmrUpdateCode.set(`${moduleFile}@${className}`, codes[index]!);\n let fileClasses = componentUpdates.classNames.get(moduleFile);\n if (!fileClasses) {\n fileClasses = new Set<string>();\n componentUpdates.classNames.set(moduleFile, fileClasses);\n }\n fileClasses.add(className);\n server.moduleGraph\n .getModulesByFile(moduleFile)\n ?.forEach((mod) => server.moduleGraph.invalidateModule(mod));\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(`${moduleFile}@${className}`),\n timestamp: Date.now(),\n });\n });\n return true;\n } catch {\n // A full reload reports the compilation error\n return false;\n }\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-ngp',\n enforce: 'pre',\n api: compilerApi,\n config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n configContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config.build?.lib,\n };\n }\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: resolveTsConfigPath(),\n isProd,\n jit: false,\n watchMode,\n isTest: options.isTest,\n isAstroIntegration: options.isAstroIntegration,\n });\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n hmr =\n watchMode &&\n options.liveReload &&\n !options.isTest &&\n config.server.hmr !== false;\n const integrations = sharedCtx\n ? await sharedCtx.resolveConfig(config)\n : await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n componentRegistries = integrations.componentRegistries;\n stylePreprocessor = integrations.stylePreprocessor;\n },\n configureServer(server) {\n const changeTypes: Record<string, FileChangeType> = {\n add: 1,\n change: 2,\n unlink: 3,\n };\n devServer = server;\n server.watcher.on('all', (event, path) => {\n const type = changeTypes[event];\n if (type) typeChecker?.notifyFileChanged(path, type);\n });\n server.httpServer?.on('close', () => {\n typeChecker?.close();\n typeChecker = undefined;\n analyzer?.close();\n analyzer = undefined;\n compiler = undefined;\n });\n },\n // Runs on the dev server with or without HMR, and in `vite build --watch`\n async watchChange(id, { event }) {\n if (!analyzer || sourceFormats.length === 0) return;\n const file = canonicalPath(id);\n const resolve: FastCompileResolve = (spec, importer) =>\n this.resolve(spec, importer, { skipSelf: true });\n await withSourceLock(async () => {\n scanner.invalidate(file);\n const format = moduleFormatOf(file);\n if (event === 'update') {\n reloweredByChange.set(\n file,\n await relowerSourceModules(file, resolve),\n );\n } else if (event === 'delete') {\n await removeSourceModule(file);\n } else if (\n event === 'create' &&\n format &&\n !sourceModules.has(`${file}.ts`)\n ) {\n const source = await readSource(file);\n if (source !== undefined) {\n await addSourceModule(file, format, source, resolve);\n }\n }\n await syncProgramFiles();\n });\n // Modules that looked up selectors in `file` lower again when transformed\n for (const importer of scanner.importersByFile.get(file) ?? []) {\n devServer?.moduleGraph\n .getModulesByFile(importer)\n ?.forEach((mod) => devServer!.moduleGraph.invalidateModule(mod));\n }\n },\n async buildStart() {\n activeBuilds++;\n if (!analyzer) {\n const tsconfig = resolveTsConfigPath();\n const hasSourceFormats = sourceFormats.length > 0;\n const ngp = await loadNgp(tsconfig, hasSourceFormats);\n const isWasm = ngp.analyzerOptions.backend === 'wasm';\n toAnalyzerPath = isWasm ? toWasmPath : (path) => path;\n fromAnalyzerPath = isWasm ? fromWasmPath : vite.normalizePath;\n api = ngp.api;\n if (hasSourceFormats) {\n await lowerSourceModules(dirname(tsconfig), (specifier, importer) =>\n this.resolve(specifier, importer, { skipSelf: true }),\n );\n }\n analyzer = await api.createAnalyzer(toAnalyzerPath(tsconfig), {\n ...ngp.analyzerOptions,\n enableHmr: hmr,\n hostFs:\n hasSourceFormats || isWasm\n ? createNgpHostFs(\n hasSourceFormats\n ? (path) => sourceModules.get(path)?.lowered.code\n : undefined,\n )\n : undefined,\n });\n pending = indexChunks();\n }\n await pending;\n for (const path of dependents.keys()) {\n this.addWatchFile(path);\n }\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: false,\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 async transform(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n const filePath = vite.normalizePath(id.split('?')[0]);\n const sourceFormat = scanner.sourceFormatOf(filePath);\n if (\n !(sourceFormat ? sourceFilter(id) : filter(id)) ||\n activeTransformFilter?.(code, id) === false\n ) {\n return;\n }\n await pending;\n let lowered: NgpLoweredModule | undefined;\n let compiledFile = filePath;\n if (sourceFormat) {\n const sourceFile = canonicalPath(filePath);\n const format = moduleFormatOf(sourceFile);\n if (!format) {\n this.error(\n `${filePath} is outside ${dirname(resolveTsConfigPath())}, where '${sourceFormat.name}' modules are compiled from.`,\n );\n }\n lowered = await withSourceLock(async () => {\n const result = await lowerForTransform(\n sourceFile,\n format,\n code,\n (spec, importer) =>\n this.resolve(spec, importer, { skipSelf: true }),\n );\n await syncProgramFiles();\n return result;\n });\n if (!lowered) {\n this.error(`${filePath} was removed while it was compiled.`);\n }\n if (lowered.error) {\n this.error({\n message: lowered.error.message,\n id: filePath,\n loc: lowered.error.loc && { file: filePath, ...lowered.error.loc },\n });\n }\n compiledFile = `${sourceFile}.ts`;\n // Transform the module again when a component it looked up changes\n for (const dependency of scanner.dependenciesOf(sourceFile)) {\n this.addWatchFile(dependency);\n }\n }\n const compiledCode = lowered ? lowered.code : code;\n const watch = (path: string) => this.addWatchFile(path);\n let result: NgpResult | undefined;\n try {\n result = await compileFile(compiledFile, watch);\n } catch (error) {\n // A failed compile stays cached until its file is updated, so only\n // report it if it compiled this content\n if (\n !sources.has(compiledFile) ||\n sources.get(compiledFile) === compiledCode\n ) {\n throw error;\n }\n }\n if (\n filesByPath.has(compiledFile) &&\n sources.get(compiledFile) !== compiledCode\n ) {\n if (lowered) analyzed.set(compiledFile, compiledCode);\n await enqueueIndex(() =>\n analyzer!.updateFileContent([\n {\n filePath: toAnalyzerPath(compiledFile),\n content: compiledCode,\n },\n ]),\n );\n result = await compileFile(compiledFile, watch);\n } else if (!result && lowered) {\n this.error(\n `${filePath} is not part of the TypeScript program of ${resolveTsConfigPath()}. Import it, or add it to the tsconfig's \\`include\\`.`,\n );\n } else if (!result && options.disableTypeChecking !== true) {\n await checkTypes(filePath, code);\n }\n let source = result?.magicString.toString() ?? code;\n if (result) {\n const analyzerFile = filesByPath.get(compiledFile)!.file.filePath;\n if (analyzerFile !== filePath) {\n // Component HMR ids name the analyzer's file; the dev server knows the module\n source = source.replaceAll(\n encodeURIComponent(`${analyzerFile}@`),\n encodeURIComponent(`${filePath}@`),\n );\n }\n }\n const map = result?.magicString.generateMap({\n source: compiledFile,\n includeContent: true,\n hires: true,\n });\n const transpiled = await transpile(source, compiledFile, map);\n const outputMap =\n lowered && transpiled.map\n ? lowered.mapToSource(JSON.stringify(transpiled.map))\n : transpiled.map;\n if (outputMap) {\n emittedMaps.set(\n filePath,\n typeof outputMap === 'string' ? outputMap : JSON.stringify(outputMap),\n );\n }\n return {\n code: transpiled.code,\n map: outputMap as vite.Rollup.SourceMapInput,\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 const normPath = vite.normalizePath(ctx.file);\n const sourceFile = canonicalPath(ctx.file);\n const programFile = programFileOf(sourceFile);\n const updates = await withSourceLock(async () => {\n // Lowered again in `watchChange`, which runs first\n const relowered = reloweredByChange.get(sourceFile) ?? [];\n reloweredByChange.delete(sourceFile);\n const lowered = programFile\n ? sourceModules.get(programFile)?.lowered\n : undefined;\n // In place only for a module that lowered without errors, which no\n // other module was lowered again against\n const componentUpdates =\n hmr &&\n !lowered?.error &&\n relowered.every((file) => file === programFile)\n ? await findComponentUpdates(\n programFile ?? normPath,\n lowered ? () => lowered.code : ctx.read,\n )\n : [];\n if (!programFile) {\n await enqueueIndex(() =>\n analyzer!.invalidateFiles([\n { filePath: toAnalyzerPath(ctx.file), updateType: FILE_CHANGED },\n ]),\n );\n }\n await syncProgramFiles();\n return componentUpdates;\n });\n if (updates.length && (await sendComponentUpdates(updates, ctx.server))) {\n return [];\n }\n hmrUpdateCode.clear();\n componentUpdates.classNames.clear();\n ctx.server.moduleGraph.invalidateAll();\n ctx.server.ws.send({ type: 'full-reload' });\n return [];\n },\n async buildEnd(error) {\n if (error || watchMode || !typeChecker) return;\n const typeErrors = await typeChecker.flushQueue();\n if (typeErrors.length) {\n throw new Error(typeErrors.join('\\n'));\n }\n },\n async closeBundle() {\n activeBuilds = Math.max(0, activeBuilds - 1);\n if (watchMode || activeBuilds > 0) return;\n await pending.catch(() => {});\n typeChecker?.close();\n typeChecker = undefined;\n analyzer?.close();\n analyzer = undefined;\n compiler = undefined;\n filesByPath.clear();\n chunkContexts.clear();\n output.clear();\n emittedMaps.clear();\n sources.clear();\n dependents.clear();\n sourceModules.clear();\n analyzed.clear();\n releaseCssPreprocessorWorkers();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiIA,IAAM,eAAe;AACrB,IAAM,eAAe;AACrB,IAAM,eAAe;AA0BrB,SAAS,qBACP,OACmC;CACn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ACP,IAAI,CAAC,aACH,MAAM,mBACJ,SAAU,gBAAgB,CACxB;KAAE,UAAU,eAAe,IAAI,IAAI;KAAG,YAAY;IAAa,CACjE,CAAC,CACH;IAEF,MAAM,iBAAiB;IACvB,OAAO;GACT,CAAC;GACD,IAAI,QAAQ,UAAW,MAAM,qBAAqB,SAAS,IAAI,MAAM,GACnE,OAAO,CAAC;GAEV,cAAc,MAAM;GACpB,iBAAiB,WAAW,MAAM;GAClC,IAAI,OAAO,YAAY,cAAc;GACrC,IAAI,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;GAC1C,OAAO,CAAC;EACV;EACA,MAAM,SAAS,OAAO;GACpB,IAAI,SAAS,aAAa,CAAC,aAAa;GACxC,MAAM,aAAa,MAAM,YAAY,WAAW;GAChD,IAAI,WAAW,QACb,MAAM,IAAI,MAAM,WAAW,KAAK,IAAI,CAAC;EAEzC;EACA,MAAM,cAAc;GAClB,eAAe,KAAK,IAAI,GAAG,eAAe,CAAC;GAC3C,IAAI,aAAa,eAAe,GAAG;GACnC,MAAM,QAAQ,YAAY,CAAC,CAAC;GAC5B,aAAa,MAAM;GACnB,cAAc,KAAA;GACd,UAAU,MAAM;GAChB,WAAW,KAAA;GACX,WAAW,KAAA;GACX,YAAY,MAAM;GAClB,cAAc,MAAM;GACpB,OAAO,MAAM;GACb,YAAY,MAAM;GAClB,QAAQ,MAAM;GACd,WAAW,MAAM;GACjB,cAAc,MAAM;GACpB,SAAS,MAAM;GACf,8BAA8B;EAChC;CACF;AACF"}
|
|
@@ -5,11 +5,11 @@ import { type AngularBuildContext, type AngularBuildContextOptions } from "./ang
|
|
|
5
5
|
export interface FileMetadataResult {
|
|
6
6
|
errors?: string[];
|
|
7
7
|
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
8
|
-
|
|
8
|
+
hmrUpdateCodes?: Map<string, string>;
|
|
9
9
|
hmrEligible?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
|
|
12
|
-
classNamesMap: Map<string, string
|
|
12
|
+
classNamesMap: Map<string, Set<string>>;
|
|
13
13
|
fileTransformMap: Map<string, string>;
|
|
14
14
|
}): void;
|
|
15
15
|
export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
|
|
@@ -20,4 +20,4 @@ export declare function ngtscCompilePlugin(ctxOrOptions?: AngularBuildContext |
|
|
|
20
20
|
/**
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
|
-
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean, classNamesMap?: Map<string, string
|
|
23
|
+
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean, classNamesMap?: Map<string, Set<string>>): (file: string) => FileMetadataResult;
|
|
@@ -113,7 +113,7 @@ function ngtscCompilePlugin(ctxOrOptions) {
|
|
|
113
113
|
});
|
|
114
114
|
return emittedResult;
|
|
115
115
|
};
|
|
116
|
-
ctx.hmr.setFileEmitter((file) => fileEmitter(file));
|
|
116
|
+
ctx.hmr.setFileEmitter((file, className) => ({ hmrUpdateCode: fileEmitter(file)?.hmrUpdateCodes?.get(className) }));
|
|
117
117
|
const compilerApi = {
|
|
118
118
|
angularCompiler: true,
|
|
119
119
|
getTsConfigPath: () => ctx.resolveTsConfigPath(),
|
|
@@ -308,7 +308,7 @@ function ngtscCompilePlugin(ctxOrOptions) {
|
|
|
308
308
|
dependencies: [],
|
|
309
309
|
errors: metadata.errors,
|
|
310
310
|
warnings: metadata.warnings,
|
|
311
|
-
|
|
311
|
+
hmrUpdateCodes: metadata.hmrUpdateCodes,
|
|
312
312
|
hmrEligible: metadata.hmrEligible
|
|
313
313
|
});
|
|
314
314
|
debugEmitV("registered ngtsc output", {
|
|
@@ -459,34 +459,36 @@ function ngtscCompilePlugin(ctxOrOptions) {
|
|
|
459
459
|
let result;
|
|
460
460
|
if (ctx.shouldEnableLiveReload()) {
|
|
461
461
|
result = fileEmitter(fileId);
|
|
462
|
+
const fileClassNames = ctx.hmr.classNames.get(fileId);
|
|
462
463
|
debugHmr("TS file emitted", {
|
|
463
464
|
fileId,
|
|
464
465
|
hmrEligible: !!result?.hmrEligible,
|
|
465
|
-
hasClassName: !!
|
|
466
|
+
hasClassName: !!fileClassNames?.size
|
|
466
467
|
});
|
|
467
468
|
debugHmrV("ts hmr evaluation", {
|
|
468
469
|
file: hmrCtx.file,
|
|
469
470
|
fileId,
|
|
470
471
|
hasResult: !!result,
|
|
471
472
|
hmrEligible: !!result?.hmrEligible,
|
|
472
|
-
hasClassName: !!
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
hasClassName: !!fileClassNames?.size,
|
|
474
|
+
classNames: fileClassNames ? [...fileClassNames] : void 0,
|
|
475
|
+
updateCodes: result?.hmrUpdateCodes ? Object.fromEntries([...result.hmrUpdateCodes].map(([name, code]) => [name, describeStylesheetContent(code)])) : void 0,
|
|
475
476
|
errors: result?.errors?.length ?? 0,
|
|
476
477
|
warnings: result?.warnings?.length ?? 0,
|
|
477
478
|
hint: result?.hmrEligible ? "A TS-side component change, including inline template edits, produced an Angular HMR payload." : "No Angular HMR payload was emitted for this TS change; the change may not affect component template state."
|
|
478
479
|
});
|
|
479
480
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
481
|
+
const tsUpdateIds = ctx.shouldEnableLiveReload() && result?.hmrEligible ? ctx.hmr.toComponentUpdateIds(fileId) : [];
|
|
482
|
+
if (tsUpdateIds.length > 0) {
|
|
483
|
+
for (const relativeFileId of tsUpdateIds) {
|
|
484
|
+
debugHmr("sending component update", { relativeFileId });
|
|
485
|
+
debugHmrV("ts hmr component update payload", {
|
|
486
|
+
file: hmrCtx.file,
|
|
487
|
+
fileId,
|
|
488
|
+
relativeFileId
|
|
489
|
+
});
|
|
490
|
+
ctx.hmr.sendComponentUpdate(hmrCtx.server, relativeFileId);
|
|
491
|
+
}
|
|
490
492
|
return hmrCtx.modules.map((mod) => {
|
|
491
493
|
if (mod.id === hmrCtx.file) return markModuleSelfAccepting(mod);
|
|
492
494
|
return mod;
|
|
@@ -544,14 +546,14 @@ function ngtscCompilePlugin(ctxOrOptions) {
|
|
|
544
546
|
const ownerIds = ownerModules.map((mod) => mod.id).filter(Boolean);
|
|
545
547
|
ownerModules.forEach((mod) => hmrCtx.server.moduleGraph.invalidateModule(mod));
|
|
546
548
|
await hotUpdates.schedule(hmrCtx.file, ownerIds);
|
|
547
|
-
const updates = ownerIds.filter((id) => ctx.hmr.classNames.get(id));
|
|
549
|
+
const updates = ownerIds.filter((id) => ctx.hmr.classNames.get(id)?.size);
|
|
548
550
|
debugHmrV("template owner recompilation result", {
|
|
549
551
|
file: hmrCtx.file,
|
|
550
552
|
ownerIds,
|
|
551
553
|
updates,
|
|
552
554
|
updateClassNames: updates.map((id) => ({
|
|
553
555
|
id,
|
|
554
|
-
|
|
556
|
+
classNames: [...ctx.hmr.classNames.get(id) ?? []]
|
|
555
557
|
})),
|
|
556
558
|
hint: updates.length > 0 ? "External template recompilation produced Angular component update targets." : "External template recompilation completed, but no Angular component update targets were surfaced."
|
|
557
559
|
});
|
|
@@ -562,7 +564,7 @@ function ngtscCompilePlugin(ctxOrOptions) {
|
|
|
562
564
|
updateCount: updates.length
|
|
563
565
|
});
|
|
564
566
|
updates.forEach((updateId) => {
|
|
565
|
-
ctx.hmr.sendComponentUpdate(hmrCtx.server,
|
|
567
|
+
for (const relativeFileId of ctx.hmr.toComponentUpdateIds(updateId)) ctx.hmr.sendComponentUpdate(hmrCtx.server, relativeFileId);
|
|
566
568
|
});
|
|
567
569
|
return ownerModules.map((mod) => markModuleSelfAccepting(mod));
|
|
568
570
|
}
|
|
@@ -575,7 +577,7 @@ function ngtscCompilePlugin(ctxOrOptions) {
|
|
|
575
577
|
const mods = [];
|
|
576
578
|
const updates = [];
|
|
577
579
|
importers.forEach((imp) => {
|
|
578
|
-
if (ctx.shouldExternalizeStyles() && imp.id && ctx.hmr.classNames.get(imp.id)) updates.push(imp.id);
|
|
580
|
+
if (ctx.shouldExternalizeStyles() && imp.id && ctx.hmr.classNames.get(imp.id)?.size) updates.push(imp.id);
|
|
579
581
|
else mods.push(imp);
|
|
580
582
|
});
|
|
581
583
|
debugHmrV("resource importer analysis", {
|
|
@@ -591,7 +593,7 @@ function ngtscCompilePlugin(ctxOrOptions) {
|
|
|
591
593
|
updateCount: updates.length
|
|
592
594
|
});
|
|
593
595
|
updates.forEach((updateId) => {
|
|
594
|
-
ctx.hmr.sendComponentUpdate(hmrCtx.server,
|
|
596
|
+
for (const relativeFileId of ctx.hmr.toComponentUpdateIds(updateId)) ctx.hmr.sendComponentUpdate(hmrCtx.server, relativeFileId);
|
|
595
597
|
});
|
|
596
598
|
return fileModules.map((mod) => {
|
|
597
599
|
if (mod.id === hmrCtx.file) return markModuleSelfAccepting(mod);
|
|
@@ -736,14 +738,14 @@ function getFileMetadata(program, angularCompiler, hmrEnabled, disableTypeChecki
|
|
|
736
738
|
const diagnostics = getDiagnosticsForSourceFile(sourceFile, !!disableTypeChecking, program, angularCompiler);
|
|
737
739
|
const errors = diagnostics.filter((d) => d.category === ts.DiagnosticCategory?.Error).map((d) => typeof d.messageText === "object" ? d.messageText.messageText : d.messageText);
|
|
738
740
|
const warnings = diagnostics.filter((d) => d.category === ts.DiagnosticCategory?.Warning).map((d) => d.messageText);
|
|
739
|
-
|
|
741
|
+
const hmrUpdateCodes = /* @__PURE__ */ new Map();
|
|
740
742
|
let hmrEligible = false;
|
|
741
743
|
if (hmrEnabled) {
|
|
742
744
|
for (const node of sourceFile.statements) if (ts.isClassDeclaration(node) && node.name != null) {
|
|
743
|
-
|
|
744
|
-
if (
|
|
745
|
+
const updateCode = angularCompiler?.emitHmrUpdateModule(node);
|
|
746
|
+
if (updateCode) {
|
|
745
747
|
const className = node.name.getText();
|
|
746
|
-
|
|
748
|
+
hmrUpdateCodes.set(className, updateCode);
|
|
747
749
|
hmrEligible = true;
|
|
748
750
|
debugHmr("NgtscProgram emitHmrUpdateModule", {
|
|
749
751
|
file,
|
|
@@ -751,11 +753,13 @@ function getFileMetadata(program, angularCompiler, hmrEnabled, disableTypeChecki
|
|
|
751
753
|
});
|
|
752
754
|
}
|
|
753
755
|
}
|
|
756
|
+
if (hmrUpdateCodes.size > 0) classNamesMap.set(file, new Set(hmrUpdateCodes.keys()));
|
|
757
|
+
else classNamesMap.delete(file);
|
|
754
758
|
}
|
|
755
759
|
return {
|
|
756
760
|
errors,
|
|
757
761
|
warnings,
|
|
758
|
-
|
|
762
|
+
hmrUpdateCodes: hmrUpdateCodes.size > 0 ? hmrUpdateCodes : void 0,
|
|
759
763
|
hmrEligible
|
|
760
764
|
};
|
|
761
765
|
};
|