@analogjs/vite-plugin-angular 3.0.0-alpha.92 → 3.0.0-alpha.94
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/README.md +16 -1
- package/package.json +1 -1
- package/src/lib/angular-vite-plugin.d.ts +1 -1
- package/src/lib/angular-vite-plugin.js +35 -18
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.js +52 -34
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compiler/angular-version.d.ts +2 -0
- package/src/lib/compiler/angular-version.js +2 -1
- package/src/lib/compiler/angular-version.js.map +1 -1
- package/src/lib/compiler/defer.js +2 -0
- package/src/lib/compiler/defer.js.map +1 -1
- package/src/lib/compiler/js-emitter.js +15 -1
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/compiler-plugin.js +18 -12
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/fast-compile-plugin.js +0 -2
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.d.ts +1 -0
- package/src/lib/host.js +19 -1
- package/src/lib/host.js.map +1 -1
- package/src/lib/hot-update-batch.d.ts +5 -0
- package/src/lib/hot-update-batch.js +176 -0
- package/src/lib/hot-update-batch.js.map +1 -0
- package/src/lib/router-plugin.js +6 -3
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/utils/compilation-shared.d.ts +1 -0
- package/src/lib/utils/compilation-shared.js +15 -1
- package/src/lib/utils/compilation-shared.js.map +1 -1
- package/src/lib/utils/devkit.js +4 -1
- package/src/lib/utils/devkit.js.map +1 -1
- package/src/lib/utils/plugin-config.d.ts +1 -0
- package/src/lib/utils/plugin-config.js +2 -1
- package/src/lib/utils/plugin-config.js.map +1 -1
|
@@ -7,7 +7,8 @@ import { isRolldown } from "../utils/rolldown.js";
|
|
|
7
7
|
import { normalizeStylesheetDependencies } from "../style-preprocessor.js";
|
|
8
8
|
import { AnalogStylesheetRegistry, preprocessStylesheetResult, registerStylesheetContent, rewriteRelativeCssImports } from "../stylesheet-registry.js";
|
|
9
9
|
import { discoverAnalogIntegrations } from "../analog-plugin-interop.js";
|
|
10
|
-
import { DiagnosticModes, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, toAngularCompilationFileReplacements } from "../utils/compilation-shared.js";
|
|
10
|
+
import { DiagnosticModes, getBrowserModeCliOverride, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, toAngularCompilationFileReplacements } from "../utils/compilation-shared.js";
|
|
11
|
+
import { createHotUpdateBatcher } from "../hot-update-batch.js";
|
|
11
12
|
import { angularVitestPlugins } from "../angular-vitest-plugin.js";
|
|
12
13
|
import { buildOptimizerPlugin } from "../angular-build-optimizer-plugin.js";
|
|
13
14
|
import { jitPlugin } from "../angular-jit-plugin.js";
|
|
@@ -64,6 +65,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
64
65
|
let pendingCompilation = null;
|
|
65
66
|
let initialCompilation = false;
|
|
66
67
|
let viteServer;
|
|
68
|
+
const hotUpdates = createHotUpdateBatcher((ids) => performCompilation(resolvedConfig, ids));
|
|
67
69
|
const tsconfigResolver = new TsconfigResolver({
|
|
68
70
|
workspaceRoot: pluginOptions.workspaceRoot,
|
|
69
71
|
include: pluginOptions.include,
|
|
@@ -71,6 +73,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
71
73
|
isTest
|
|
72
74
|
});
|
|
73
75
|
const isVitestVscode = !!process.env["VITEST_VSCODE"];
|
|
76
|
+
let deferInitialCompilation = isVitestVscode;
|
|
74
77
|
let testWatchMode = isTestWatchMode();
|
|
75
78
|
function hasViteHmrTransport() {
|
|
76
79
|
return resolvedConfig ? resolvedConfig.server.hmr !== false : true;
|
|
@@ -136,6 +139,33 @@ function angularCompilationPlugin(options = {}) {
|
|
|
136
139
|
compilationApiTsConfigPath,
|
|
137
140
|
modifiedFileCount: modifiedFiles?.size ?? 0
|
|
138
141
|
});
|
|
142
|
+
const transformCompilerOptions = (tsCompilerOptions) => {
|
|
143
|
+
if (shouldExternalizeStyles()) tsCompilerOptions["externalRuntimeStyles"] = true;
|
|
144
|
+
if (shouldEnableLiveReload()) {
|
|
145
|
+
tsCompilerOptions["_enableHmr"] = true;
|
|
146
|
+
tsCompilerOptions["supportTestBed"] = true;
|
|
147
|
+
}
|
|
148
|
+
debugCompiler("tsCompilerOptions (compilation API)", {
|
|
149
|
+
liveReload: pluginOptions.liveReload,
|
|
150
|
+
viteHmr: hasViteHmrTransport(),
|
|
151
|
+
externalizeStylesRequested,
|
|
152
|
+
watchMode,
|
|
153
|
+
shouldExternalize: shouldExternalizeStyles(),
|
|
154
|
+
externalRuntimeStyles: !!tsCompilerOptions["externalRuntimeStyles"],
|
|
155
|
+
hmrEnabled: !!tsCompilerOptions["_enableHmr"]
|
|
156
|
+
});
|
|
157
|
+
if (tsCompilerOptions["compilationMode"] === "partial") {
|
|
158
|
+
tsCompilerOptions["supportTestBed"] = true;
|
|
159
|
+
tsCompilerOptions["supportJitMode"] = true;
|
|
160
|
+
}
|
|
161
|
+
if (!isTest && resolvedConfig.build?.lib) {
|
|
162
|
+
tsCompilerOptions["declaration"] = true;
|
|
163
|
+
tsCompilerOptions["declarationMap"] = watchMode;
|
|
164
|
+
tsCompilerOptions["inlineSources"] = true;
|
|
165
|
+
}
|
|
166
|
+
if (isTest) tsCompilerOptions["supportTestBed"] = true;
|
|
167
|
+
return tsCompilerOptions;
|
|
168
|
+
};
|
|
139
169
|
const compilationResult = await compilation.initialize(compilationApiTsConfigPath, {
|
|
140
170
|
fileReplacements: toAngularCompilationFileReplacements(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),
|
|
141
171
|
modifiedFiles,
|
|
@@ -188,33 +218,12 @@ function angularCompilationPlugin(options = {}) {
|
|
|
188
218
|
processWebWorker(workerFile) {
|
|
189
219
|
return workerFile;
|
|
190
220
|
}
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
debugCompiler("tsCompilerOptions (compilation API)", {
|
|
198
|
-
liveReload: pluginOptions.liveReload,
|
|
199
|
-
viteHmr: hasViteHmrTransport(),
|
|
200
|
-
externalizeStylesRequested,
|
|
201
|
-
watchMode,
|
|
202
|
-
shouldExternalize: shouldExternalizeStyles(),
|
|
203
|
-
externalRuntimeStyles: !!tsCompilerOptions["externalRuntimeStyles"],
|
|
204
|
-
hmrEnabled: !!tsCompilerOptions["_enableHmr"]
|
|
205
|
-
});
|
|
206
|
-
if (tsCompilerOptions["compilationMode"] === "partial") {
|
|
207
|
-
tsCompilerOptions["supportTestBed"] = true;
|
|
208
|
-
tsCompilerOptions["supportJitMode"] = true;
|
|
209
|
-
}
|
|
210
|
-
if (!isTest && resolvedConfig.build?.lib) {
|
|
211
|
-
tsCompilerOptions["declaration"] = true;
|
|
212
|
-
tsCompilerOptions["declarationMap"] = watchMode;
|
|
213
|
-
tsCompilerOptions["inlineSources"] = true;
|
|
214
|
-
}
|
|
215
|
-
if (isTest) tsCompilerOptions["supportTestBed"] = true;
|
|
216
|
-
return tsCompilerOptions;
|
|
217
|
-
});
|
|
221
|
+
}, angularFullVersion >= 220200 ? {
|
|
222
|
+
enableHmr: shouldEnableLiveReload(),
|
|
223
|
+
externalRuntimeStyles: shouldExternalizeStyles(),
|
|
224
|
+
includeTestMetadata: isTest || shouldEnableLiveReload(),
|
|
225
|
+
instrumentForCoverage: !isTest
|
|
226
|
+
} : transformCompilerOptions);
|
|
218
227
|
debugStyles("external stylesheets from compilation API", {
|
|
219
228
|
count: compilationResult.externalStylesheets?.size ?? 0,
|
|
220
229
|
hasPreprocessor: !!stylePreprocessor,
|
|
@@ -284,6 +293,10 @@ function angularCompilationPlugin(options = {}) {
|
|
|
284
293
|
hmrEligible: !!templateUpdate?.code
|
|
285
294
|
});
|
|
286
295
|
}
|
|
296
|
+
if (!watchMode && !isTest) {
|
|
297
|
+
await compilation.close?.();
|
|
298
|
+
angularCompilation = void 0;
|
|
299
|
+
}
|
|
287
300
|
}
|
|
288
301
|
async function performCompilation(config, ids) {
|
|
289
302
|
let resolve;
|
|
@@ -367,10 +380,15 @@ function angularCompilationPlugin(options = {}) {
|
|
|
367
380
|
stylesheetRegistry = new AnalogStylesheetRegistry();
|
|
368
381
|
(await discoverAnalogIntegrations(config)).configureStylesheetRegistry?.(stylesheetRegistry, { workspaceRoot: pluginOptions.workspaceRoot });
|
|
369
382
|
debugStyles("stylesheet registry initialized (Angular Compilation API)");
|
|
370
|
-
if (isTest)
|
|
383
|
+
if (isTest) {
|
|
384
|
+
const browser = config.test?.browser;
|
|
385
|
+
deferInitialCompilation = isVitestVscode || !!browser && (getBrowserModeCliOverride() ?? browser.enabled) === true;
|
|
386
|
+
testWatchMode = !(config.server.watch === null) || config.test?.watch === true || testWatchMode;
|
|
387
|
+
}
|
|
371
388
|
},
|
|
372
389
|
configureServer(server) {
|
|
373
390
|
viteServer = server;
|
|
391
|
+
hotUpdates.configureServer(server);
|
|
374
392
|
const invalidateCompilation = async () => {
|
|
375
393
|
tsconfigResolver.invalidateAll();
|
|
376
394
|
await performCompilation(resolvedConfig);
|
|
@@ -382,7 +400,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
382
400
|
});
|
|
383
401
|
},
|
|
384
402
|
async buildStart() {
|
|
385
|
-
if (!
|
|
403
|
+
if (!deferInitialCompilation) {
|
|
386
404
|
pendingCompilation = performCompilation(resolvedConfig);
|
|
387
405
|
await pendingCompilation;
|
|
388
406
|
pendingCompilation = null;
|
|
@@ -400,11 +418,9 @@ function angularCompilationPlugin(options = {}) {
|
|
|
400
418
|
file: ctx.file,
|
|
401
419
|
fileId
|
|
402
420
|
});
|
|
403
|
-
|
|
421
|
+
await hotUpdates.schedule(ctx.file, [fileId]);
|
|
404
422
|
let result;
|
|
405
423
|
if (shouldEnableLiveReload()) {
|
|
406
|
-
await pendingCompilation;
|
|
407
|
-
pendingCompilation = null;
|
|
408
424
|
result = fileEmitter(fileId);
|
|
409
425
|
debugHmr("TS file emitted", {
|
|
410
426
|
fileId,
|
|
@@ -477,7 +493,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
477
493
|
const isAngular = /(Component|Directive|Pipe|Injectable|NgModule)\(/.test(code);
|
|
478
494
|
if (id.includes(".ts?")) id = id.replace(/\?(.*)/, "");
|
|
479
495
|
if (isTest) {
|
|
480
|
-
if (
|
|
496
|
+
if (deferInitialCompilation && !initialCompilation) {
|
|
481
497
|
pendingCompilation = performCompilation(resolvedConfig);
|
|
482
498
|
initialCompilation = true;
|
|
483
499
|
}
|
|
@@ -491,6 +507,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
491
507
|
await pendingCompilation;
|
|
492
508
|
pendingCompilation = null;
|
|
493
509
|
}
|
|
510
|
+
await hotUpdates.wait();
|
|
494
511
|
const typescriptResult = fileEmitter(id);
|
|
495
512
|
if (!typescriptResult) {
|
|
496
513
|
debugCompilationApi("transform skip (file not emitted)", { id });
|
|
@@ -510,6 +527,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
510
527
|
}
|
|
511
528
|
},
|
|
512
529
|
async closeBundle() {
|
|
530
|
+
hotUpdates.close();
|
|
513
531
|
await compilationLock;
|
|
514
532
|
await angularCompilation?.close?.();
|
|
515
533
|
angularCompilation = void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n createTsConfigGetter,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n discoverAnalogIntegrations,\n type TransformFilter,\n} from '../analog-plugin-interop.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n} from '../utils/compilation-shared.js';\nimport { angularVitestPlugins } from '../angular-vitest-plugin.js';\nimport { buildOptimizerPlugin } from '../angular-build-optimizer-plugin.js';\nimport { jitPlugin } from '../angular-jit-plugin.js';\nimport { liveReloadPlugin } from '../live-reload-plugin.js';\nimport { virtualModulesPlugin } from '../virtual-modules-plugin.js';\nimport { encapsulationPlugin } from '../encapsulation-plugin.js';\nimport { nxFolderPlugin } from '../nx-folder-plugin.js';\nimport { routerPlugin } from '../router-plugin.js';\nimport { replaceFiles } from '../plugins/file-replacements.plugin.js';\nimport { cssExtensionStyleResolverPlugin } from '../utils/css-extension-resolver.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\n/**\n * @experimental The Angular Compilation API plugin may change in future releases.\n */\nexport interface AngularCompilationPluginOptions {\n tsconfig?: string | (() => string);\n workspaceRoot?: string;\n inlineStylesExtension?: string;\n jit?: boolean;\n liveReload?: boolean;\n disableTypeChecking?: boolean;\n supportedBrowsers?: string[];\n fileReplacements?: FileReplacement[];\n include?: string[];\n debug?: DebugOption;\n}\n\n/**\n * Compiles Angular applications using Angular's private Compilation API.\n *\n * @experimental This plugin may change in future releases.\n */\nexport function angularCompilationPlugin(\n options: AngularCompilationPluginOptions = {},\n): Plugin[] {\n if (\n angularFullVersion < 200100 ||\n typeof createAngularCompilation !== 'function'\n ) {\n throw new Error(\n '[@analogjs/vite-plugin-angular]: angularCompilationPlugin requires Angular v20.1 or later and a matching @angular/build package with the Compilation API.',\n );\n }\n\n applyDebugOption(options.debug, options.workspaceRoot);\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const pluginOptions = {\n tsconfigGetter: createTsConfigGetter(options.tsconfig),\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options.inlineStylesExtension ?? 'css',\n jit: options.jit ?? isTest,\n liveReload: options.liveReload ?? true,\n disableTypeChecking: options.disableTypeChecking ?? true,\n supportedBrowsers: options.supportedBrowsers ?? ['safari 15'],\n fileReplacements: options.fileReplacements ?? [],\n include: options.include ?? [],\n isAstroIntegration: process.env['ANALOG_ASTRO'] === 'true',\n };\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n let stylePreprocessor: StylePreprocessor | undefined;\n let transformFilter: TransformFilter | undefined;\n let externalizeStylesRequested = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || externalizeStylesRequested);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(workerFile: string) {\n return workerFile;\n },\n },\n (tsCompilerOptions: Record<string, unknown>) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n externalizeStylesRequested,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n },\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (stylesheetRegistry && stylePreprocessor && existsSync(key)) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n const integrations = await discoverAnalogIntegrations(config);\n stylePreprocessor = integrations.stylePreprocessor;\n transformFilter = integrations.transformFilter;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n externalizeStylesRequested = integrations.externalizeStyles;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n const compilerPlugin: Plugin = {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n api: { getTsConfigPath: resolveTsConfigPath },\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\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 // `angularCompilationPlugin()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n const integrations = await discoverAnalogIntegrations(config);\n integrations.configureStylesheetRegistry?.(stylesheetRegistry, {\n workspaceRoot: pluginOptions.workspaceRoot,\n });\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!isVitestVscode) {\n pendingCompilation = performCompilation(resolvedConfig);\n await pendingCompilation;\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n pendingCompilation = performCompilation(resolvedConfig, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n await pendingCompilation;\n pendingCompilation = null;\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath =\n stylesheetRegistry?.getServedSourcePath(filename);\n\n if (servedSourcePath) {\n debugStylesV('resolveId: mapped served stylesheet to source', {\n filename,\n resolvedPath: servedSourcePath,\n });\n return servedSourcePath + search;\n }\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n if (/[?&]raw\\b/.test(id)) return;\n if (transformFilter && !transformFilter(code, id)) {\n return;\n }\n\n // Angular emits every file in the program, not only files with\n // Angular decorators, and `@analogjs/platform` excludes `.ts` from\n // Vite's own transform. So serve Angular's output for any emitted\n // file; only the \"not emitted\" warning below is decorator-specific.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (isVitestVscode && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n async closeBundle() {\n await compilationLock;\n await angularCompilation?.close?.();\n angularCompilation = undefined;\n outputFiles.clear();\n classNames.clear();\n sourceFileCache.clear();\n tsconfigResolver.invalidateAll();\n stylesheetRegistry = undefined;\n pendingCompilation = null;\n initialCompilation = false;\n },\n };\n\n return [\n cssExtensionStyleResolverPlugin(),\n replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),\n virtualModulesPlugin({ jit: pluginOptions.jit }),\n compilerPlugin,\n pluginOptions.liveReload && liveReloadPlugin({ classNames, fileEmitter }),\n ...(isTest && !isStackBlitz\n ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map)\n : []),\n pluginOptions.jit &&\n jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),\n buildOptimizerPlugin({\n supportedBrowsers: pluginOptions.supportedBrowsers,\n jit: pluginOptions.jit,\n }),\n routerPlugin(),\n nxFolderPlugin(),\n encapsulationPlugin(),\n ].filter(Boolean) as Plugin[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;;;;;;AAuBhC,SAAgB,yBACd,UAA2C,EAAE,EACnC;AACV,KACE,qBAAqB,UACrB,OAAO,6BAA6B,WAEpC,OAAM,IAAI,MACR,4JACD;AAGH,kBAAiB,QAAQ,OAAO,QAAQ,cAAc;CACtD,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,eAAe,CAAC,CAAC,QAAQ,SAAS;CACxC,MAAM,gBAAgB;EACpB,gBAAgB,qBAAqB,QAAQ,SAAS;EACtD,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,KAAK;EACf,uBAAuB,QAAQ,yBAAyB;EACxD,KAAK,QAAQ,OAAO;EACpB,YAAY,QAAQ,cAAc;EAClC,qBAAqB,QAAQ,uBAAuB;EACpD,mBAAmB,QAAQ,qBAAqB,CAAC,YAAY;EAC7D,kBAAkB,QAAQ,oBAAoB,EAAE;EAChD,SAAS,QAAQ,WAAW,EAAE;EAC9B,oBAAoB,QAAQ,IAAI,oBAAoB;EACrD;CACD,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAChB,IAAI;CACJ,IAAI;CACJ,IAAI,6BAA6B;CAIjC,IAAI;CAGJ,MAAM,oBAAuC,IAAI,iBAAiB;CAClE,MAAM,8BAAc,IAAI,KAA6B;CACrD,MAAM,6BAAa,IAAI,KAAqB;CAC5C,IAAI;CACJ,IAAI,kBAAkB,QAAQ,SAAS;CACvC,IAAI,qBAA2C;CAC/C,IAAI,qBAAqB;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ACP,KAAK,SAAS,wBAAwB,CAEvD,QAAO,+BAA+B,KAAK;;AAI/C,WAAO;KACL,MAAM;KACN,KAAK;KACN;;GAEJ;EACD,MAAM,cAAc;AAClB,SAAM;AACN,SAAM,oBAAoB,SAAS;AACnC,wBAAqB,KAAA;AACrB,eAAY,OAAO;AACnB,cAAW,OAAO;AAClB,qBAAgB,OAAO;AACvB,oBAAiB,eAAe;AAChC,wBAAqB,KAAA;AACrB,wBAAqB;AACrB,wBAAqB;;EAExB;AAED,QAAO;EACL,iCAAiC;EACjC,aAAa,cAAc,kBAAkB,cAAc,cAAc;EACzE,qBAAqB,EAAE,KAAK,cAAc,KAAK,CAAC;EAChD;EACA,cAAc,cAAc,iBAAiB;GAAE;GAAY;GAAa,CAAC;EACzE,GAAI,UAAU,CAAC,eACX,sBAAsB,OAAO,YAAY,IAAI,cAAc,GAAG,CAAC,EAAE,IAAI,GACrE,EAAE;EACN,cAAc,OACZ,UAAU,EAAE,uBAAuB,cAAc,uBAAuB,CAAC;EAC3E,qBAAqB;GACnB,mBAAmB,cAAc;GACjC,KAAK,cAAc;GACpB,CAAC;EACF,cAAc;EACd,gBAAgB;EAChB,qBAAqB;EACtB,CAAC,OAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n createTsConfigGetter,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n discoverAnalogIntegrations,\n type TransformFilter,\n} from '../analog-plugin-interop.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n getBrowserModeCliOverride,\n} from '../utils/compilation-shared.js';\nimport { createHotUpdateBatcher } from '../hot-update-batch.js';\nimport { angularVitestPlugins } from '../angular-vitest-plugin.js';\nimport { buildOptimizerPlugin } from '../angular-build-optimizer-plugin.js';\nimport { jitPlugin } from '../angular-jit-plugin.js';\nimport { liveReloadPlugin } from '../live-reload-plugin.js';\nimport { virtualModulesPlugin } from '../virtual-modules-plugin.js';\nimport { encapsulationPlugin } from '../encapsulation-plugin.js';\nimport { nxFolderPlugin } from '../nx-folder-plugin.js';\nimport { routerPlugin } from '../router-plugin.js';\nimport { replaceFiles } from '../plugins/file-replacements.plugin.js';\nimport { cssExtensionStyleResolverPlugin } from '../utils/css-extension-resolver.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\n/**\n * @experimental The Angular Compilation API plugin may change in future releases.\n */\nexport interface AngularCompilationPluginOptions {\n tsconfig?: string | (() => string);\n workspaceRoot?: string;\n inlineStylesExtension?: string;\n jit?: boolean;\n liveReload?: boolean;\n disableTypeChecking?: boolean;\n supportedBrowsers?: string[];\n fileReplacements?: FileReplacement[];\n include?: string[];\n debug?: DebugOption;\n}\n\n/**\n * Compiles Angular applications using Angular's private Compilation API.\n *\n * @experimental This plugin may change in future releases.\n */\nexport function angularCompilationPlugin(\n options: AngularCompilationPluginOptions = {},\n): Plugin[] {\n if (\n angularFullVersion < 200100 ||\n typeof createAngularCompilation !== 'function'\n ) {\n throw new Error(\n '[@analogjs/vite-plugin-angular]: angularCompilationPlugin requires Angular v20.1 or later and a matching @angular/build package with the Compilation API.',\n );\n }\n\n applyDebugOption(options.debug, options.workspaceRoot);\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const pluginOptions = {\n tsconfigGetter: createTsConfigGetter(options.tsconfig),\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options.inlineStylesExtension ?? 'css',\n jit: options.jit ?? isTest,\n liveReload: options.liveReload ?? true,\n disableTypeChecking: options.disableTypeChecking ?? true,\n supportedBrowsers: options.supportedBrowsers ?? ['safari 15'],\n fileReplacements: options.fileReplacements ?? [],\n include: options.include ?? [],\n isAstroIntegration: process.env['ANALOG_ASTRO'] === 'true',\n };\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n let stylePreprocessor: StylePreprocessor | undefined;\n let transformFilter: TransformFilter | undefined;\n let externalizeStylesRequested = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n const hotUpdates = createHotUpdateBatcher((ids) =>\n performCompilation(resolvedConfig, ids),\n );\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let deferInitialCompilation = isVitestVscode;\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || externalizeStylesRequested);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const transformCompilerOptions = (\n tsCompilerOptions: Record<string, unknown>,\n ) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n externalizeStylesRequested,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n };\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(workerFile: string) {\n return workerFile;\n },\n },\n angularFullVersion >= 220200\n ? {\n enableHmr: shouldEnableLiveReload(),\n externalRuntimeStyles: shouldExternalizeStyles(),\n includeTestMetadata: isTest || shouldEnableLiveReload(),\n instrumentForCoverage: !isTest,\n }\n : (transformCompilerOptions as unknown as Parameters<\n typeof compilation.initialize\n >[2]),\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (stylesheetRegistry && stylePreprocessor && existsSync(key)) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n\n // Free the compilation before chunks render; `transform` still reads `outputFiles`.\n if (!watchMode && !isTest) {\n await compilation.close?.();\n angularCompilation = undefined;\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n const integrations = await discoverAnalogIntegrations(config);\n stylePreprocessor = integrations.stylePreprocessor;\n transformFilter = integrations.transformFilter;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n externalizeStylesRequested = integrations.externalizeStyles;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n const compilerPlugin: Plugin = {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n api: { getTsConfigPath: resolveTsConfigPath },\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\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 // `angularCompilationPlugin()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n const integrations = await discoverAnalogIntegrations(config);\n integrations.configureStylesheetRegistry?.(stylesheetRegistry, {\n workspaceRoot: pluginOptions.workspaceRoot,\n });\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n const browser = (config as any).test?.browser;\n deferInitialCompilation =\n isVitestVscode ||\n (!!browser &&\n (getBrowserModeCliOverride() ?? browser.enabled) === true);\n\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n hotUpdates.configureServer(server);\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!deferInitialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n await pendingCompilation;\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n await hotUpdates.schedule(ctx.file, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath =\n stylesheetRegistry?.getServedSourcePath(filename);\n\n if (servedSourcePath) {\n debugStylesV('resolveId: mapped served stylesheet to source', {\n filename,\n resolvedPath: servedSourcePath,\n });\n return servedSourcePath + search;\n }\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n if (/[?&]raw\\b/.test(id)) return;\n if (transformFilter && !transformFilter(code, id)) {\n return;\n }\n\n // Angular emits every file in the program, not only files with\n // Angular decorators, and `@analogjs/platform` excludes `.ts` from\n // Vite's own transform. So serve Angular's output for any emitted\n // file; only the \"not emitted\" warning below is decorator-specific.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (deferInitialCompilation && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n await hotUpdates.wait();\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n async closeBundle() {\n hotUpdates.close();\n await compilationLock;\n await angularCompilation?.close?.();\n angularCompilation = undefined;\n outputFiles.clear();\n classNames.clear();\n sourceFileCache.clear();\n tsconfigResolver.invalidateAll();\n stylesheetRegistry = undefined;\n pendingCompilation = null;\n initialCompilation = false;\n },\n };\n\n return [\n cssExtensionStyleResolverPlugin(),\n replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),\n virtualModulesPlugin({ jit: pluginOptions.jit }),\n compilerPlugin,\n pluginOptions.liveReload && liveReloadPlugin({ classNames, fileEmitter }),\n ...(isTest && !isStackBlitz\n ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map)\n : []),\n pluginOptions.jit &&\n jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),\n buildOptimizerPlugin({\n supportedBrowsers: pluginOptions.supportedBrowsers,\n jit: pluginOptions.jit,\n }),\n routerPlugin(),\n nxFolderPlugin(),\n encapsulationPlugin(),\n ].filter(Boolean) as Plugin[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;;;;;;AAuBhC,SAAgB,yBACd,UAA2C,EAAE,EACnC;AACV,KACE,qBAAqB,UACrB,OAAO,6BAA6B,WAEpC,OAAM,IAAI,MACR,4JACD;AAGH,kBAAiB,QAAQ,OAAO,QAAQ,cAAc;CACtD,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,eAAe,CAAC,CAAC,QAAQ,SAAS;CACxC,MAAM,gBAAgB;EACpB,gBAAgB,qBAAqB,QAAQ,SAAS;EACtD,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,KAAK;EACf,uBAAuB,QAAQ,yBAAyB;EACxD,KAAK,QAAQ,OAAO;EACpB,YAAY,QAAQ,cAAc;EAClC,qBAAqB,QAAQ,uBAAuB;EACpD,mBAAmB,QAAQ,qBAAqB,CAAC,YAAY;EAC7D,kBAAkB,QAAQ,oBAAoB,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,KAAK,CAAC;EAChD;EACA,cAAc,cAAc,iBAAiB;GAAE;GAAY;GAAa,CAAC;EACzE,GAAI,UAAU,CAAC,eACX,sBAAsB,OAAO,YAAY,IAAI,cAAc,GAAG,CAAC,EAAE,IAAI,GACrE,EAAE;EACN,cAAc,OACZ,UAAU,EAAE,uBAAuB,cAAc,uBAAuB,CAAC;EAC3E,qBAAqB;GACnB,mBAAmB,cAAc;GACjC,KAAK,cAAc;GACpB,CAAC;EACF,cAAc;EACd,gBAAgB;EAChB,qBAAqB;EACtB,CAAC,OAAO,QAAQ"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const SUPPORTS_BOUNDARY_BLOCKS: unknown;
|
|
2
|
+
export declare const SUPPORTS_INCREMENT_DECREMENT: unknown;
|
|
1
3
|
/**
|
|
2
4
|
* The major version of the installed `@angular/compiler` package, parsed
|
|
3
5
|
* from `o.VERSION.major`. Falls back to `DEFAULT_ASSUMED_MAJOR` when the
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as o from "@angular/compiler";
|
|
2
|
-
|
|
2
|
+
"TmplAstBoundaryBlock" in o;
|
|
3
|
+
o.UnaryOperator["Increment"];
|
|
3
4
|
var DEFAULT_ASSUMED_MAJOR = 22;
|
|
4
5
|
/**
|
|
5
6
|
* The major version of the installed `@angular/compiler` package, parsed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-version.js","names":[],"sources":["../../../../src/lib/compiler/angular-version.ts"],"sourcesContent":["import * as o from '@angular/compiler';\n\n// Detect the installed @angular/compiler major version once at module load\n// time and expose helpers for version-aware code paths.\n//\n// Why this matters: Angular's compiler API surface (enum members,\n// metadata shapes, output formats) shifts between major versions in ways\n// that can't always be papered over with duck typing. The compatibility\n// matrix in .github/workflows/compiler-compat.yml runs the test\n// suite against multiple installed versions to catch this drift, and the\n// version-aware code paths in compile.ts / js-emitter.ts / metadata.ts\n// gate behavior on `ANGULAR_MAJOR` to keep the compiler working across\n// the supported `peerDependencies` range (currently >=19.0.0).\n//\n// Default fallback: when the version string is missing or unparseable\n// (vendored builds, monkey-patched test environments), assume the latest\n// known major. This biases toward the most-tested code path.\nconst DEFAULT_ASSUMED_MAJOR = 22;\n\n/**\n * The major version of the installed `@angular/compiler` package, parsed\n * from `o.VERSION.major`. Falls back to `DEFAULT_ASSUMED_MAJOR` when the\n * version is unavailable.\n */\nexport const ANGULAR_MAJOR: number = (() => {\n const major = Number.parseInt(o.VERSION?.major ?? '', 10);\n return Number.isFinite(major) && major > 0 ? major : DEFAULT_ASSUMED_MAJOR;\n})();\n\n/**\n * Returns `true` when the installed Angular major is at least `major`.\n * Use this to gate code paths that depend on APIs introduced in a\n * specific Angular release.\n *\n * @example\n * if (angularVersionAtLeast(21)) {\n * // Use Angular 21+ API\n * } else {\n * // Fall back to v19/v20 behavior\n * }\n */\nexport function angularVersionAtLeast(major: number): boolean {\n return ANGULAR_MAJOR >= major;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"angular-version.js","names":[],"sources":["../../../../src/lib/compiler/angular-version.ts"],"sourcesContent":["import * as o from '@angular/compiler';\n\n// Boundary blocks were introduced during the Angular 22.2 prereleases.\nexport const SUPPORTS_BOUNDARY_BLOCKS = 'TmplAstBoundaryBlock' in o;\n\nexport const SUPPORTS_INCREMENT_DECREMENT =\n typeof (o.UnaryOperator as Record<string, unknown>)['Increment'] === 'number';\n\n// Detect the installed @angular/compiler major version once at module load\n// time and expose helpers for version-aware code paths.\n//\n// Why this matters: Angular's compiler API surface (enum members,\n// metadata shapes, output formats) shifts between major versions in ways\n// that can't always be papered over with duck typing. The compatibility\n// matrix in .github/workflows/compiler-compat.yml runs the test\n// suite against multiple installed versions to catch this drift, and the\n// version-aware code paths in compile.ts / js-emitter.ts / metadata.ts\n// gate behavior on `ANGULAR_MAJOR` to keep the compiler working across\n// the supported `peerDependencies` range (currently >=19.0.0).\n//\n// Default fallback: when the version string is missing or unparseable\n// (vendored builds, monkey-patched test environments), assume the latest\n// known major. This biases toward the most-tested code path.\nconst DEFAULT_ASSUMED_MAJOR = 22;\n\n/**\n * The major version of the installed `@angular/compiler` package, parsed\n * from `o.VERSION.major`. Falls back to `DEFAULT_ASSUMED_MAJOR` when the\n * version is unavailable.\n */\nexport const ANGULAR_MAJOR: number = (() => {\n const major = Number.parseInt(o.VERSION?.major ?? '', 10);\n return Number.isFinite(major) && major > 0 ? major : DEFAULT_ASSUMED_MAJOR;\n})();\n\n/**\n * Returns `true` when the installed Angular major is at least `major`.\n * Use this to gate code paths that depend on APIs introduced in a\n * specific Angular release.\n *\n * @example\n * if (angularVersionAtLeast(21)) {\n * // Use Angular 21+ API\n * } else {\n * // Fall back to v19/v20 behavior\n * }\n */\nexport function angularVersionAtLeast(major: number): boolean {\n return ANGULAR_MAJOR >= major;\n}\n"],"mappings":";AAGwC,0BAA0B;AAGxD,EAAE,cAA0C;AAiBtD,IAAM,wBAAwB;;;;;;AAO9B,IAAa,uBAA+B;CAC1C,MAAM,QAAQ,OAAO,SAAS,EAAE,SAAS,SAAS,IAAI,GAAG;AACzD,QAAO,OAAO,SAAS,MAAM,IAAI,QAAQ,IAAI,QAAQ;IACnD;;;;;;;;;;;;;AAcJ,SAAgB,sBAAsB,OAAwB;AAC5D,QAAO,iBAAiB"}
|
|
@@ -9,6 +9,7 @@ function collectDeferBlocks(nodes) {
|
|
|
9
9
|
if (node.constructor?.name === "DeferredBlock") result.push(node);
|
|
10
10
|
if (Array.isArray(node.children)) node.children.forEach(walk);
|
|
11
11
|
if (Array.isArray(node.branches)) node.branches.forEach(walk);
|
|
12
|
+
if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);
|
|
12
13
|
if (Array.isArray(node.groups)) node.groups.forEach(walk);
|
|
13
14
|
if (Array.isArray(node.cases)) node.cases.forEach(walk);
|
|
14
15
|
if (node.empty?.children) node.empty.children.forEach(walk);
|
|
@@ -43,6 +44,7 @@ function collectElementNames(nodes, excludeDeferBlocks = false) {
|
|
|
43
44
|
if (node.constructor?.name === "Element") result.add(node.name);
|
|
44
45
|
if (Array.isArray(node.children)) node.children.forEach(walk);
|
|
45
46
|
if (Array.isArray(node.branches)) node.branches.forEach(walk);
|
|
47
|
+
if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);
|
|
46
48
|
if (Array.isArray(node.groups)) node.groups.forEach(walk);
|
|
47
49
|
if (Array.isArray(node.cases)) node.cases.forEach(walk);
|
|
48
50
|
if (node.empty?.children) node.empty.children.forEach(walk);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defer.js","names":[],"sources":["../../../../src/lib/compiler/defer.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport * as o from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\n\n/** Recursively collect all DeferredBlock nodes from a template AST. */\nexport function collectDeferBlocks(nodes: any[]): any[] {\n const result: any[] = [];\n function walk(node: any) {\n if (!node) return;\n if (node.constructor?.name === 'DeferredBlock') {\n result.push(node);\n }\n // Walk all possible child structures across block types:\n // Element/Template: children\n // IfBlock: branches (each has children)\n // ForLoopBlock: children, empty (has children)\n // SwitchBlock: groups (Angular v21+, each is a SwitchBlockCaseGroup with\n // children) or cases (Angular v18-v20, each has children)\n // DeferredBlock: children, placeholder/loading/error (each has children)\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/**\n * Collect element tag names from template AST nodes recursively.\n *\n * When `excludeDeferBlocks` is true, the deferred body of any DeferredBlock is\n * skipped — its children are treated as deferred, not eager. The fallback\n * subtrees (`@placeholder`, `@loading`, `@error`) are still walked: Angular\n * treats them as *eager* dependencies because the placeholder must render in\n * the main bundle before the defer trigger fires. A component shared between\n * the defer body and a fallback block must stay in static imports, otherwise\n * the fallback render breaks.\n */\nexport function collectElementNames(\n nodes: any[],\n excludeDeferBlocks = false,\n): Set<string> {\n const result = new Set<string>();\n function walk(node: any) {\n if (!node) return;\n if (excludeDeferBlocks && node.constructor?.name === 'DeferredBlock') {\n // Skip the deferred body but keep walking the fallback subtrees so\n // components referenced in `@placeholder` / `@loading` / `@error`\n // stay in the eager set.\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n return;\n }\n if (node.constructor?.name === 'Element') result.add(node.name);\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/** Information about how a class is imported. */\nexport interface ImportInfo {\n /** Module path from the import statement. */\n path: string;\n /** Whether the class was imported as a default import (`import X from`). */\n isDefault: boolean;\n /**\n * Original exported name on the source module's namespace. For\n * `import { HeavyWidget as Widget } from './heavy'`, the local\n * binding is `Widget` but the namespace exposes `HeavyWidget` —\n * `await import('./heavy')` returns `{ HeavyWidget }`, not\n * `{ Widget }`. Defer dependency emit must use the exported name,\n * not the local alias, or the lookup resolves to `undefined` at\n * runtime.\n */\n exportName: string;\n}\n\n/**\n * Build import info map: localName → { path, isDefault, exportName }\n * from source file imports. Tracks default vs named imports plus the\n * original exported name so the defer dependency generator can emit\n * `import('./p').then(m => m.default)` for default imports and\n * `import('./p').then(m => m.OriginalExportName)` for aliased named\n * imports.\n */\nexport function buildImportMap(sf: ts.SourceFile): Map<string, ImportInfo> {\n const result = new Map<string, ImportInfo>();\n for (const stmt of sf.statements) {\n if (!ts.isImportDeclaration(stmt) || !stmt.importClause) continue;\n const path = (stmt.moduleSpecifier as ts.StringLiteral).text;\n const clause = stmt.importClause;\n if (clause.name) {\n result.set(clause.name.text, {\n path,\n isDefault: true,\n exportName: 'default',\n });\n }\n if (clause.namedBindings && ts.isNamedImports(clause.namedBindings)) {\n for (const el of clause.namedBindings.elements) {\n // `import { Foo as Bar }` → propertyName is `Foo`, name is `Bar`.\n // `import { Foo }` → propertyName is undefined.\n const exportName = el.propertyName?.text ?? el.name.text;\n const info: ImportInfo = { path, isDefault: false, exportName };\n // Key the map by BOTH the local binding and the original export\n // name. The defer-dep lookup uses the className from the\n // registry — which is always the original class name from the\n // source file (`HeavyWidget`), not the consumer's local alias\n // (`Widget`). Without the export-name key, aliased imports\n // would silently produce no defer dependency at all.\n result.set(el.name.text, info);\n if (exportName !== el.name.text) {\n result.set(exportName, info);\n }\n }\n }\n }\n return result;\n}\n\n/**\n * Build defer block dependency map with dynamic import() expressions.\n *\n * For each defer block, identifies which imported components are only used\n * inside defer blocks (not in the eager template), and generates dynamic\n * import expressions for lazy loading.\n *\n * Returns:\n * - blocks: Map<DeferredBlock, Expression | null> for compileComponentFromMetadata\n * - deferredImports: Set<string> of class names that should be removed from static imports\n */\nexport function buildDeferDependencyMap(\n parsedTemplate: any,\n sourceFile: ts.SourceFile,\n registry: ComponentRegistry | undefined,\n localSelectors: Map<string, string>,\n): { blocks: Map<any, any>; deferredImports: Set<string> } {\n const deferBlocks = collectDeferBlocks(parsedTemplate.nodes);\n if (deferBlocks.length === 0) {\n return { blocks: new Map(), deferredImports: new Set() };\n }\n\n const deferElements = new Set<string>();\n for (const block of deferBlocks) {\n const elements = collectElementNames(block.children || []);\n for (const el of elements) deferElements.add(el);\n }\n // Eager elements = elements reachable without crossing into a DeferredBlock.\n // Pass `excludeDeferBlocks` so a defer block nested inside @switch / @if /\n // @for is not unfolded into the eager set. Without this, a component used\n // only inside such a nested defer would be misclassified as eager and lose\n // its lazy-load dependency function.\n const eagerElements = collectElementNames(parsedTemplate.nodes, true);\n\n // Build selector → className map from registry + local selectors\n const selectorToClass = new Map<string, string>();\n if (registry) {\n for (const [className, entry] of registry) {\n if (entry.selector) selectorToClass.set(entry.selector, className);\n }\n }\n for (const [className, selector] of localSelectors) {\n selectorToClass.set(selector, className);\n }\n\n // Build className → importPath map\n const importMap = buildImportMap(sourceFile);\n\n // Find defer-only component class names\n const deferredImports = new Set<string>();\n const deferOnlyElements = new Set<string>();\n for (const el of deferElements) {\n if (!eagerElements.has(el)) deferOnlyElements.add(el);\n }\n\n for (const el of deferOnlyElements) {\n const className = selectorToClass.get(el);\n if (className && importMap.has(className)) {\n deferredImports.add(className);\n }\n }\n\n // Build the blocks map with dependency functions\n const blocks = new Map<any, any>();\n for (const block of deferBlocks) {\n const blockElements = collectElementNames(block.children || []);\n const blockDeps: any[] = [];\n // Within a single block, dedupe by `${path}#${symbolName}` so two\n // refs to the same component don't generate two import expressions.\n const seenInBlock = new Set<string>();\n\n for (const el of blockElements) {\n const className = selectorToClass.get(el);\n if (!className || !deferredImports.has(className)) continue;\n const info = importMap.get(className)!;\n // Use the original exported name (tracked by buildImportMap) so\n // aliased imports like `import { HeavyWidget as Widget }` resolve\n // to `m.HeavyWidget` instead of `m.Widget` (which would be\n // `undefined` on the module namespace).\n const symbolName = info.exportName;\n const key = `${info.path}#${symbolName}`;\n if (seenInBlock.has(key)) continue;\n seenInBlock.add(key);\n // import('./path').then(m => m.ClassName) — or `m.default` for\n // default imports. Without the `.then(...)` resolver Angular's\n // runtime gets a module namespace and can't find the class.\n // `FnParam` and the `variable()` helper aren't on the top-level\n // namespace; they live in the `outputAst` sub-namespace.\n const ast: any = (o as any).outputAst;\n const mVar = ast.variable('m');\n const innerFn = ast.arrowFn(\n [new ast.FnParam('m', ast.DYNAMIC_TYPE)],\n new o.ReadPropExpr(mVar, symbolName),\n );\n const importExpr = new o.InvokeFunctionExpr(\n new o.ReadPropExpr(\n new o.DynamicImportExpr(new o.LiteralExpr(info.path)),\n 'then',\n ),\n [innerFn],\n );\n blockDeps.push(new o.ArrowFunctionExpr([], importExpr));\n }\n\n if (blockDeps.length > 0) {\n // () => [import('./a').then(m => m.A), import('./b').then(m => m.default)]\n blocks.set(\n block,\n new o.ArrowFunctionExpr([], new o.LiteralArrayExpr(blockDeps)),\n );\n } else {\n blocks.set(block, null);\n }\n }\n\n return { blocks, deferredImports };\n}\n"],"mappings":";;;;AAKA,SAAgB,mBAAmB,OAAqB;CACtD,MAAM,SAAgB,EAAE;CACxB,SAAS,KAAK,MAAW;AACvB,MAAI,CAAC,KAAM;AACX,MAAI,KAAK,aAAa,SAAS,gBAC7B,QAAO,KAAK,KAAK;AASnB,MAAI,MAAM,QAAQ,KAAK,SAAS,CAAE,MAAK,SAAS,QAAQ,KAAK;AAC7D,MAAI,MAAM,QAAQ,KAAK,SAAS,CAAE,MAAK,SAAS,QAAQ,KAAK;AAC7D,MAAI,MAAM,QAAQ,KAAK,OAAO,CAAE,MAAK,OAAO,QAAQ,KAAK;AACzD,MAAI,MAAM,QAAQ,KAAK,MAAM,CAAE,MAAK,MAAM,QAAQ,KAAK;AACvD,MAAI,KAAK,OAAO,SAAU,MAAK,MAAM,SAAS,QAAQ,KAAK;AAC3D,MAAI,KAAK,aAAa,SAAU,MAAK,YAAY,SAAS,QAAQ,KAAK;AACvE,MAAI,KAAK,SAAS,SAAU,MAAK,QAAQ,SAAS,QAAQ,KAAK;AAC/D,MAAI,KAAK,OAAO,SAAU,MAAK,MAAM,SAAS,QAAQ,KAAK;;AAE7D,OAAM,QAAQ,KAAK;AACnB,QAAO;;;;;;;;;;;;;AAcT,SAAgB,oBACd,OACA,qBAAqB,OACR;CACb,MAAM,yBAAS,IAAI,KAAa;CAChC,SAAS,KAAK,MAAW;AACvB,MAAI,CAAC,KAAM;AACX,MAAI,sBAAsB,KAAK,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S,aAAa;EAC/B,MAAM,gBAAgB,oBAAoB,MAAM,YAAY,EAAE,CAAC;EAC/D,MAAM,YAAmB,EAAE;EAG3B,MAAM,8BAAc,IAAI,KAAa;AAErC,OAAK,MAAM,MAAM,eAAe;GAC9B,MAAM,YAAY,gBAAgB,IAAI,GAAG;AACzC,OAAI,CAAC,aAAa,CAAC,gBAAgB,IAAI,UAAU,CAAE;GACnD,MAAM,OAAO,UAAU,IAAI,UAAU;GAKrC,MAAM,aAAa,KAAK;GACxB,MAAM,MAAM,GAAG,KAAK,KAAK,GAAG;AAC5B,OAAI,YAAY,IAAI,IAAI,CAAE;AAC1B,eAAY,IAAI,IAAI;GAMpB,MAAM,MAAY,EAAU;GAC5B,MAAM,OAAO,IAAI,SAAS,IAAI;GAC9B,MAAM,UAAU,IAAI,QAClB,CAAC,IAAI,IAAI,QAAQ,KAAK,IAAI,aAAa,CAAC,EACxC,IAAI,EAAE,aAAa,MAAM,WAAW,CACrC;GACD,MAAM,aAAa,IAAI,EAAE,mBACvB,IAAI,EAAE,aACJ,IAAI,EAAE,kBAAkB,IAAI,EAAE,YAAY,KAAK,KAAK,CAAC,EACrD,OACD,EACD,CAAC,QAAQ,CACV;AACD,aAAU,KAAK,IAAI,EAAE,kBAAkB,EAAE,EAAE,WAAW,CAAC;;AAGzD,MAAI,UAAU,SAAS,EAErB,QAAO,IACL,OACA,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,iBAAiB,UAAU,CAAC,CAC/D;MAED,QAAO,IAAI,OAAO,KAAK;;AAI3B,QAAO;EAAE;EAAQ;EAAiB"}
|
|
1
|
+
{"version":3,"file":"defer.js","names":[],"sources":["../../../../src/lib/compiler/defer.ts"],"sourcesContent":["import * as ts from 'typescript';\nimport * as o from '@angular/compiler';\nimport { ComponentRegistry } from './registry.js';\n\n/** Recursively collect all DeferredBlock nodes from a template AST. */\nexport function collectDeferBlocks(nodes: any[]): any[] {\n const result: any[] = [];\n function walk(node: any) {\n if (!node) return;\n if (node.constructor?.name === 'DeferredBlock') {\n result.push(node);\n }\n // Walk all possible child structures across block types:\n // Element/Template: children\n // IfBlock: branches (each has children)\n // ForLoopBlock: children, empty (has children)\n // SwitchBlock: groups (Angular v21+, each is a SwitchBlockCaseGroup with\n // children) or cases (Angular v18-v20, each has children)\n // DeferredBlock: children, placeholder/loading/error (each has children)\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/**\n * Collect element tag names from template AST nodes recursively.\n *\n * When `excludeDeferBlocks` is true, the deferred body of any DeferredBlock is\n * skipped — its children are treated as deferred, not eager. The fallback\n * subtrees (`@placeholder`, `@loading`, `@error`) are still walked: Angular\n * treats them as *eager* dependencies because the placeholder must render in\n * the main bundle before the defer trigger fires. A component shared between\n * the defer body and a fallback block must stay in static imports, otherwise\n * the fallback render breaks.\n */\nexport function collectElementNames(\n nodes: any[],\n excludeDeferBlocks = false,\n): Set<string> {\n const result = new Set<string>();\n function walk(node: any) {\n if (!node) return;\n if (excludeDeferBlocks && node.constructor?.name === 'DeferredBlock') {\n // Skip the deferred body but keep walking the fallback subtrees so\n // components referenced in `@placeholder` / `@loading` / `@error`\n // stay in the eager set.\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n return;\n }\n if (node.constructor?.name === 'Element') result.add(node.name);\n if (Array.isArray(node.children)) node.children.forEach(walk);\n if (Array.isArray(node.branches)) node.branches.forEach(walk);\n if (Array.isArray(node.errorBlocks)) node.errorBlocks.forEach(walk);\n if (Array.isArray(node.groups)) node.groups.forEach(walk);\n if (Array.isArray(node.cases)) node.cases.forEach(walk);\n if (node.empty?.children) node.empty.children.forEach(walk);\n if (node.placeholder?.children) node.placeholder.children.forEach(walk);\n if (node.loading?.children) node.loading.children.forEach(walk);\n if (node.error?.children) node.error.children.forEach(walk);\n }\n nodes.forEach(walk);\n return result;\n}\n\n/** Information about how a class is imported. */\nexport interface ImportInfo {\n /** Module path from the import statement. */\n path: string;\n /** Whether the class was imported as a default import (`import X from`). */\n isDefault: boolean;\n /**\n * Original exported name on the source module's namespace. For\n * `import { HeavyWidget as Widget } from './heavy'`, the local\n * binding is `Widget` but the namespace exposes `HeavyWidget` —\n * `await import('./heavy')` returns `{ HeavyWidget }`, not\n * `{ Widget }`. Defer dependency emit must use the exported name,\n * not the local alias, or the lookup resolves to `undefined` at\n * runtime.\n */\n exportName: string;\n}\n\n/**\n * Build import info map: localName → { path, isDefault, exportName }\n * from source file imports. Tracks default vs named imports plus the\n * original exported name so the defer dependency generator can emit\n * `import('./p').then(m => m.default)` for default imports and\n * `import('./p').then(m => m.OriginalExportName)` for aliased named\n * imports.\n */\nexport function buildImportMap(sf: ts.SourceFile): Map<string, ImportInfo> {\n const result = new Map<string, ImportInfo>();\n for (const stmt of sf.statements) {\n if (!ts.isImportDeclaration(stmt) || !stmt.importClause) continue;\n const path = (stmt.moduleSpecifier as ts.StringLiteral).text;\n const clause = stmt.importClause;\n if (clause.name) {\n result.set(clause.name.text, {\n path,\n isDefault: true,\n exportName: 'default',\n });\n }\n if (clause.namedBindings && ts.isNamedImports(clause.namedBindings)) {\n for (const el of clause.namedBindings.elements) {\n // `import { Foo as Bar }` → propertyName is `Foo`, name is `Bar`.\n // `import { Foo }` → propertyName is undefined.\n const exportName = el.propertyName?.text ?? el.name.text;\n const info: ImportInfo = { path, isDefault: false, exportName };\n // Key the map by BOTH the local binding and the original export\n // name. The defer-dep lookup uses the className from the\n // registry — which is always the original class name from the\n // source file (`HeavyWidget`), not the consumer's local alias\n // (`Widget`). Without the export-name key, aliased imports\n // would silently produce no defer dependency at all.\n result.set(el.name.text, info);\n if (exportName !== el.name.text) {\n result.set(exportName, info);\n }\n }\n }\n }\n return result;\n}\n\n/**\n * Build defer block dependency map with dynamic import() expressions.\n *\n * For each defer block, identifies which imported components are only used\n * inside defer blocks (not in the eager template), and generates dynamic\n * import expressions for lazy loading.\n *\n * Returns:\n * - blocks: Map<DeferredBlock, Expression | null> for compileComponentFromMetadata\n * - deferredImports: Set<string> of class names that should be removed from static imports\n */\nexport function buildDeferDependencyMap(\n parsedTemplate: any,\n sourceFile: ts.SourceFile,\n registry: ComponentRegistry | undefined,\n localSelectors: Map<string, string>,\n): { blocks: Map<any, any>; deferredImports: Set<string> } {\n const deferBlocks = collectDeferBlocks(parsedTemplate.nodes);\n if (deferBlocks.length === 0) {\n return { blocks: new Map(), deferredImports: new Set() };\n }\n\n const deferElements = new Set<string>();\n for (const block of deferBlocks) {\n const elements = collectElementNames(block.children || []);\n for (const el of elements) deferElements.add(el);\n }\n // Eager elements = elements reachable without crossing into a DeferredBlock.\n // Pass `excludeDeferBlocks` so a defer block nested inside @switch / @if /\n // @for is not unfolded into the eager set. Without this, a component used\n // only inside such a nested defer would be misclassified as eager and lose\n // its lazy-load dependency function.\n const eagerElements = collectElementNames(parsedTemplate.nodes, true);\n\n // Build selector → className map from registry + local selectors\n const selectorToClass = new Map<string, string>();\n if (registry) {\n for (const [className, entry] of registry) {\n if (entry.selector) selectorToClass.set(entry.selector, className);\n }\n }\n for (const [className, selector] of localSelectors) {\n selectorToClass.set(selector, className);\n }\n\n // Build className → importPath map\n const importMap = buildImportMap(sourceFile);\n\n // Find defer-only component class names\n const deferredImports = new Set<string>();\n const deferOnlyElements = new Set<string>();\n for (const el of deferElements) {\n if (!eagerElements.has(el)) deferOnlyElements.add(el);\n }\n\n for (const el of deferOnlyElements) {\n const className = selectorToClass.get(el);\n if (className && importMap.has(className)) {\n deferredImports.add(className);\n }\n }\n\n // Build the blocks map with dependency functions\n const blocks = new Map<any, any>();\n for (const block of deferBlocks) {\n const blockElements = collectElementNames(block.children || []);\n const blockDeps: any[] = [];\n // Within a single block, dedupe by `${path}#${symbolName}` so two\n // refs to the same component don't generate two import expressions.\n const seenInBlock = new Set<string>();\n\n for (const el of blockElements) {\n const className = selectorToClass.get(el);\n if (!className || !deferredImports.has(className)) continue;\n const info = importMap.get(className)!;\n // Use the original exported name (tracked by buildImportMap) so\n // aliased imports like `import { HeavyWidget as Widget }` resolve\n // to `m.HeavyWidget` instead of `m.Widget` (which would be\n // `undefined` on the module namespace).\n const symbolName = info.exportName;\n const key = `${info.path}#${symbolName}`;\n if (seenInBlock.has(key)) continue;\n seenInBlock.add(key);\n // import('./path').then(m => m.ClassName) — or `m.default` for\n // default imports. Without the `.then(...)` resolver Angular's\n // runtime gets a module namespace and can't find the class.\n // `FnParam` and the `variable()` helper aren't on the top-level\n // namespace; they live in the `outputAst` sub-namespace.\n const ast: any = (o as any).outputAst;\n const mVar = ast.variable('m');\n const innerFn = ast.arrowFn(\n [new ast.FnParam('m', ast.DYNAMIC_TYPE)],\n new o.ReadPropExpr(mVar, symbolName),\n );\n const importExpr = new o.InvokeFunctionExpr(\n new o.ReadPropExpr(\n new o.DynamicImportExpr(new o.LiteralExpr(info.path)),\n 'then',\n ),\n [innerFn],\n );\n blockDeps.push(new o.ArrowFunctionExpr([], importExpr));\n }\n\n if (blockDeps.length > 0) {\n // () => [import('./a').then(m => m.A), import('./b').then(m => m.default)]\n blocks.set(\n block,\n new o.ArrowFunctionExpr([], new o.LiteralArrayExpr(blockDeps)),\n );\n } else {\n blocks.set(block, null);\n }\n }\n\n return { blocks, deferredImports };\n}\n"],"mappings":";;;;AAKA,SAAgB,mBAAmB,OAAqB;CACtD,MAAM,SAAgB,EAAE;CACxB,SAAS,KAAK,MAAW;AACvB,MAAI,CAAC,KAAM;AACX,MAAI,KAAK,aAAa,SAAS,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AG;AAC5B,OAAI,YAAY,IAAI,IAAI,CAAE;AAC1B,eAAY,IAAI,IAAI;GAMpB,MAAM,MAAY,EAAU;GAC5B,MAAM,OAAO,IAAI,SAAS,IAAI;GAC9B,MAAM,UAAU,IAAI,QAClB,CAAC,IAAI,IAAI,QAAQ,KAAK,IAAI,aAAa,CAAC,EACxC,IAAI,EAAE,aAAa,MAAM,WAAW,CACrC;GACD,MAAM,aAAa,IAAI,EAAE,mBACvB,IAAI,EAAE,aACJ,IAAI,EAAE,kBAAkB,IAAI,EAAE,YAAY,KAAK,KAAK,CAAC,EACrD,OACD,EACD,CAAC,QAAQ,CACV;AACD,aAAU,KAAK,IAAI,EAAE,kBAAkB,EAAE,EAAE,WAAW,CAAC;;AAGzD,MAAI,UAAU,SAAS,EAErB,QAAO,IACL,OACA,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,iBAAiB,UAAU,CAAC,CAC/D;MAED,QAAO,IAAI,OAAO,KAAK;;AAI3B,QAAO;EAAE;EAAQ;EAAiB"}
|
|
@@ -184,6 +184,17 @@ for (const [name, str, precedence] of OP_DEFINITIONS) {
|
|
|
184
184
|
BINARY_PRECEDENCE.set(value, precedence);
|
|
185
185
|
if (ASSIGNMENT_OP_NAMES.has(name)) ASSIGNMENT_OP_VALUES.add(value);
|
|
186
186
|
}
|
|
187
|
+
var UNARY_OP_STR = /* @__PURE__ */ new Map();
|
|
188
|
+
for (const [name, str] of [
|
|
189
|
+
["Plus", "+"],
|
|
190
|
+
["Minus", "-"],
|
|
191
|
+
["Increment", "++"],
|
|
192
|
+
["Decrement", "--"]
|
|
193
|
+
]) {
|
|
194
|
+
const value = o.UnaryOperator[name];
|
|
195
|
+
if (typeof value !== "number") continue;
|
|
196
|
+
UNARY_OP_STR.set(value, str);
|
|
197
|
+
}
|
|
187
198
|
/** Returns true when `op` represents any kind of assignment (`=`, `+=`, etc.). */
|
|
188
199
|
function isAssignmentOperator(op) {
|
|
189
200
|
return ASSIGNMENT_OP_VALUES.has(op);
|
|
@@ -361,7 +372,10 @@ var JSEmitter = class JSEmitter {
|
|
|
361
372
|
return "typeof " + ast.expr.visitExpression(this, null);
|
|
362
373
|
}
|
|
363
374
|
visitUnaryOperatorExpr(ast) {
|
|
364
|
-
|
|
375
|
+
const op = UNARY_OP_STR.get(ast.operator);
|
|
376
|
+
if (op === void 0) throw new Error(`[fast-compile] Unsupported UnaryOperator value ${ast.operator} on @angular/compiler ${o.VERSION?.full ?? "(unknown version)"}`);
|
|
377
|
+
const operand = "(" + ast.expr.visitExpression(this, null) + ")";
|
|
378
|
+
return "(" + ("isPrefix" in ast && ast.isPrefix === false ? operand + op : op + operand) + ")";
|
|
365
379
|
}
|
|
366
380
|
visitInstantiateExpr(ast) {
|
|
367
381
|
return "new (" + ast.classExpr.visitExpression(this, null) + ")(" + ast.args.map((a) => this.emitExpr(a)).join(", ") + ")";
|