@analogjs/vite-plugin-angular 3.0.0-alpha.42 → 3.0.0-alpha.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/angular-jit-plugin.js +1 -1
- package/src/lib/angular-vite-plugin.d.ts +3 -77
- package/src/lib/angular-vite-plugin.js +77 -1012
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +29 -0
- package/src/lib/compilation-api/compilation-api-plugin.js +468 -0
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
- package/src/lib/compilation-api/index.d.ts +1 -0
- package/src/lib/compilation-api/index.js +1 -0
- package/src/lib/compiler/compile.js +2 -2
- package/src/lib/compiler/defer.js +1 -1
- package/src/lib/compiler/js-emitter.js +1 -1
- package/src/lib/encapsulation-plugin.d.ts +13 -0
- package/src/lib/encapsulation-plugin.js +48 -0
- package/src/lib/encapsulation-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.js +2 -28
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.js +1 -1
- package/src/lib/stylesheet-registry.js +1 -1
- package/src/lib/tailwind-plugin.d.ts +34 -0
- package/src/lib/tailwind-plugin.js +116 -0
- package/src/lib/tailwind-plugin.js.map +1 -0
- package/src/lib/template-class-binding-guard-plugin.d.ts +30 -0
- package/src/lib/template-class-binding-guard-plugin.js +237 -0
- package/src/lib/template-class-binding-guard-plugin.js.map +1 -0
- package/src/lib/utils/compilation-shared.d.ts +58 -0
- package/src/lib/utils/compilation-shared.js +133 -0
- package/src/lib/utils/compilation-shared.js.map +1 -0
- package/src/lib/utils/tsconfig-resolver.d.ts +28 -0
- package/src/lib/utils/tsconfig-resolver.js +191 -0
- package/src/lib/utils/tsconfig-resolver.js.map +1 -0
- package/src/lib/utils/virtual-resources.js +4 -31
- package/src/lib/utils/virtual-resources.js.map +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +5 -0
- package/src/lib/virtual-modules-plugin.js +50 -0
- package/src/lib/virtual-modules-plugin.js.map +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
import { type DebugOption } from "../utils/debug.js";
|
|
3
|
+
import type { StylePreprocessor } from "../style-preprocessor.js";
|
|
4
|
+
import { AngularStylePipelineOptions } from "../style-pipeline.js";
|
|
5
|
+
import { type FileReplacement } from "../plugins/file-replacements.plugin.js";
|
|
6
|
+
export interface CompilationAPIPluginOptions {
|
|
7
|
+
tsconfigGetter: () => string;
|
|
8
|
+
workspaceRoot: string;
|
|
9
|
+
inlineStylesExtension: string;
|
|
10
|
+
jit: boolean;
|
|
11
|
+
liveReload: boolean;
|
|
12
|
+
disableTypeChecking: boolean;
|
|
13
|
+
supportedBrowsers: string[];
|
|
14
|
+
transformFilter?: (code: string, id: string) => boolean;
|
|
15
|
+
fileReplacements: FileReplacement[];
|
|
16
|
+
stylePreprocessor?: StylePreprocessor;
|
|
17
|
+
stylePipeline?: AngularStylePipelineOptions;
|
|
18
|
+
hasTailwindCss: boolean;
|
|
19
|
+
tailwindCss?: {
|
|
20
|
+
rootStylesheet: string;
|
|
21
|
+
prefixes?: string[];
|
|
22
|
+
};
|
|
23
|
+
isTest: boolean;
|
|
24
|
+
isAstroIntegration: boolean;
|
|
25
|
+
include: string[];
|
|
26
|
+
additionalContentDirs: string[];
|
|
27
|
+
debug?: DebugOption;
|
|
28
|
+
}
|
|
29
|
+
export declare function compilationAPIPlugin(pluginOptions: CompilationAPIPluginOptions): Plugin;
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { angularFullVersion, createAngularCompilation, sourceFileCache } from "../utils/devkit.js";
|
|
2
|
+
import { activateDeferredDebug, debugCompilationApi, debugCompiler, debugEmit, debugHmr, debugHmrV, debugStyles } from "../utils/debug.js";
|
|
3
|
+
import { isTailwindReferenceError } from "../utils/tailwind-reference.js";
|
|
4
|
+
import { shouldPreprocessTestCss } from "../utils/virtual-resources.js";
|
|
5
|
+
import { normalizeStylesheetDependencies } from "../style-preprocessor.js";
|
|
6
|
+
import { AnalogStylesheetRegistry, preprocessStylesheetResult, registerStylesheetContent, rewriteRelativeCssImports } from "../stylesheet-registry.js";
|
|
7
|
+
import { TS_EXT_REGEX, getTsConfigPath } from "../utils/plugin-config.js";
|
|
8
|
+
import { TsconfigResolver } from "../utils/tsconfig-resolver.js";
|
|
9
|
+
import { configureStylePipelineRegistry } from "../style-pipeline.js";
|
|
10
|
+
import { DiagnosticModes, injectViteIgnoreForHmrMetadata, isIgnoredHmrFile, isTestWatchMode, mapTemplateUpdatesToFiles, refreshStylesheetRegistryForFile, toAngularCompilationFileReplacements } from "../utils/compilation-shared.js";
|
|
11
|
+
import { union } from "es-toolkit";
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { basename, isAbsolute, join, relative, resolve } from "node:path";
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import { normalizePath, preprocessCSS } from "vite";
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
//#region packages/vite-plugin-angular/src/lib/compilation-api/compilation-api-plugin.ts
|
|
18
|
+
var ts = createRequire(import.meta.url)("typescript");
|
|
19
|
+
function compilationAPIPlugin(pluginOptions) {
|
|
20
|
+
let resolvedConfig;
|
|
21
|
+
let tsConfigResolutionContext = null;
|
|
22
|
+
let watchMode = false;
|
|
23
|
+
let angularCompilation;
|
|
24
|
+
const sourceFileCache$1 = new sourceFileCache();
|
|
25
|
+
const outputFiles = /* @__PURE__ */ new Map();
|
|
26
|
+
const classNames = /* @__PURE__ */ new Map();
|
|
27
|
+
let stylesheetRegistry;
|
|
28
|
+
let compilationLock = Promise.resolve();
|
|
29
|
+
let pendingCompilation = null;
|
|
30
|
+
let initialCompilation = false;
|
|
31
|
+
let viteServer;
|
|
32
|
+
const isTest = process.env.NODE_ENV === "test" || !!process.env["VITEST"];
|
|
33
|
+
const tsconfigResolver = new TsconfigResolver({
|
|
34
|
+
workspaceRoot: pluginOptions.workspaceRoot,
|
|
35
|
+
include: pluginOptions.include,
|
|
36
|
+
liveReload: pluginOptions.liveReload,
|
|
37
|
+
hasTailwindCss: pluginOptions.hasTailwindCss,
|
|
38
|
+
isTest
|
|
39
|
+
});
|
|
40
|
+
const isVitestVscode = !!process.env["VITEST_VSCODE"];
|
|
41
|
+
let testWatchMode = isTestWatchMode();
|
|
42
|
+
function hasViteHmrTransport() {
|
|
43
|
+
return resolvedConfig ? resolvedConfig.server.hmr !== false : true;
|
|
44
|
+
}
|
|
45
|
+
function shouldEnableLiveReload() {
|
|
46
|
+
return !!((isTest ? testWatchMode : watchMode) && pluginOptions.liveReload && hasViteHmrTransport());
|
|
47
|
+
}
|
|
48
|
+
function shouldExternalizeStyles() {
|
|
49
|
+
if (!(isTest ? testWatchMode : watchMode)) return false;
|
|
50
|
+
return !!(shouldEnableLiveReload() || pluginOptions.hasTailwindCss);
|
|
51
|
+
}
|
|
52
|
+
function resolveTsConfigPath() {
|
|
53
|
+
const tsconfigValue = pluginOptions.tsconfigGetter();
|
|
54
|
+
return getTsConfigPath(tsConfigResolutionContext.root, tsconfigValue, tsConfigResolutionContext.isProd, isTest, tsConfigResolutionContext.isLib);
|
|
55
|
+
}
|
|
56
|
+
function resolveCompilationApiTsConfigPath(resolvedTsConfigPath, config) {
|
|
57
|
+
const includedFiles = tsconfigResolver.ensureIncludeCache();
|
|
58
|
+
const cached = tsconfigResolver.getCachedTsconfigOptions(resolvedTsConfigPath, config);
|
|
59
|
+
const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(resolvedTsConfigPath, config);
|
|
60
|
+
const mergedRootNames = union(cached.rootNames, expandedGraphRoots, includedFiles).map((file) => normalizePath(file));
|
|
61
|
+
if (mergedRootNames.length === cached.rootNames.length) return resolvedTsConfigPath;
|
|
62
|
+
const wrapperDir = join(isAbsolute(config.cacheDir) ? config.cacheDir : resolve(config.root, config.cacheDir), "analog-angular", "compilation-api");
|
|
63
|
+
const rawTsconfig = ts.readConfigFile(resolvedTsConfigPath, ts.sys.readFile).config ?? {};
|
|
64
|
+
const wrapperPayload = {
|
|
65
|
+
extends: normalizePath(resolvedTsConfigPath),
|
|
66
|
+
files: [...mergedRootNames].sort(),
|
|
67
|
+
...rawTsconfig.references ? { references: rawTsconfig.references } : {}
|
|
68
|
+
};
|
|
69
|
+
const wrapperPath = join(wrapperDir, `tsconfig.includes.${createHash("sha1").update(JSON.stringify(wrapperPayload)).digest("hex").slice(0, 12)}.json`);
|
|
70
|
+
mkdirSync(wrapperDir, { recursive: true });
|
|
71
|
+
if (!existsSync(wrapperPath)) writeFileSync(wrapperPath, `${JSON.stringify(wrapperPayload, null, 2)}\n`, "utf-8");
|
|
72
|
+
debugCompilationApi("generated include wrapper tsconfig", {
|
|
73
|
+
originalTsconfig: resolvedTsConfigPath,
|
|
74
|
+
wrapperTsconfig: wrapperPath,
|
|
75
|
+
includeCount: includedFiles.length,
|
|
76
|
+
rootNameCount: mergedRootNames.length
|
|
77
|
+
});
|
|
78
|
+
return wrapperPath;
|
|
79
|
+
}
|
|
80
|
+
const normalizeEmitterLookupId = (file) => {
|
|
81
|
+
const normalizedFile = normalizePath(file);
|
|
82
|
+
if (!normalizedFile.startsWith("/@fs/")) return normalizedFile;
|
|
83
|
+
return normalizePath(normalizedFile.slice(4).replace(/^\/([A-Za-z]:\/)/, "$1"));
|
|
84
|
+
};
|
|
85
|
+
let outputFile;
|
|
86
|
+
const fileEmitter = (file) => {
|
|
87
|
+
const normalizedFile = normalizeEmitterLookupId(file);
|
|
88
|
+
outputFile?.(normalizedFile);
|
|
89
|
+
return outputFiles.get(normalizedFile);
|
|
90
|
+
};
|
|
91
|
+
async function performAngularCompilation(config, ids) {
|
|
92
|
+
const compilation = angularCompilation ??= await createAngularCompilation(!!pluginOptions.jit, false);
|
|
93
|
+
const modifiedFiles = ids?.length ? new Set(ids.map((file) => normalizePath(file))) : void 0;
|
|
94
|
+
if (modifiedFiles?.size) sourceFileCache$1.invalidate(modifiedFiles);
|
|
95
|
+
if (modifiedFiles?.size && compilation.update) {
|
|
96
|
+
debugCompilationApi("incremental update", { files: [...modifiedFiles] });
|
|
97
|
+
await compilation.update(modifiedFiles);
|
|
98
|
+
}
|
|
99
|
+
const resolvedTsConfigPath = resolveTsConfigPath();
|
|
100
|
+
const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(resolvedTsConfigPath, config);
|
|
101
|
+
debugEmit("compilation initialize", {
|
|
102
|
+
resolvedTsConfigPath,
|
|
103
|
+
compilationApiTsConfigPath,
|
|
104
|
+
modifiedFileCount: modifiedFiles?.size ?? 0
|
|
105
|
+
});
|
|
106
|
+
const compilationResult = await compilation.initialize(compilationApiTsConfigPath, {
|
|
107
|
+
fileReplacements: toAngularCompilationFileReplacements(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),
|
|
108
|
+
modifiedFiles,
|
|
109
|
+
async transformStylesheet(data, containingFile, resourceFile, order, className) {
|
|
110
|
+
const filename = resourceFile ?? containingFile.replace(".ts", `.${pluginOptions.inlineStylesExtension}`);
|
|
111
|
+
const preprocessed = preprocessStylesheetResult(data, filename, pluginOptions.stylePreprocessor, {
|
|
112
|
+
filename,
|
|
113
|
+
containingFile,
|
|
114
|
+
resourceFile,
|
|
115
|
+
className,
|
|
116
|
+
order,
|
|
117
|
+
inline: !resourceFile
|
|
118
|
+
});
|
|
119
|
+
if (shouldEnableLiveReload() && className && containingFile) classNames.set(normalizePath(containingFile), className);
|
|
120
|
+
if (shouldExternalizeStyles()) {
|
|
121
|
+
const stylesheetId = registerStylesheetContent(stylesheetRegistry, {
|
|
122
|
+
code: preprocessed.code,
|
|
123
|
+
dependencies: normalizeStylesheetDependencies(preprocessed.dependencies),
|
|
124
|
+
diagnostics: preprocessed.diagnostics,
|
|
125
|
+
tags: preprocessed.tags,
|
|
126
|
+
containingFile,
|
|
127
|
+
className,
|
|
128
|
+
order,
|
|
129
|
+
inlineStylesExtension: pluginOptions.inlineStylesExtension,
|
|
130
|
+
resourceFile: resourceFile ?? void 0
|
|
131
|
+
});
|
|
132
|
+
debugStyles("stylesheet deferred to Vite pipeline", {
|
|
133
|
+
stylesheetId,
|
|
134
|
+
resourceFile: resourceFile ?? "(inline)"
|
|
135
|
+
});
|
|
136
|
+
return stylesheetId;
|
|
137
|
+
}
|
|
138
|
+
debugStyles("stylesheet processed inline via preprocessCSS", {
|
|
139
|
+
filename,
|
|
140
|
+
resourceFile: resourceFile ?? "(inline)",
|
|
141
|
+
dataLength: preprocessed.code.length
|
|
142
|
+
});
|
|
143
|
+
if (!shouldPreprocessTestCss(resolvedConfig, filename)) return "";
|
|
144
|
+
let stylesheetResult;
|
|
145
|
+
try {
|
|
146
|
+
stylesheetResult = await preprocessCSS(preprocessed.code, `${filename}?direct`, resolvedConfig);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
if (isTailwindReferenceError(e)) throw e;
|
|
149
|
+
debugStyles("preprocessCSS error", {
|
|
150
|
+
filename,
|
|
151
|
+
resourceFile: resourceFile ?? "(inline)",
|
|
152
|
+
error: String(e)
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return stylesheetResult?.code || "";
|
|
156
|
+
},
|
|
157
|
+
processWebWorker(_workerFile, _containingFile) {
|
|
158
|
+
return "";
|
|
159
|
+
}
|
|
160
|
+
}, (tsCompilerOptions) => {
|
|
161
|
+
if (shouldExternalizeStyles()) tsCompilerOptions["externalRuntimeStyles"] = true;
|
|
162
|
+
if (shouldEnableLiveReload()) {
|
|
163
|
+
tsCompilerOptions["_enableHmr"] = true;
|
|
164
|
+
tsCompilerOptions["supportTestBed"] = true;
|
|
165
|
+
}
|
|
166
|
+
debugCompiler("tsCompilerOptions (compilation API)", {
|
|
167
|
+
liveReload: pluginOptions.liveReload,
|
|
168
|
+
viteHmr: hasViteHmrTransport(),
|
|
169
|
+
hasTailwindCss: pluginOptions.hasTailwindCss,
|
|
170
|
+
watchMode,
|
|
171
|
+
shouldExternalize: shouldExternalizeStyles(),
|
|
172
|
+
externalRuntimeStyles: !!tsCompilerOptions["externalRuntimeStyles"],
|
|
173
|
+
hmrEnabled: !!tsCompilerOptions["_enableHmr"]
|
|
174
|
+
});
|
|
175
|
+
if (tsCompilerOptions["compilationMode"] === "partial") {
|
|
176
|
+
tsCompilerOptions["supportTestBed"] = true;
|
|
177
|
+
tsCompilerOptions["supportJitMode"] = true;
|
|
178
|
+
}
|
|
179
|
+
if (!isTest && resolvedConfig.build?.lib) {
|
|
180
|
+
tsCompilerOptions["declaration"] = true;
|
|
181
|
+
tsCompilerOptions["declarationMap"] = watchMode;
|
|
182
|
+
tsCompilerOptions["inlineSources"] = true;
|
|
183
|
+
}
|
|
184
|
+
if (isTest) tsCompilerOptions["supportTestBed"] = true;
|
|
185
|
+
return tsCompilerOptions;
|
|
186
|
+
});
|
|
187
|
+
debugStyles("external stylesheets from compilation API", {
|
|
188
|
+
count: compilationResult.externalStylesheets?.size ?? 0,
|
|
189
|
+
hasPreprocessor: !!pluginOptions.stylePreprocessor,
|
|
190
|
+
hasInlineMap: !!stylesheetRegistry
|
|
191
|
+
});
|
|
192
|
+
const preprocessStats = {
|
|
193
|
+
total: 0,
|
|
194
|
+
injected: 0,
|
|
195
|
+
skipped: 0,
|
|
196
|
+
errors: 0
|
|
197
|
+
};
|
|
198
|
+
for (const [key, value] of compilationResult.externalStylesheets ?? []) {
|
|
199
|
+
preprocessStats.total++;
|
|
200
|
+
const angularHash = `${value}.css`;
|
|
201
|
+
stylesheetRegistry?.registerExternalRequest(angularHash, key);
|
|
202
|
+
if (stylesheetRegistry && pluginOptions.stylePreprocessor && existsSync(key)) try {
|
|
203
|
+
const rawCss = readFileSync(key, "utf-8");
|
|
204
|
+
const preprocessed = preprocessStylesheetResult(rawCss, key, pluginOptions.stylePreprocessor);
|
|
205
|
+
const servedCss = rewriteRelativeCssImports(preprocessed.code, key);
|
|
206
|
+
stylesheetRegistry.registerServedStylesheet({
|
|
207
|
+
publicId: angularHash,
|
|
208
|
+
sourcePath: key,
|
|
209
|
+
originalCode: rawCss,
|
|
210
|
+
normalizedCode: servedCss,
|
|
211
|
+
dependencies: normalizeStylesheetDependencies(preprocessed.dependencies),
|
|
212
|
+
diagnostics: preprocessed.diagnostics,
|
|
213
|
+
tags: preprocessed.tags
|
|
214
|
+
}, [
|
|
215
|
+
key,
|
|
216
|
+
normalizePath(key),
|
|
217
|
+
basename(key),
|
|
218
|
+
key.replace(/^\//, "")
|
|
219
|
+
]);
|
|
220
|
+
if (servedCss && servedCss !== rawCss) preprocessStats.injected++;
|
|
221
|
+
else preprocessStats.skipped++;
|
|
222
|
+
} catch (e) {
|
|
223
|
+
preprocessStats.errors++;
|
|
224
|
+
console.warn(`[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`);
|
|
225
|
+
}
|
|
226
|
+
else preprocessStats.skipped++;
|
|
227
|
+
}
|
|
228
|
+
debugStyles("external stylesheet preprocessing complete", preprocessStats);
|
|
229
|
+
const diagnostics = await compilation.diagnoseFiles(pluginOptions.disableTypeChecking ? DiagnosticModes.All & ~DiagnosticModes.Semantic : DiagnosticModes.All);
|
|
230
|
+
const errors = diagnostics.errors?.length ? diagnostics.errors : [];
|
|
231
|
+
const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];
|
|
232
|
+
const templateUpdates = mapTemplateUpdatesToFiles(compilationResult.templateUpdates);
|
|
233
|
+
if (templateUpdates.size > 0) debugHmr("compilation API template updates", {
|
|
234
|
+
count: templateUpdates.size,
|
|
235
|
+
files: [...templateUpdates.keys()]
|
|
236
|
+
});
|
|
237
|
+
const affectedFiles = await compilation.emitAffectedFiles();
|
|
238
|
+
debugEmit("emitAffectedFiles summary", {
|
|
239
|
+
count: affectedFiles.length,
|
|
240
|
+
templateUpdateCount: templateUpdates.size,
|
|
241
|
+
knownOutputCountBefore: outputFiles.size
|
|
242
|
+
});
|
|
243
|
+
for (const file of affectedFiles) {
|
|
244
|
+
const normalizedFilename = normalizePath(file.filename);
|
|
245
|
+
const templateUpdate = templateUpdates.get(normalizedFilename);
|
|
246
|
+
if (templateUpdate) classNames.set(normalizedFilename, templateUpdate.className);
|
|
247
|
+
outputFiles.set(normalizedFilename, {
|
|
248
|
+
content: file.contents,
|
|
249
|
+
dependencies: [],
|
|
250
|
+
errors: errors.map((error) => error.text || ""),
|
|
251
|
+
warnings: warnings.map((warning) => warning.text || ""),
|
|
252
|
+
hmrUpdateCode: templateUpdate?.code,
|
|
253
|
+
hmrEligible: !!templateUpdate?.code
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async function performCompilation(config, ids) {
|
|
258
|
+
let resolve;
|
|
259
|
+
const previousLock = compilationLock;
|
|
260
|
+
compilationLock = new Promise((r) => {
|
|
261
|
+
resolve = r;
|
|
262
|
+
});
|
|
263
|
+
try {
|
|
264
|
+
await previousLock;
|
|
265
|
+
await performAngularCompilation(config, ids);
|
|
266
|
+
} finally {
|
|
267
|
+
resolve();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function isComponentStyleSheet(id) {
|
|
271
|
+
return id.includes("ngcomp=");
|
|
272
|
+
}
|
|
273
|
+
function getFilenameFromPath(id) {
|
|
274
|
+
try {
|
|
275
|
+
return new URL(id, "http://localhost").pathname.replace(/^\//, "");
|
|
276
|
+
} catch {
|
|
277
|
+
const queryIndex = id.indexOf("?");
|
|
278
|
+
return (queryIndex >= 0 ? id.slice(0, queryIndex) : id).replace(/^\//, "");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function sendHMRComponentUpdate(server, id) {
|
|
282
|
+
debugHmrV("ws send: angular component update", {
|
|
283
|
+
id,
|
|
284
|
+
timestamp: Date.now()
|
|
285
|
+
});
|
|
286
|
+
server.ws.send("angular:component-update", {
|
|
287
|
+
id: encodeURIComponent(id),
|
|
288
|
+
timestamp: Date.now()
|
|
289
|
+
});
|
|
290
|
+
classNames.delete(id);
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
name: "@analogjs/vite-plugin-angular-compilation-api",
|
|
294
|
+
enforce: "pre",
|
|
295
|
+
async config(config, { command }) {
|
|
296
|
+
activateDeferredDebug(command);
|
|
297
|
+
watchMode = command === "serve";
|
|
298
|
+
const isProd = config.mode === "production" || process.env.NODE_ENV === "production";
|
|
299
|
+
tsConfigResolutionContext = {
|
|
300
|
+
root: config.root || ".",
|
|
301
|
+
isProd,
|
|
302
|
+
isLib: !!config?.build?.lib
|
|
303
|
+
};
|
|
304
|
+
if (angularFullVersion < 200100) console.warn("[@analogjs/vite-plugin-angular]: The Angular Compilation API is only available with Angular v20.1 and later");
|
|
305
|
+
else debugCompilationApi("enabled (Angular %s)", angularFullVersion);
|
|
306
|
+
debugCompilationApi("esbuild/oxc disabled, Angular handles transforms");
|
|
307
|
+
return {
|
|
308
|
+
esbuild: void 0,
|
|
309
|
+
oxc: void 0,
|
|
310
|
+
optimizeDeps: {
|
|
311
|
+
include: [
|
|
312
|
+
"rxjs/operators",
|
|
313
|
+
"rxjs",
|
|
314
|
+
"tslib"
|
|
315
|
+
],
|
|
316
|
+
exclude: ["@angular/platform-server"]
|
|
317
|
+
},
|
|
318
|
+
resolve: { conditions: ["style", ...config.resolve?.conditions ?? []] }
|
|
319
|
+
};
|
|
320
|
+
},
|
|
321
|
+
configResolved(config) {
|
|
322
|
+
resolvedConfig = config;
|
|
323
|
+
stylesheetRegistry = new AnalogStylesheetRegistry();
|
|
324
|
+
configureStylePipelineRegistry(pluginOptions.stylePipeline, stylesheetRegistry, { workspaceRoot: pluginOptions.workspaceRoot });
|
|
325
|
+
debugStyles("stylesheet registry initialized (Angular Compilation API)");
|
|
326
|
+
if (isTest) testWatchMode = !(config.server.watch === null) || config.test?.watch === true || testWatchMode;
|
|
327
|
+
},
|
|
328
|
+
configureServer(server) {
|
|
329
|
+
viteServer = server;
|
|
330
|
+
const invalidateCompilation = async () => {
|
|
331
|
+
tsconfigResolver.invalidateAll();
|
|
332
|
+
await performCompilation(resolvedConfig);
|
|
333
|
+
};
|
|
334
|
+
server.watcher.on("add", invalidateCompilation);
|
|
335
|
+
server.watcher.on("unlink", invalidateCompilation);
|
|
336
|
+
server.watcher.on("change", (file) => {
|
|
337
|
+
if (file.includes("tsconfig")) tsconfigResolver.invalidateTsconfigCaches();
|
|
338
|
+
});
|
|
339
|
+
},
|
|
340
|
+
async buildStart() {
|
|
341
|
+
if (!isVitestVscode) {
|
|
342
|
+
await performCompilation(resolvedConfig);
|
|
343
|
+
pendingCompilation = null;
|
|
344
|
+
initialCompilation = true;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
async handleHotUpdate(ctx) {
|
|
348
|
+
if (isIgnoredHmrFile(ctx.file)) {
|
|
349
|
+
debugHmr("ignored file change", { file: ctx.file });
|
|
350
|
+
return [];
|
|
351
|
+
}
|
|
352
|
+
if (TS_EXT_REGEX.test(ctx.file)) {
|
|
353
|
+
const [fileId] = ctx.file.split("?");
|
|
354
|
+
debugHmr("TS file changed", {
|
|
355
|
+
file: ctx.file,
|
|
356
|
+
fileId
|
|
357
|
+
});
|
|
358
|
+
pendingCompilation = performCompilation(resolvedConfig, [fileId]);
|
|
359
|
+
let result;
|
|
360
|
+
if (shouldEnableLiveReload()) {
|
|
361
|
+
await pendingCompilation;
|
|
362
|
+
pendingCompilation = null;
|
|
363
|
+
result = fileEmitter(fileId);
|
|
364
|
+
debugHmr("TS file emitted", {
|
|
365
|
+
fileId,
|
|
366
|
+
hmrEligible: !!result?.hmrEligible,
|
|
367
|
+
hasClassName: !!classNames.get(fileId)
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
if (shouldEnableLiveReload() && result?.hmrEligible && classNames.get(fileId)) {
|
|
371
|
+
const relativeFileId = `${normalizePath(relative(process.cwd(), fileId))}@${classNames.get(fileId)}`;
|
|
372
|
+
debugHmr("sending component update", { relativeFileId });
|
|
373
|
+
sendHMRComponentUpdate(ctx.server, relativeFileId);
|
|
374
|
+
return ctx.modules.map((mod) => {
|
|
375
|
+
if (mod.id === ctx.file) mod.isSelfAccepting = true;
|
|
376
|
+
return mod;
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (/\.(html|htm)$/.test(ctx.file)) {
|
|
381
|
+
debugHmr("template file changed", { file: ctx.file });
|
|
382
|
+
pendingCompilation = performCompilation(resolvedConfig);
|
|
383
|
+
}
|
|
384
|
+
if (/\.(css|less|sass|scss)$/.test(ctx.file)) {
|
|
385
|
+
debugHmr("stylesheet file changed", { file: ctx.file });
|
|
386
|
+
refreshStylesheetRegistryForFile(ctx.file, stylesheetRegistry, pluginOptions.stylePreprocessor);
|
|
387
|
+
}
|
|
388
|
+
return ctx.modules;
|
|
389
|
+
},
|
|
390
|
+
resolveId(id) {
|
|
391
|
+
if (isComponentStyleSheet(id)) {
|
|
392
|
+
const filename = getFilenameFromPath(id);
|
|
393
|
+
if (stylesheetRegistry?.hasServed(filename)) return id;
|
|
394
|
+
const componentStyles = stylesheetRegistry?.resolveExternalSource(filename);
|
|
395
|
+
if (componentStyles) return componentStyles + new URL(id, "http://localhost").search;
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
async load(id) {
|
|
399
|
+
if (isComponentStyleSheet(id)) {
|
|
400
|
+
const filename = getFilenameFromPath(id);
|
|
401
|
+
const componentStyles = stylesheetRegistry?.getServedContent(filename);
|
|
402
|
+
if (componentStyles) {
|
|
403
|
+
stylesheetRegistry?.registerActiveRequest(id);
|
|
404
|
+
return componentStyles;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
transform: {
|
|
409
|
+
filter: { id: {
|
|
410
|
+
include: [TS_EXT_REGEX],
|
|
411
|
+
exclude: [
|
|
412
|
+
/node_modules/,
|
|
413
|
+
"type=script",
|
|
414
|
+
"@ng/component"
|
|
415
|
+
]
|
|
416
|
+
} },
|
|
417
|
+
async handler(code, id) {
|
|
418
|
+
if (pluginOptions.transformFilter && !(pluginOptions.transformFilter(code, id) ?? true)) return;
|
|
419
|
+
const isAngular = /(Component|Directive|Pipe|Injectable|NgModule)\(/.test(code);
|
|
420
|
+
if (!isAngular) {
|
|
421
|
+
debugCompilationApi("transform skip (non-Angular file)", { id });
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (id.includes("?") && id.includes("analog-content-")) return;
|
|
425
|
+
if (id.includes(".ts?")) id = id.replace(/\?(.*)/, "");
|
|
426
|
+
if (isTest) {
|
|
427
|
+
if (isVitestVscode && !initialCompilation) {
|
|
428
|
+
pendingCompilation = performCompilation(resolvedConfig);
|
|
429
|
+
initialCompilation = true;
|
|
430
|
+
}
|
|
431
|
+
const tsMod = viteServer?.moduleGraph.getModuleById(id);
|
|
432
|
+
if (tsMod) {
|
|
433
|
+
const invalidated = tsMod.lastInvalidationTimestamp;
|
|
434
|
+
if (testWatchMode && invalidated) pendingCompilation = performCompilation(resolvedConfig, [id]);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (pendingCompilation) {
|
|
438
|
+
await pendingCompilation;
|
|
439
|
+
pendingCompilation = null;
|
|
440
|
+
}
|
|
441
|
+
const typescriptResult = fileEmitter(id);
|
|
442
|
+
if (!typescriptResult) {
|
|
443
|
+
debugCompilationApi("transform skip (file not emitted)", { id });
|
|
444
|
+
if (isAngular) this.warn(`[@analogjs/vite-plugin-angular]: "${id}" contains Angular decorators but is not in the TypeScript program. Ensure it is included in your tsconfig.`);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (typescriptResult.warnings && typescriptResult.warnings.length > 0) this.warn(`${typescriptResult.warnings.join("\n")}`);
|
|
448
|
+
if (typescriptResult.errors && typescriptResult.errors.length > 0) this.error(`${typescriptResult.errors.join("\n")}`);
|
|
449
|
+
let data = typescriptResult.content ?? "";
|
|
450
|
+
if (data.includes("HmrLoad")) {
|
|
451
|
+
if (data.includes("getReplaceMetadataURL")) data = injectViteIgnoreForHmrMetadata(data);
|
|
452
|
+
}
|
|
453
|
+
return {
|
|
454
|
+
code: data,
|
|
455
|
+
map: null
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
closeBundle() {
|
|
460
|
+
angularCompilation?.close?.();
|
|
461
|
+
angularCompilation = void 0;
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
//#endregion
|
|
466
|
+
export { compilationAPIPlugin };
|
|
467
|
+
|
|
468
|
+
//# sourceMappingURL=compilation-api-plugin.js.map
|
|
@@ -0,0 +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 {\n basename,\n dirname,\n isAbsolute,\n join,\n relative,\n resolve,\n} 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 debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { shouldPreprocessTestCss } from '../utils/virtual-resources.js';\nimport { isTailwindReferenceError } from '../utils/tailwind-reference.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 AngularStylePipelineOptions,\n configureStylePipelineRegistry,\n} from '../style-pipeline.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';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface CompilationAPIPluginOptions {\n tsconfigGetter: () => string;\n workspaceRoot: string;\n inlineStylesExtension: string;\n jit: boolean;\n liveReload: boolean;\n disableTypeChecking: boolean;\n supportedBrowsers: string[];\n transformFilter?: (code: string, id: string) => boolean;\n fileReplacements: FileReplacement[];\n stylePreprocessor?: StylePreprocessor;\n stylePipeline?: AngularStylePipelineOptions;\n hasTailwindCss: boolean;\n tailwindCss?: {\n rootStylesheet: string;\n prefixes?: string[];\n };\n isTest: boolean;\n isAstroIntegration: boolean;\n include: string[];\n additionalContentDirs: string[];\n debug?: DebugOption;\n}\n\nexport function compilationAPIPlugin(\n pluginOptions: CompilationAPIPluginOptions,\n): Plugin {\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = 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 isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n hasTailwindCss: pluginOptions.hasTailwindCss,\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() || pluginOptions.hasTailwindCss);\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 pluginOptions.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 if (!shouldPreprocessTestCss(resolvedConfig, filename)) {\n return '';\n }\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n if (isTailwindReferenceError(e)) {\n throw e;\n }\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, _containingFile: string) {\n return '';\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 hasTailwindCss: pluginOptions.hasTailwindCss,\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: !!pluginOptions.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 (\n stylesheetRegistry &&\n pluginOptions.stylePreprocessor &&\n existsSync(key)\n ) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n pluginOptions.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 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 return {\n name: '@analogjs/vite-plugin-angular-compilation-api',\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 if (angularFullVersion < 200100) {\n console.warn(\n '[@analogjs/vite-plugin-angular]: The Angular Compilation API is only available with Angular v20.1 and later',\n );\n } else {\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n }\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 return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n },\n resolve: {\n conditions: ['style', ...(config.resolve?.conditions ?? [])],\n },\n };\n },\n configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n configureStylePipelineRegistry(\n pluginOptions.stylePipeline,\n 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 await performCompilation(resolvedConfig);\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 pluginOptions.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\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 // 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: [/node_modules/, 'type=script', '@ng/component'],\n },\n },\n async handler(code, id) {\n if (\n pluginOptions.transformFilter &&\n !(pluginOptions.transformFilter(code, id) ?? true)\n ) {\n return;\n }\n\n // Skip non-Angular files — in compilation API mode, Angular\n // compiles TypeScript before this hook, so only Angular files\n // need processing.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n if (!isAngular) {\n debugCompilationApi('transform skip (non-Angular file)', { id });\n return;\n }\n\n if (id.includes('?') && id.includes('analog-content-')) {\n return;\n }\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 closeBundle() {\n angularCompilation?.close?.();\n angularCompilation = undefined;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsEA,IAAM,KADU,cAAc,OAAO,KAAK,IAAI,CAC3B,aAAa;AA0BhC,SAAgB,qBACd,eACQ;CACR,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAIhB,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;CACzB,IAAI;CAEJ,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,mBAAmB,IAAI,iBAAiB;EAC5C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GAAG,QAAQ,UAAU,GAAG;AAG/B,QAAI,QAAQ;AACV,SAAI,kBAAkB,CAAC,oBAAoB;AACzC,2BAAqB,mBAAmB,eAAe;AACvD,2BAAqB;;KAGvB,MAAM,QAAQ,YAAY,YAAY,cAAc,GAAG;AACvD,SAAI,OAAO;MACT,MAAM,cAAc,MAAM;AAC1B,UAAI,iBAAiB,YACnB,sBAAqB,mBAAmB,gBAAgB,CAAC,GAAG,CAAC;;;AAKnE,QAAI,oBAAoB;AACtB,WAAM;AACN,0BAAqB;;IAGvB,MAAM,mBAAmB,YAAY,GAAG;AACxC,QAAI,CAAC,kBAAkB;AACrB,yBAAoB,qCAAqC,EAAE,IAAI,CAAC;AAChE,SAAI,UACF,MAAK,KACH,qCAAqC,GAAG,6GAEzC;AAEH;;AAGF,QAAI,iBAAiB,YAAY,iBAAiB,SAAS,SAAS,EAClE,MAAK,KAAK,GAAG,iBAAiB,SAAS,KAAK,KAAK,GAAG;AAGtD,QAAI,iBAAiB,UAAU,iBAAiB,OAAO,SAAS,EAC9D,MAAK,MAAM,GAAG,iBAAiB,OAAO,KAAK,KAAK,GAAG;IAGrD,IAAI,OAAO,iBAAiB,WAAW;AAGvC,QAAI,KAAK,SAAS,UAAU;SACP,KAAK,SAAS,wBAAwB,CAEvD,QAAO,+BAA+B,KAAK;;AAI/C,WAAO;KACL,MAAM;KACN,KAAK;KACN;;GAEJ;EACD,cAAc;AACZ,uBAAoB,SAAS;AAC7B,wBAAqB,KAAA;;EAExB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { compilationAPIPlugin, type CompilationAPIPluginOptions } from "./compilation-api-plugin.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./compilation-api-plugin.js";
|
|
@@ -9,10 +9,10 @@ import { debugCompile } from "./debug.js";
|
|
|
9
9
|
import { ANGULAR_MAJOR } from "./angular-version.js";
|
|
10
10
|
import * as fs from "node:fs";
|
|
11
11
|
import * as path$1 from "node:path";
|
|
12
|
-
import * as o from "@angular/compiler";
|
|
13
|
-
import { ConstantPool, FactoryTarget, ParseLocation, ParseSourceFile, ParseSourceSpan, R3NgModuleMetadataKind, R3SelectorScopeMode, compileClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDirectiveFromMetadata, compileFactoryFunction, compileInjector, compileNgModule, compilePipeFromMetadata, makeBindingParser, parseHostBindings, parseTemplate } from "@angular/compiler";
|
|
14
12
|
import { parseSync } from "oxc-parser";
|
|
15
13
|
import * as ts from "typescript";
|
|
14
|
+
import * as o from "@angular/compiler";
|
|
15
|
+
import { ConstantPool, FactoryTarget, ParseLocation, ParseSourceFile, ParseSourceSpan, R3NgModuleMetadataKind, R3SelectorScopeMode, compileClassMetadata, compileComponentFromMetadata, compileDeclareClassMetadata, compileDeclareComponentFromMetadata, compileDeclareDirectiveFromMetadata, compileDeclareFactoryFunction, compileDeclareInjectableFromMetadata, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileDeclarePipeFromMetadata, compileDirectiveFromMetadata, compileFactoryFunction, compileInjector, compileNgModule, compilePipeFromMetadata, makeBindingParser, parseHostBindings, parseTemplate } from "@angular/compiler";
|
|
16
16
|
import MagicString from "magic-string";
|
|
17
17
|
//#region packages/vite-plugin-angular/src/lib/compiler/compile.ts
|
|
18
18
|
function hasExportModifier(node) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as o from "@angular/compiler";
|
|
2
1
|
import * as ts from "typescript";
|
|
2
|
+
import * as o from "@angular/compiler";
|
|
3
3
|
//#region packages/vite-plugin-angular/src/lib/compiler/defer.ts
|
|
4
4
|
/** Recursively collect all DeferredBlock nodes from a template AST. */
|
|
5
5
|
function collectDeferBlocks(nodes) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as o from "@angular/compiler";
|
|
2
1
|
import * as ts from "typescript";
|
|
2
|
+
import * as o from "@angular/compiler";
|
|
3
3
|
//#region packages/vite-plugin-angular/src/lib/compiler/js-emitter.ts
|
|
4
4
|
/** Shared printer — only used as fallback for complex WrappedNodeExpr (e.g. decorator args). */
|
|
5
5
|
var sharedPrinter = ts.createPrinter({ removeComments: true });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
export declare function isComponentStyleSheet(id: string): boolean;
|
|
3
|
+
export declare function getComponentStyleSheetMeta(id: string): {
|
|
4
|
+
componentId: string;
|
|
5
|
+
encapsulation: "emulated" | "shadow" | "none";
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Encapsulation runs in enforce: 'post' so that @tailwindcss/vite
|
|
9
|
+
* (enforce: 'pre') fully resolves @apply directives — including those
|
|
10
|
+
* inside :host {} — before Angular's ShadowCss rewrites selectors.
|
|
11
|
+
* (#2293)
|
|
12
|
+
*/
|
|
13
|
+
export declare function encapsulationPlugin(shouldExternalizeStyles: () => boolean): Plugin;
|