@analogjs/vite-plugin-angular 3.0.0-beta.4 → 3.0.0-beta.41
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/ngp/LICENSE +21 -0
- package/ngp/api.mjs +46048 -0
- package/ngp/build.json +4 -0
- package/ngp/ng_analyze.cjs +504 -0
- package/ngp/ng_analyze_bg.wasm +0 -0
- package/package.json +1 -1
- package/src/lib/analog-plugin-interop.js +1 -1
- package/src/lib/angular-build-context.d.ts +215 -0
- package/src/lib/angular-build-context.js +361 -0
- package/src/lib/angular-build-context.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +6 -4
- package/src/lib/angular-build-optimizer-plugin.js +10 -5
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +5 -3
- package/src/lib/angular-jit-plugin.js +14 -6
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +6 -109
- package/src/lib/angular-vite-plugin.js +8 -1246
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +3 -2
- package/src/lib/angular-vitest-plugin.js +6 -3
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/companion-plugins.d.ts +7 -0
- package/src/lib/companion-plugins.js +38 -0
- package/src/lib/companion-plugins.js.map +1 -0
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +11 -2
- package/src/lib/compilation-api/compilation-api-plugin.js +154 -282
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compiler/compile.d.ts +1 -1
- package/src/lib/compiler/compile.js +158 -143
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/defer.d.ts +2 -3
- package/src/lib/compiler/defer.js +11 -13
- package/src/lib/compiler/defer.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +6 -1
- package/src/lib/compiler/dts-reader.js +19 -10
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +7 -2
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +4 -4
- package/src/lib/compiler/jit-metadata.d.ts +3 -1
- package/src/lib/compiler/jit-metadata.js +10 -8
- package/src/lib/compiler/jit-metadata.js.map +1 -1
- package/src/lib/compiler/jit-transform.js +2 -2
- package/src/lib/compiler/jit-transform.js.map +1 -1
- package/src/lib/compiler/js-emitter.d.ts +0 -3
- package/src/lib/compiler/js-emitter.js +3 -21
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/compiler/registry.d.ts +7 -1
- package/src/lib/compiler/registry.js +23 -3
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/compiler/resource-inliner.d.ts +8 -9
- package/src/lib/compiler/resource-inliner.js +10 -18
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.d.ts +9 -1
- package/src/lib/compiler/style-ast.js +26 -5
- package/src/lib/compiler/style-ast.js.map +1 -1
- package/src/lib/compiler/type-elision.d.ts +4 -3
- package/src/lib/compiler/type-elision.js +10 -11
- package/src/lib/compiler/type-elision.js.map +1 -1
- package/src/lib/compiler/utils.d.ts +14 -7
- package/src/lib/compiler/utils.js +38 -9
- package/src/lib/compiler/utils.js.map +1 -1
- package/src/lib/component-styles-plugin.d.ts +52 -0
- package/src/lib/component-styles-plugin.js +353 -0
- package/src/lib/component-styles-plugin.js.map +1 -0
- package/src/lib/compose-angular-plugins.d.ts +12 -0
- package/src/lib/compose-angular-plugins.js +31 -0
- package/src/lib/compose-angular-plugins.js.map +1 -0
- package/src/lib/dev-server-mode-plugin.d.ts +7 -0
- package/src/lib/dev-server-mode-plugin.js +23 -0
- package/src/lib/dev-server-mode-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +6 -1
- package/src/lib/fast-compile-plugin.js +209 -79
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.d.ts +3 -0
- package/src/lib/host.js +4 -2
- package/src/lib/host.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +6 -3
- package/src/lib/live-reload-plugin.js +13 -6
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-plugin.d.ts +4 -0
- package/src/lib/ngp-compile-plugin.js +410 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
- package/src/lib/ngtsc-compile-plugin.js +763 -0
- package/src/lib/ngtsc-compile-plugin.js.map +1 -0
- package/src/lib/nx-folder-plugin.d.ts +6 -5
- package/src/lib/nx-folder-plugin.js +12 -7
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +6 -0
- package/src/lib/plugins/file-replacements.plugin.js +1 -0
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +5 -1
- package/src/lib/router-plugin.js +13 -4
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +1 -1
- package/src/lib/utils/devkit.js +1 -1
- package/src/lib/utils/hmr-component-updates.d.ts +7 -0
- package/src/lib/utils/hmr-component-updates.js +87 -0
- package/src/lib/utils/hmr-component-updates.js.map +1 -0
- package/src/lib/utils/lsp-type-checker.d.ts +55 -0
- package/src/lib/utils/lsp-type-checker.js +502 -0
- package/src/lib/utils/lsp-type-checker.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +15 -8
- package/src/lib/utils/plugin-config.js +18 -5
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/stylesheet-warning.d.ts +2 -0
- package/src/lib/utils/stylesheet-warning.js +11 -0
- package/src/lib/utils/stylesheet-warning.js.map +1 -0
- package/src/lib/utils/tsconfig-resolver.js +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +11 -3
- package/src/lib/virtual-modules-plugin.js +43 -12
- package/src/lib/virtual-modules-plugin.js.map +1 -1
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
import { discoverAnalogIntegrations } from "./analog-plugin-interop.js";
|
|
2
|
+
import { preprocessStylesheet } from "./stylesheet-registry.js";
|
|
3
|
+
import { isIgnoredHmrFile } from "./utils/compilation-shared.js";
|
|
4
|
+
import { angularFullVersion } from "./utils/devkit.js";
|
|
5
|
+
import { isRolldown } from "./utils/rolldown.js";
|
|
6
|
+
import { TS_EXT_REGEX, createDepOptimizerConfig, getTsConfigPath, isProdMode } from "./utils/plugin-config.js";
|
|
7
|
+
import { createAngularBuildContext, isAngularBuildContext } from "./angular-build-context.js";
|
|
8
|
+
import { releaseCssPreprocessorWorkers } from "./utils/css-preprocessor-workers.js";
|
|
9
|
+
import { loadAngularVirtualModule, resolveAngularVirtualId } from "./virtual-modules-plugin.js";
|
|
10
|
+
import { findHmrComponentUpdates } from "./utils/hmr-component-updates.js";
|
|
11
|
+
import { LspTypeChecker } from "./utils/lsp-type-checker.js";
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
import { resolve } from "node:path";
|
|
14
|
+
import * as vite from "vite";
|
|
15
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
16
|
+
//#region packages/vite-plugin-angular/src/lib/ngp-compile-plugin.ts
|
|
17
|
+
function isFastCompileOptions(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && !isAngularBuildContext(value) && "tsconfigGetter" in value && typeof value.tsconfigGetter === "function";
|
|
19
|
+
}
|
|
20
|
+
var BUNDLED_NGP = new URL("../../ngp/", "" + import.meta.url);
|
|
21
|
+
async function loadNgp(tsconfig) {
|
|
22
|
+
const nativeBinding = process.env["ANALOG_NGP_NATIVE_BINDING"];
|
|
23
|
+
let modulePath = process.env["ANALOG_NGP_COMPILER"];
|
|
24
|
+
if (!modulePath) try {
|
|
25
|
+
modulePath = createRequire(tsconfig).resolve("@angular/ngp");
|
|
26
|
+
} catch {
|
|
27
|
+
if (angularFullVersion < 220200) throw new Error("[@analogjs/vite-plugin-angular]: compilation: 'ngp' requires Angular v22.2 or later.");
|
|
28
|
+
return {
|
|
29
|
+
api: await import(new URL("api.mjs", BUNDLED_NGP).href),
|
|
30
|
+
analyzerOptions: nativeBinding ? { nativeBinding } : {
|
|
31
|
+
backend: "wasm",
|
|
32
|
+
wasmBinding: fileURLToPath(new URL("ng_analyze.cjs", BUNDLED_NGP))
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
api: await import(pathToFileURL(resolve(modulePath)).href),
|
|
38
|
+
analyzerOptions: nativeBinding ? { nativeBinding } : {}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function transpile(source, filePath, map) {
|
|
42
|
+
return vite.transformWithOxc ? vite.transformWithOxc(source, filePath, {
|
|
43
|
+
lang: "ts",
|
|
44
|
+
sourcemap: true
|
|
45
|
+
}, map) : vite.transformWithEsbuild(source, filePath, {
|
|
46
|
+
loader: "ts",
|
|
47
|
+
sourcemap: true
|
|
48
|
+
}, map);
|
|
49
|
+
}
|
|
50
|
+
function ngpCompilePlugin(optionsOrCtx) {
|
|
51
|
+
const sharedCtx = isAngularBuildContext(optionsOrCtx) ? optionsOrCtx : isFastCompileOptions(optionsOrCtx) ? void 0 : createAngularBuildContext({
|
|
52
|
+
jit: false,
|
|
53
|
+
...optionsOrCtx,
|
|
54
|
+
compilationBackend: "ngp"
|
|
55
|
+
});
|
|
56
|
+
const options = sharedCtx ? sharedCtx.options : optionsOrCtx;
|
|
57
|
+
if (options.jit || options.fastCompileMode === "partial") throw new Error("compilation: 'ngp' requires jit: false and fastCompileMode: 'full'.");
|
|
58
|
+
let configContext;
|
|
59
|
+
let resolvedConfig;
|
|
60
|
+
let transformFilter;
|
|
61
|
+
let stylePreprocessor;
|
|
62
|
+
let watchMode = false;
|
|
63
|
+
let hmr = false;
|
|
64
|
+
let activeBuilds = 0;
|
|
65
|
+
let analyzer;
|
|
66
|
+
let compiler;
|
|
67
|
+
let typeChecker;
|
|
68
|
+
let api;
|
|
69
|
+
const filesByPath = /* @__PURE__ */ new Map();
|
|
70
|
+
const chunkContexts = /* @__PURE__ */ new Map();
|
|
71
|
+
const output = /* @__PURE__ */ new Map();
|
|
72
|
+
const emittedMaps = /* @__PURE__ */ new Map();
|
|
73
|
+
const sources = /* @__PURE__ */ new Map();
|
|
74
|
+
const dependents = /* @__PURE__ */ new Map();
|
|
75
|
+
const hmrUpdateCode = /* @__PURE__ */ new Map();
|
|
76
|
+
const classNames = sharedCtx ? sharedCtx.hmr.classNames : /* @__PURE__ */ new Map();
|
|
77
|
+
const fileEmitter = (file, className) => ({ hmrUpdateCode: hmrUpdateCode.get(`${file}@${className}`) });
|
|
78
|
+
sharedCtx?.hmr.setFileEmitter(fileEmitter);
|
|
79
|
+
const componentUpdates = {
|
|
80
|
+
classNames,
|
|
81
|
+
fileEmitter
|
|
82
|
+
};
|
|
83
|
+
let pending = Promise.resolve();
|
|
84
|
+
const filter = vite.createFilter(TS_EXT_REGEX, [
|
|
85
|
+
/node_modules/,
|
|
86
|
+
/[?&]raw\b/,
|
|
87
|
+
/type=script/,
|
|
88
|
+
/@ng\/component/
|
|
89
|
+
]);
|
|
90
|
+
function resolveTsConfigPath() {
|
|
91
|
+
if (sharedCtx) return sharedCtx.resolveTsConfigPath();
|
|
92
|
+
const ctx = configContext ?? {
|
|
93
|
+
root: resolvedConfig?.root || ".",
|
|
94
|
+
isProd: isProdMode(resolvedConfig?.mode),
|
|
95
|
+
isLib: !!resolvedConfig?.build?.lib
|
|
96
|
+
};
|
|
97
|
+
return getTsConfigPath(ctx.root, options.tsconfigGetter(), ctx.isProd, options.isTest, ctx.isLib, options.workspaceRoot);
|
|
98
|
+
}
|
|
99
|
+
const compilerApi = {
|
|
100
|
+
angularCompiler: true,
|
|
101
|
+
getTsConfigPath: resolveTsConfigPath,
|
|
102
|
+
getSourceMap: (id) => emittedMaps.get(vite.normalizePath(id)),
|
|
103
|
+
hasEmitted: (id) => filesByPath.has(vite.normalizePath(id)),
|
|
104
|
+
output,
|
|
105
|
+
ready: () => pending,
|
|
106
|
+
componentUpdates
|
|
107
|
+
};
|
|
108
|
+
sharedCtx?.registerCompiler({
|
|
109
|
+
name: "@analogjs/vite-plugin-angular-ngp",
|
|
110
|
+
getTsConfigPath: compilerApi.getTsConfigPath,
|
|
111
|
+
getSourceMap: compilerApi.getSourceMap,
|
|
112
|
+
hasEmitted: compilerApi.hasEmitted
|
|
113
|
+
});
|
|
114
|
+
async function prepareResources(file, watch) {
|
|
115
|
+
watch(file.filePath);
|
|
116
|
+
const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;
|
|
117
|
+
const activeStylePreprocessor = sharedCtx?.stylePreprocessor ?? stylePreprocessor;
|
|
118
|
+
return {
|
|
119
|
+
...file,
|
|
120
|
+
classes: await Promise.all(file.classes.map(async (metadata, classIndex) => {
|
|
121
|
+
const component = metadata.component;
|
|
122
|
+
if (!component) return metadata;
|
|
123
|
+
if (component.templateUrl) watch(component.templateUrl.resolvedPath);
|
|
124
|
+
for (const style of component.styleUrls ?? []) watch(style.resolvedPath);
|
|
125
|
+
const preprocess = async (content, path, order, inline) => {
|
|
126
|
+
const preprocessed = preprocessStylesheet(content, path, activeStylePreprocessor, {
|
|
127
|
+
filename: path,
|
|
128
|
+
containingFile: file.filePath,
|
|
129
|
+
resourceFile: inline ? void 0 : path,
|
|
130
|
+
className: metadata.className,
|
|
131
|
+
order,
|
|
132
|
+
inline
|
|
133
|
+
});
|
|
134
|
+
const result = await vite.preprocessCSS(preprocessed, path, activeConfig);
|
|
135
|
+
result.deps?.forEach(watch);
|
|
136
|
+
return result.code;
|
|
137
|
+
};
|
|
138
|
+
return {
|
|
139
|
+
...metadata,
|
|
140
|
+
component: {
|
|
141
|
+
...component,
|
|
142
|
+
styles: component.styles && await Promise.all(component.styles.map((style, index) => preprocess(style, `${file.filePath}.inline-${classIndex}-${index}.${options.inlineStylesExtension}`, index, true))),
|
|
143
|
+
stylesFromUrls: component.stylesFromUrls && await Promise.all(component.stylesFromUrls.map((style, index) => preprocess(style, component.styleUrls[index].resolvedPath, index, false)))
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}))
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
async function indexChunks(update) {
|
|
150
|
+
if (update) {
|
|
151
|
+
const invalidated = await update();
|
|
152
|
+
for (const filePath of invalidated) {
|
|
153
|
+
output.delete(vite.normalizePath(filePath));
|
|
154
|
+
compiler.fileCache.delete(filePath);
|
|
155
|
+
}
|
|
156
|
+
chunkContexts.clear();
|
|
157
|
+
} else {
|
|
158
|
+
filesByPath.clear();
|
|
159
|
+
chunkContexts.clear();
|
|
160
|
+
output.clear();
|
|
161
|
+
compiler = new api.HybridCompiler(analyzer, {
|
|
162
|
+
optimize: true,
|
|
163
|
+
enableHmr: hmr
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const chunks = update ? compiler.analyzeOptimizedDelta() : compiler.analyzeOptimized();
|
|
167
|
+
for await (const chunk of chunks) for (const file of chunk.files) {
|
|
168
|
+
const normPath = vite.normalizePath(file.filePath);
|
|
169
|
+
filesByPath.set(normPath, {
|
|
170
|
+
file,
|
|
171
|
+
chunk
|
|
172
|
+
});
|
|
173
|
+
output.delete(normPath);
|
|
174
|
+
compiler.fileCache.delete(file.filePath);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function enqueueIndex(update) {
|
|
178
|
+
pending = pending.catch(() => {}).then(() => indexChunks(update));
|
|
179
|
+
return pending;
|
|
180
|
+
}
|
|
181
|
+
function getChunkContext(chunk) {
|
|
182
|
+
let context = chunkContexts.get(chunk);
|
|
183
|
+
if (!context) {
|
|
184
|
+
context = compiler.prepareChunk(chunk);
|
|
185
|
+
chunkContexts.set(chunk, context);
|
|
186
|
+
}
|
|
187
|
+
return context;
|
|
188
|
+
}
|
|
189
|
+
async function checkTypes(filePath, sourceCode, tcbCode) {
|
|
190
|
+
typeChecker ??= new LspTypeChecker(resolveTsConfigPath(), options.typeChecker);
|
|
191
|
+
typeChecker.queueFile(filePath, sourceCode, tcbCode);
|
|
192
|
+
if (!watchMode) return;
|
|
193
|
+
const typeErrors = await typeChecker.flushQueue(true);
|
|
194
|
+
if (typeErrors.length) throw new Error(typeErrors.join("\n"));
|
|
195
|
+
}
|
|
196
|
+
async function processFile(normPath, activeCompiler, watch) {
|
|
197
|
+
const { file: analyzed, chunk } = filesByPath.get(normPath);
|
|
198
|
+
const [file, context, content] = await Promise.all([
|
|
199
|
+
prepareResources(analyzed, (path) => {
|
|
200
|
+
const key = vite.normalizePath(path);
|
|
201
|
+
dependents.set(key, (dependents.get(key) ?? /* @__PURE__ */ new Set()).add(normPath));
|
|
202
|
+
watch(path);
|
|
203
|
+
}),
|
|
204
|
+
getChunkContext(chunk),
|
|
205
|
+
analyzer.getFileContent(analyzed.filePath)
|
|
206
|
+
]);
|
|
207
|
+
sources.set(normPath, content);
|
|
208
|
+
return {
|
|
209
|
+
file,
|
|
210
|
+
content,
|
|
211
|
+
result: activeCompiler.processFile.length >= 5 ? await activeCompiler.processFile(file.filePath, content, void 0, file, context) : await activeCompiler.processFile(file.filePath, content, file, context)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function compileFile(normPath, watch) {
|
|
215
|
+
if (!filesByPath.has(normPath)) return void 0;
|
|
216
|
+
let task = output.get(normPath);
|
|
217
|
+
if (!task) {
|
|
218
|
+
task = (async () => {
|
|
219
|
+
const { file, content, result } = await processFile(normPath, compiler, watch);
|
|
220
|
+
const errors = [...file.diagnostics ?? [], ...result.diagnostics ?? []].filter((diagnostic) => diagnostic.category === 1);
|
|
221
|
+
if (errors.length) throw new Error(`${file.filePath}: ${errors.map((error) => error.messageText).join("\n")}`);
|
|
222
|
+
if (options.disableTypeChecking !== true) await checkTypes(file.filePath, content, result.tcb?.code);
|
|
223
|
+
return result;
|
|
224
|
+
})();
|
|
225
|
+
output.set(normPath, task);
|
|
226
|
+
}
|
|
227
|
+
return task;
|
|
228
|
+
}
|
|
229
|
+
function componentNames(normPath) {
|
|
230
|
+
return (filesByPath.get(normPath)?.file.classes ?? []).flatMap(({ className, component }) => component && className ? [className] : []);
|
|
231
|
+
}
|
|
232
|
+
async function findComponentUpdates(normPath, read) {
|
|
233
|
+
if (!TS_EXT_REGEX.test(normPath)) return [...dependents.get(normPath) ?? []].flatMap((file) => componentNames(file).map((className) => ({
|
|
234
|
+
file,
|
|
235
|
+
className
|
|
236
|
+
})));
|
|
237
|
+
const stale = sources.get(normPath);
|
|
238
|
+
if (stale === void 0) return [];
|
|
239
|
+
return (findHmrComponentUpdates(normPath, stale, await read(), new Set(componentNames(normPath))) ?? []).map((className) => ({
|
|
240
|
+
file: normPath,
|
|
241
|
+
className
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
async function emitHmrUpdate(file, className) {
|
|
245
|
+
const { result } = await processFile(file, Object.assign(Object.create(Object.getPrototypeOf(compiler)), compiler, { hmrUpdateTarget: className }), () => {});
|
|
246
|
+
return result.hmrUpdateModule && (await transpile(result.hmrUpdateModule, file)).code;
|
|
247
|
+
}
|
|
248
|
+
async function sendComponentUpdates(updates, server) {
|
|
249
|
+
try {
|
|
250
|
+
for (const file of new Set(updates.map((update) => update.file))) await compileFile(file, () => {});
|
|
251
|
+
const codes = await Promise.all(updates.map(({ file, className }) => emitHmrUpdate(file, className)));
|
|
252
|
+
if (codes.some((code) => !code)) return false;
|
|
253
|
+
updates.forEach(({ file, className }, index) => {
|
|
254
|
+
hmrUpdateCode.set(`${file}@${className}`, codes[index]);
|
|
255
|
+
componentUpdates.classNames.set(file, className);
|
|
256
|
+
server.moduleGraph.getModulesByFile(file)?.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
257
|
+
server.ws.send("angular:component-update", {
|
|
258
|
+
id: encodeURIComponent(`${filesByPath.get(file).file.filePath}@${className}`),
|
|
259
|
+
timestamp: Date.now()
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
return true;
|
|
263
|
+
} catch {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
name: "@analogjs/vite-plugin-angular-ngp",
|
|
269
|
+
enforce: "pre",
|
|
270
|
+
api: compilerApi,
|
|
271
|
+
config(config, { command, mode }) {
|
|
272
|
+
watchMode = command === "serve";
|
|
273
|
+
const isProd = isProdMode(config.mode);
|
|
274
|
+
if (sharedCtx) sharedCtx.initConfig(config, {
|
|
275
|
+
command,
|
|
276
|
+
mode
|
|
277
|
+
});
|
|
278
|
+
else configContext = {
|
|
279
|
+
root: config.root || ".",
|
|
280
|
+
isProd,
|
|
281
|
+
isLib: !!config.build?.lib
|
|
282
|
+
};
|
|
283
|
+
const depOptimizer = createDepOptimizerConfig({
|
|
284
|
+
tsconfig: resolveTsConfigPath(),
|
|
285
|
+
isProd,
|
|
286
|
+
jit: false,
|
|
287
|
+
watchMode,
|
|
288
|
+
isTest: options.isTest,
|
|
289
|
+
isAstroIntegration: options.isAstroIntegration
|
|
290
|
+
});
|
|
291
|
+
return {
|
|
292
|
+
...isRolldown() ? { oxc: {} } : { esbuild: false },
|
|
293
|
+
...depOptimizer
|
|
294
|
+
};
|
|
295
|
+
},
|
|
296
|
+
async configResolved(config) {
|
|
297
|
+
resolvedConfig = config;
|
|
298
|
+
hmr = watchMode && options.liveReload && !options.isTest && config.server.hmr !== false;
|
|
299
|
+
const integrations = sharedCtx ? await sharedCtx.resolveConfig(config) : await discoverAnalogIntegrations(config);
|
|
300
|
+
transformFilter = integrations.transformFilter;
|
|
301
|
+
stylePreprocessor = integrations.stylePreprocessor;
|
|
302
|
+
},
|
|
303
|
+
configureServer(server) {
|
|
304
|
+
const changeTypes = {
|
|
305
|
+
add: 1,
|
|
306
|
+
change: 2,
|
|
307
|
+
unlink: 3
|
|
308
|
+
};
|
|
309
|
+
server.watcher.on("all", (event, path) => {
|
|
310
|
+
const type = changeTypes[event];
|
|
311
|
+
if (type) typeChecker?.notifyFileChanged(path, type);
|
|
312
|
+
});
|
|
313
|
+
server.httpServer?.on("close", () => {
|
|
314
|
+
typeChecker?.close();
|
|
315
|
+
typeChecker = void 0;
|
|
316
|
+
analyzer?.close();
|
|
317
|
+
analyzer = void 0;
|
|
318
|
+
compiler = void 0;
|
|
319
|
+
});
|
|
320
|
+
},
|
|
321
|
+
async buildStart() {
|
|
322
|
+
activeBuilds++;
|
|
323
|
+
if (!analyzer) {
|
|
324
|
+
const tsconfig = resolveTsConfigPath();
|
|
325
|
+
const ngp = await loadNgp(tsconfig);
|
|
326
|
+
api = ngp.api;
|
|
327
|
+
analyzer = await api.createAnalyzer(tsconfig, {
|
|
328
|
+
...ngp.analyzerOptions,
|
|
329
|
+
enableHmr: hmr
|
|
330
|
+
});
|
|
331
|
+
pending = indexChunks();
|
|
332
|
+
}
|
|
333
|
+
await pending;
|
|
334
|
+
for (const path of dependents.keys()) this.addWatchFile(path);
|
|
335
|
+
},
|
|
336
|
+
resolveId(id, importer) {
|
|
337
|
+
return resolveAngularVirtualId(id, importer, {
|
|
338
|
+
jit: false,
|
|
339
|
+
resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig
|
|
340
|
+
});
|
|
341
|
+
},
|
|
342
|
+
async load(id) {
|
|
343
|
+
return loadAngularVirtualModule(this, id, sharedCtx?.resolvedConfig ?? resolvedConfig);
|
|
344
|
+
},
|
|
345
|
+
async transform(code, id) {
|
|
346
|
+
const activeTransformFilter = sharedCtx?.transformFilter ?? transformFilter;
|
|
347
|
+
if (!filter(id) || activeTransformFilter?.(code, id) === false) return;
|
|
348
|
+
const filePath = vite.normalizePath(id.split("?")[0]);
|
|
349
|
+
await pending;
|
|
350
|
+
let result = await compileFile(filePath, (path) => this.addWatchFile(path));
|
|
351
|
+
if (result && result.magicString.original !== code) {
|
|
352
|
+
await enqueueIndex(() => analyzer.updateFileContent([{
|
|
353
|
+
filePath,
|
|
354
|
+
content: code
|
|
355
|
+
}]));
|
|
356
|
+
result = await compileFile(filePath, (path) => this.addWatchFile(path));
|
|
357
|
+
} else if (!result && options.disableTypeChecking !== true) await checkTypes(filePath, code);
|
|
358
|
+
const source = result?.magicString.toString() ?? code;
|
|
359
|
+
const map = result?.magicString.generateMap({
|
|
360
|
+
source: filePath,
|
|
361
|
+
includeContent: true,
|
|
362
|
+
hires: true
|
|
363
|
+
});
|
|
364
|
+
const transpiled = await transpile(source, filePath, map);
|
|
365
|
+
if (transpiled?.map) emittedMaps.set(filePath, typeof transpiled.map === "string" ? transpiled.map : JSON.stringify(transpiled.map));
|
|
366
|
+
return transpiled;
|
|
367
|
+
},
|
|
368
|
+
async handleHotUpdate(ctx) {
|
|
369
|
+
if (sharedCtx ? sharedCtx.hmr.isIgnoredFile(ctx.file) : isIgnoredHmrFile(ctx.file)) return [];
|
|
370
|
+
const normPath = vite.normalizePath(ctx.file);
|
|
371
|
+
const updates = hmr ? await findComponentUpdates(normPath, ctx.read) : [];
|
|
372
|
+
await enqueueIndex(() => analyzer.invalidateFiles([{
|
|
373
|
+
filePath: ctx.file,
|
|
374
|
+
updateType: 2
|
|
375
|
+
}]));
|
|
376
|
+
if (updates.length && await sendComponentUpdates(updates, ctx.server)) return [];
|
|
377
|
+
hmrUpdateCode.clear();
|
|
378
|
+
componentUpdates.classNames.clear();
|
|
379
|
+
ctx.server.moduleGraph.invalidateAll();
|
|
380
|
+
ctx.server.ws.send({ type: "full-reload" });
|
|
381
|
+
return [];
|
|
382
|
+
},
|
|
383
|
+
async buildEnd(error) {
|
|
384
|
+
if (error || watchMode || !typeChecker) return;
|
|
385
|
+
const typeErrors = await typeChecker.flushQueue();
|
|
386
|
+
if (typeErrors.length) throw new Error(typeErrors.join("\n"));
|
|
387
|
+
},
|
|
388
|
+
async closeBundle() {
|
|
389
|
+
activeBuilds = Math.max(0, activeBuilds - 1);
|
|
390
|
+
if (watchMode || activeBuilds > 0) return;
|
|
391
|
+
await pending.catch(() => {});
|
|
392
|
+
typeChecker?.close();
|
|
393
|
+
typeChecker = void 0;
|
|
394
|
+
analyzer?.close();
|
|
395
|
+
analyzer = void 0;
|
|
396
|
+
compiler = void 0;
|
|
397
|
+
filesByPath.clear();
|
|
398
|
+
chunkContexts.clear();
|
|
399
|
+
output.clear();
|
|
400
|
+
emittedMaps.clear();
|
|
401
|
+
sources.clear();
|
|
402
|
+
dependents.clear();
|
|
403
|
+
releaseCssPreprocessorWorkers();
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
408
|
+
export { ngpCompilePlugin };
|
|
409
|
+
|
|
410
|
+
//# sourceMappingURL=ngp-compile-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngp-compile-plugin.js","names":[],"sources":["../../../src/lib/ngp-compile-plugin.ts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport type MagicString from 'magic-string';\nimport * as vite from 'vite';\nimport {\n discoverAnalogIntegrations,\n type TransformFilter,\n} from './analog-plugin-interop.js';\nimport {\n createAngularBuildContext,\n isAngularBuildContext,\n type AngularBuildContext,\n type AngularBuildContextOptions,\n} from './angular-build-context.js';\nimport type { FastCompilePluginOptions } from './fast-compile-plugin.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport { isIgnoredHmrFile } from './utils/compilation-shared.js';\nimport {\n createDepOptimizerConfig,\n getTsConfigPath,\n isProdMode,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from './utils/plugin-config.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\nimport { angularFullVersion } from './utils/devkit.js';\nimport { findHmrComponentUpdates } from './utils/hmr-component-updates.js';\nimport {\n LspTypeChecker,\n type FileChangeType,\n} from './utils/lsp-type-checker.js';\nimport { isRolldown } from './utils/rolldown.js';\nimport type { ComponentUpdates } from './live-reload-plugin.js';\nimport {\n loadAngularVirtualModule,\n resolveAngularVirtualId,\n} from './virtual-modules-plugin.js';\n\n// The unpublished NGP API is loaded at runtime. Model only the surface we use.\ninterface NgpDiagnostic {\n category: number;\n messageText: string;\n}\n\ninterface NgpFile {\n filePath: string;\n diagnostics?: NgpDiagnostic[];\n classes: {\n className?: string;\n component?: {\n templateUrl?: { resolvedPath: string };\n styleUrls?: { resolvedPath: string }[];\n stylesFromUrls?: string[];\n styles?: string[];\n };\n }[];\n}\n\ninterface NgpChunk {\n files: NgpFile[];\n}\n\ninterface NgpResult {\n magicString: MagicString;\n diagnostics?: NgpDiagnostic[];\n tcb?: { code: string } | null;\n hmrUpdateModule?: string | null;\n}\n\ninterface NgpAnalyzer {\n getFileContent(path: string): Promise<string>;\n updateFileContent(\n updates: { filePath: string; content: string }[],\n ): Promise<string[]>;\n invalidateFiles(\n updates: { filePath: string; updateType: number }[],\n ): Promise<string[]>;\n close(): void;\n}\n\ninterface NgpCompiler {\n // Parsed templates by file, cleared by NGP's own update methods\n fileCache: Map<string, unknown>;\n analyzeOptimized(): AsyncIterable<NgpChunk>;\n analyzeOptimizedDelta(): AsyncIterable<NgpChunk>;\n prepareChunk(chunk: NgpChunk): Promise<unknown>;\n processFile(\n path: string,\n content: string,\n ...args: [undefined, NgpFile, unknown] | [NgpFile, unknown]\n ): Promise<NgpResult>;\n}\n\ninterface ComponentUpdate {\n file: string;\n className: string;\n}\n\ninterface NgpAnalyzerOptions {\n nativeBinding?: string;\n backend?: 'wasm';\n wasmBinding?: string;\n enableHmr?: boolean;\n}\n\ninterface NgpApi {\n createAnalyzer(\n tsconfig: string,\n options: NgpAnalyzerOptions,\n ): Promise<NgpAnalyzer>;\n HybridCompiler: new (\n analyzer: NgpAnalyzer,\n options: { optimize: boolean; enableHmr: boolean },\n ) => NgpCompiler;\n}\n\nfunction isFastCompileOptions(\n value: unknown,\n): value is FastCompilePluginOptions {\n return (\n typeof value === 'object' &&\n value !== null &&\n !isAngularBuildContext(value) &&\n 'tsconfigGetter' in value &&\n typeof (value as FastCompilePluginOptions).tsconfigGetter === 'function'\n );\n}\n\n// Interim NGP build bundled with this package until @angular/ngp is published\nconst BUNDLED_NGP = new URL('../../ngp/', import.meta.url);\n\nasync function loadNgp(\n tsconfig: string,\n): Promise<{ api: NgpApi; analyzerOptions: NgpAnalyzerOptions }> {\n const nativeBinding = process.env['ANALOG_NGP_NATIVE_BINDING'];\n let modulePath = process.env['ANALOG_NGP_COMPILER'];\n if (!modulePath) {\n try {\n modulePath = createRequire(tsconfig).resolve('@angular/ngp');\n } catch {\n if (angularFullVersion < 220200) {\n throw new Error(\n \"[@analogjs/vite-plugin-angular]: compilation: 'ngp' requires Angular v22.2 or later.\",\n );\n }\n return {\n api: await import(new URL('api.mjs', BUNDLED_NGP).href),\n analyzerOptions: nativeBinding\n ? { nativeBinding }\n : {\n backend: 'wasm',\n wasmBinding: fileURLToPath(\n new URL('ng_analyze.cjs', BUNDLED_NGP),\n ),\n },\n };\n }\n }\n return {\n api: await import(pathToFileURL(resolve(modulePath)).href),\n analyzerOptions: nativeBinding ? { nativeBinding } : {},\n };\n}\n\nfunction transpile(\n source: string,\n filePath: string,\n map?: Parameters<typeof vite.transformWithEsbuild>[3],\n) {\n return vite.transformWithOxc\n ? vite.transformWithOxc(\n source,\n filePath,\n { lang: 'ts', sourcemap: true },\n map,\n )\n : vite.transformWithEsbuild(\n source,\n filePath,\n { loader: 'ts', sourcemap: true },\n map,\n );\n}\n\nexport function ngpCompilePlugin(\n optionsOrCtx?:\n | AngularBuildContext\n | FastCompilePluginOptions\n | AngularBuildContextOptions,\n): vite.Plugin {\n const sharedCtx = isAngularBuildContext(optionsOrCtx)\n ? optionsOrCtx\n : isFastCompileOptions(optionsOrCtx)\n ? undefined\n : createAngularBuildContext({\n jit: false,\n ...optionsOrCtx,\n compilationBackend: 'ngp',\n });\n\n const options: FastCompilePluginOptions = sharedCtx\n ? sharedCtx.options\n : (optionsOrCtx as FastCompilePluginOptions);\n\n if (options.jit || options.fastCompileMode === 'partial') {\n throw new Error(\n \"compilation: 'ngp' requires jit: false and fastCompileMode: 'full'.\",\n );\n }\n\n let configContext: TsConfigResolutionContext | undefined;\n let resolvedConfig: vite.ResolvedConfig;\n let transformFilter: TransformFilter | undefined;\n let stylePreprocessor: StylePreprocessor | undefined;\n let watchMode = false;\n let hmr = false;\n let activeBuilds = 0;\n let analyzer: NgpAnalyzer | undefined;\n let compiler: NgpCompiler | undefined;\n let typeChecker: LspTypeChecker | undefined;\n let api: NgpApi;\n const filesByPath = new Map<string, { file: NgpFile; chunk: NgpChunk }>();\n const chunkContexts = new Map<NgpChunk, Promise<unknown>>();\n const output = new Map<string, Promise<NgpResult>>();\n const emittedMaps = new Map<string, string>();\n // Last compiled source of each file, compared on edits for HMR\n const sources = new Map<string, string>();\n // Watched files mapped to the source files that depend on them\n const dependents = new Map<string, Set<string>>();\n const hmrUpdateCode = new Map<string, string>();\n const classNames = sharedCtx\n ? sharedCtx.hmr.classNames\n : new Map<string, string>();\n const fileEmitter = (file: string, className: string) => ({\n hmrUpdateCode: hmrUpdateCode.get(`${file}@${className}`),\n });\n sharedCtx?.hmr.setFileEmitter(fileEmitter);\n\n const componentUpdates: ComponentUpdates = {\n classNames,\n fileEmitter,\n };\n let pending = Promise.resolve();\n const filter = vite.createFilter(TS_EXT_REGEX, [\n /node_modules/,\n /[?&]raw\\b/,\n /type=script/,\n /@ng\\/component/,\n ]);\n\n function resolveTsConfigPath(): string {\n if (sharedCtx) {\n return sharedCtx.resolveTsConfigPath();\n }\n const ctx = configContext ?? {\n root: resolvedConfig?.root || '.',\n isProd: isProdMode(resolvedConfig?.mode),\n isLib: !!resolvedConfig?.build?.lib,\n };\n return getTsConfigPath(\n ctx.root,\n options.tsconfigGetter(),\n ctx.isProd,\n options.isTest,\n ctx.isLib,\n options.workspaceRoot,\n );\n }\n\n const compilerApi = {\n angularCompiler: true as const,\n getTsConfigPath: resolveTsConfigPath,\n getSourceMap: (id: string): string | undefined =>\n emittedMaps.get(vite.normalizePath(id)),\n hasEmitted: (id: string): boolean =>\n filesByPath.has(vite.normalizePath(id)),\n output,\n ready: (): Promise<void> => pending,\n componentUpdates,\n };\n\n sharedCtx?.registerCompiler({\n name: '@analogjs/vite-plugin-angular-ngp',\n getTsConfigPath: compilerApi.getTsConfigPath,\n getSourceMap: compilerApi.getSourceMap,\n hasEmitted: compilerApi.hasEmitted,\n });\n\n async function prepareResources(\n file: NgpFile,\n watch: (path: string) => void,\n ): Promise<NgpFile> {\n watch(file.filePath);\n const activeConfig = sharedCtx?.resolvedConfig ?? resolvedConfig;\n const activeStylePreprocessor =\n sharedCtx?.stylePreprocessor ?? stylePreprocessor;\n\n return {\n ...file,\n classes: await Promise.all(\n file.classes.map(async (metadata, classIndex) => {\n const component = metadata.component;\n if (!component) return metadata;\n if (component.templateUrl) watch(component.templateUrl.resolvedPath);\n for (const style of component.styleUrls ?? [])\n watch(style.resolvedPath);\n const preprocess = async (\n content: string,\n path: string,\n order: number,\n inline: boolean,\n ) => {\n const preprocessed = preprocessStylesheet(\n content,\n path,\n activeStylePreprocessor,\n {\n filename: path,\n containingFile: file.filePath,\n resourceFile: inline ? undefined : path,\n className: metadata.className,\n order,\n inline,\n },\n );\n const result = await vite.preprocessCSS(\n preprocessed,\n path,\n activeConfig,\n );\n result.deps?.forEach(watch);\n return result.code;\n };\n return {\n ...metadata,\n component: {\n ...component,\n styles:\n component.styles &&\n (await Promise.all(\n component.styles.map((style, index) =>\n preprocess(\n style,\n `${file.filePath}.inline-${classIndex}-${index}.${options.inlineStylesExtension}`,\n index,\n true,\n ),\n ),\n )),\n stylesFromUrls:\n component.stylesFromUrls &&\n (await Promise.all(\n component.stylesFromUrls.map((style, index) =>\n preprocess(\n style,\n component.styleUrls![index].resolvedPath,\n index,\n false,\n ),\n ),\n )),\n },\n };\n }),\n ),\n };\n }\n\n async function indexChunks(update?: () => Promise<string[]>): Promise<void> {\n if (update) {\n const invalidated = await update();\n for (const filePath of invalidated) {\n output.delete(vite.normalizePath(filePath));\n compiler!.fileCache.delete(filePath);\n }\n chunkContexts.clear();\n } else {\n filesByPath.clear();\n chunkContexts.clear();\n output.clear();\n compiler = new api.HybridCompiler(analyzer!, {\n optimize: true,\n enableHmr: hmr,\n });\n }\n const chunks = update\n ? compiler!.analyzeOptimizedDelta()\n : compiler!.analyzeOptimized();\n for await (const chunk of chunks) {\n for (const file of chunk.files) {\n const normPath = vite.normalizePath(file.filePath);\n filesByPath.set(normPath, { file, chunk });\n output.delete(normPath);\n compiler!.fileCache.delete(file.filePath);\n }\n }\n }\n\n function enqueueIndex(update: () => Promise<string[]>): Promise<void> {\n pending = pending.catch(() => {}).then(() => indexChunks(update));\n return pending;\n }\n\n function getChunkContext(chunk: NgpChunk): Promise<unknown> {\n let context = chunkContexts.get(chunk);\n if (!context) {\n context = compiler!.prepareChunk(chunk);\n chunkContexts.set(chunk, context);\n }\n return context;\n }\n\n async function checkTypes(\n filePath: string,\n sourceCode: string,\n tcbCode?: string | null,\n ): Promise<void> {\n typeChecker ??= new LspTypeChecker(\n resolveTsConfigPath(),\n options.typeChecker,\n );\n typeChecker.queueFile(filePath, sourceCode, tcbCode);\n if (!watchMode) return;\n const typeErrors = await typeChecker.flushQueue(true);\n if (typeErrors.length) {\n throw new Error(typeErrors.join('\\n'));\n }\n }\n\n async function processFile(\n normPath: string,\n activeCompiler: NgpCompiler,\n watch: (path: string) => void,\n ) {\n const { file: analyzed, chunk } = filesByPath.get(normPath)!;\n const [file, context, content] = await Promise.all([\n prepareResources(analyzed, (path) => {\n const key = vite.normalizePath(path);\n dependents.set(key, (dependents.get(key) ?? new Set()).add(normPath));\n watch(path);\n }),\n getChunkContext(chunk),\n analyzer!.getFileContent(analyzed.filePath),\n ]);\n sources.set(normPath, content);\n const result =\n activeCompiler.processFile.length >= 5\n ? await activeCompiler.processFile(\n file.filePath,\n content,\n undefined,\n file,\n context,\n )\n : await activeCompiler.processFile(\n file.filePath,\n content,\n file,\n context,\n );\n return { file, content, result };\n }\n\n function compileFile(\n normPath: string,\n watch: (path: string) => void,\n ): Promise<NgpResult> | undefined {\n if (!filesByPath.has(normPath)) return undefined;\n let task = output.get(normPath);\n if (!task) {\n task = (async () => {\n const { file, content, result } = await processFile(\n normPath,\n compiler!,\n watch,\n );\n const errors = [\n ...(file.diagnostics ?? []),\n ...(result.diagnostics ?? []),\n ].filter((diagnostic) => diagnostic.category === 1);\n if (errors.length) {\n throw new Error(\n `${file.filePath}: ${errors.map((error) => error.messageText).join('\\n')}`,\n );\n }\n if (options.disableTypeChecking !== true) {\n await checkTypes(file.filePath, content, result.tcb?.code);\n }\n return result;\n })();\n output.set(normPath, task);\n }\n return task;\n }\n\n function componentNames(normPath: string): string[] {\n return (filesByPath.get(normPath)?.file.classes ?? []).flatMap(\n ({ className, component }) => (component && className ? [className] : []),\n );\n }\n\n // Components to update in place, following the Angular CLI's rule\n async function findComponentUpdates(\n normPath: string,\n read: () => string | Promise<string>,\n ): Promise<ComponentUpdate[]> {\n if (!TS_EXT_REGEX.test(normPath)) {\n return [...(dependents.get(normPath) ?? [])].flatMap((file) =>\n componentNames(file).map((className) => ({ file, className })),\n );\n }\n const stale = sources.get(normPath);\n if (stale === undefined) return [];\n const matchedClassNames = findHmrComponentUpdates(\n normPath,\n stale,\n await read(),\n new Set(componentNames(normPath)),\n );\n return (matchedClassNames ?? []).map((className) => ({\n file: normPath,\n className,\n }));\n }\n\n async function emitHmrUpdate(file: string, className: string) {\n // NGP emits only the update module of the class named by `hmrUpdateTarget`\n const target = Object.assign(\n Object.create(Object.getPrototypeOf(compiler)),\n compiler,\n { hmrUpdateTarget: className },\n );\n const { result } = await processFile(file, target, () => {});\n return (\n result.hmrUpdateModule &&\n (await transpile(result.hmrUpdateModule, file)).code\n );\n }\n\n async function sendComponentUpdates(\n updates: ComponentUpdate[],\n server: vite.ViteDevServer,\n ): Promise<boolean> {\n try {\n for (const file of new Set(updates.map((update) => update.file))) {\n await compileFile(file, () => {});\n }\n const codes = await Promise.all(\n updates.map(({ file, className }) => emitHmrUpdate(file, className)),\n );\n if (codes.some((code) => !code)) return false;\n updates.forEach(({ file, className }, index) => {\n hmrUpdateCode.set(`${file}@${className}`, codes[index]!);\n componentUpdates.classNames.set(file, className);\n server.moduleGraph\n .getModulesByFile(file)\n ?.forEach((mod) => server.moduleGraph.invalidateModule(mod));\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(\n `${filesByPath.get(file)!.file.filePath}@${className}`,\n ),\n timestamp: Date.now(),\n });\n });\n return true;\n } catch {\n // A full reload reports the compilation error\n return false;\n }\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-ngp',\n enforce: 'pre',\n api: compilerApi,\n config(config, { command, mode }) {\n watchMode = command === 'serve';\n const isProd = isProdMode(config.mode);\n if (sharedCtx) {\n sharedCtx.initConfig(config, { command, mode });\n } else {\n configContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config.build?.lib,\n };\n }\n const depOptimizer = createDepOptimizerConfig({\n tsconfig: resolveTsConfigPath(),\n isProd,\n jit: false,\n watchMode,\n isTest: options.isTest,\n isAstroIntegration: options.isAstroIntegration,\n });\n return {\n ...(isRolldown() ? { oxc: {} as any } : { esbuild: false }),\n ...depOptimizer,\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n hmr =\n watchMode &&\n options.liveReload &&\n !options.isTest &&\n config.server.hmr !== false;\n const integrations = sharedCtx\n ? await sharedCtx.resolveConfig(config)\n : await discoverAnalogIntegrations(config);\n transformFilter = integrations.transformFilter;\n stylePreprocessor = integrations.stylePreprocessor;\n },\n configureServer(server) {\n const changeTypes: Record<string, FileChangeType> = {\n add: 1,\n change: 2,\n unlink: 3,\n };\n server.watcher.on('all', (event, path) => {\n const type = changeTypes[event];\n if (type) typeChecker?.notifyFileChanged(path, type);\n });\n server.httpServer?.on('close', () => {\n typeChecker?.close();\n typeChecker = undefined;\n analyzer?.close();\n analyzer = undefined;\n compiler = undefined;\n });\n },\n async buildStart() {\n activeBuilds++;\n if (!analyzer) {\n const tsconfig = resolveTsConfigPath();\n const ngp = await loadNgp(tsconfig);\n api = ngp.api;\n analyzer = await api.createAnalyzer(tsconfig, {\n ...ngp.analyzerOptions,\n enableHmr: hmr,\n });\n pending = indexChunks();\n }\n await pending;\n for (const path of dependents.keys()) {\n this.addWatchFile(path);\n }\n },\n resolveId(id, importer) {\n return resolveAngularVirtualId(id, importer, {\n jit: false,\n resolvedConfig: sharedCtx?.resolvedConfig ?? resolvedConfig,\n });\n },\n async load(id) {\n return loadAngularVirtualModule(\n this,\n id,\n sharedCtx?.resolvedConfig ?? resolvedConfig,\n );\n },\n async transform(code, id) {\n const activeTransformFilter =\n sharedCtx?.transformFilter ?? transformFilter;\n if (!filter(id) || activeTransformFilter?.(code, id) === false) return;\n const filePath = vite.normalizePath(id.split('?')[0]);\n await pending;\n let result = await compileFile(filePath, (path) =>\n this.addWatchFile(path),\n );\n if (result && result.magicString.original !== code) {\n await enqueueIndex(() =>\n analyzer!.updateFileContent([{ filePath, content: code }]),\n );\n result = await compileFile(filePath, (path) => this.addWatchFile(path));\n } else if (!result && options.disableTypeChecking !== true) {\n await checkTypes(filePath, code);\n }\n const source = result?.magicString.toString() ?? code;\n const map = result?.magicString.generateMap({\n source: filePath,\n includeContent: true,\n hires: true,\n });\n const transpiled = await transpile(source, filePath, map);\n if (transpiled?.map) {\n emittedMaps.set(\n filePath,\n typeof transpiled.map === 'string'\n ? transpiled.map\n : JSON.stringify(transpiled.map),\n );\n }\n return transpiled;\n },\n async handleHotUpdate(ctx) {\n if (\n sharedCtx\n ? sharedCtx.hmr.isIgnoredFile(ctx.file)\n : isIgnoredHmrFile(ctx.file)\n ) {\n return [];\n }\n const normPath = vite.normalizePath(ctx.file);\n const updates = hmr ? await findComponentUpdates(normPath, ctx.read) : [];\n await enqueueIndex(() =>\n analyzer!.invalidateFiles([{ filePath: ctx.file, updateType: 2 }]),\n );\n if (updates.length && (await sendComponentUpdates(updates, ctx.server))) {\n return [];\n }\n hmrUpdateCode.clear();\n componentUpdates.classNames.clear();\n ctx.server.moduleGraph.invalidateAll();\n ctx.server.ws.send({ type: 'full-reload' });\n return [];\n },\n async buildEnd(error) {\n if (error || watchMode || !typeChecker) return;\n const typeErrors = await typeChecker.flushQueue();\n if (typeErrors.length) {\n throw new Error(typeErrors.join('\\n'));\n }\n },\n async closeBundle() {\n activeBuilds = Math.max(0, activeBuilds - 1);\n if (watchMode || activeBuilds > 0) return;\n await pending.catch(() => {});\n typeChecker?.close();\n typeChecker = undefined;\n analyzer?.close();\n analyzer = undefined;\n compiler = undefined;\n filesByPath.clear();\n chunkContexts.clear();\n output.clear();\n emittedMaps.clear();\n sources.clear();\n dependents.clear();\n releaseCssPreprocessorWorkers();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsHA,SAAS,qBACP,OACmC;CACnC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,sBAAsB,KAAK,KAC5B,oBAAoB,SACpB,OAAQ,MAAmC,mBAAmB;AAElE;AAGA,IAAM,cAAc,IAAA,IAAA,cAAA,KAAA,YAAA,GAAA;AAEpB,eAAe,QACb,UAC+D;CAC/D,MAAM,gBAAgB,QAAQ,IAAI;CAClC,IAAI,aAAa,QAAQ,IAAI;CAC7B,IAAI,CAAC,YACH,IAAI;EACF,aAAa,cAAc,QAAQ,CAAC,CAAC,QAAQ,cAAc;CAC7D,QAAQ;EACN,IAAI,qBAAqB,QACvB,MAAM,IAAI,MACR,sFACF;EAEF,OAAO;GACL,KAAK,MAAM,OAAO,IAAI,IAAI,WAAW,WAAW,CAAC,CAAC;GAClD,iBAAiB,gBACb,EAAE,cAAc,IAChB;IACE,SAAS;IACT,aAAa,cACX,IAAI,IAAI,kBAAkB,WAAW,CACvC;GACF;EACN;CACF;CAEF,OAAO;EACL,KAAK,MAAM,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,CAAC;EACrD,iBAAiB,gBAAgB,EAA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AAa;GACxC,MAAM,aAAa,MAAM,YAAY,WAAW;GAChD,IAAI,WAAW,QACb,MAAM,IAAI,MAAM,WAAW,KAAK,IAAI,CAAC;EAEzC;EACA,MAAM,cAAc;GAClB,eAAe,KAAK,IAAI,GAAG,eAAe,CAAC;GAC3C,IAAI,aAAa,eAAe,GAAG;GACnC,MAAM,QAAQ,YAAY,CAAC,CAAC;GAC5B,aAAa,MAAM;GACnB,cAAc,KAAA;GACd,UAAU,MAAM;GAChB,WAAW,KAAA;GACX,WAAW,KAAA;GACX,YAAY,MAAM;GAClB,cAAc,MAAM;GACpB,OAAO,MAAM;GACb,YAAY,MAAM;GAClB,QAAQ,MAAM;GACd,WAAW,MAAM;GACjB,8BAA8B;EAChC;CACF;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NgtscProgram } from "@angular/compiler-cli";
|
|
2
|
+
import type * as ts from "typescript";
|
|
3
|
+
import { type Plugin } from "vite";
|
|
4
|
+
import { type AngularBuildContext, type AngularBuildContextOptions } from "./angular-build-context.js";
|
|
5
|
+
export interface FileMetadataResult {
|
|
6
|
+
errors?: string[];
|
|
7
|
+
warnings?: (string | ts.DiagnosticMessageChain)[];
|
|
8
|
+
hmrUpdateCode?: string | null;
|
|
9
|
+
hmrEligible?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function evictDeletedFileMetadata(file: string, { classNamesMap, fileTransformMap }: {
|
|
12
|
+
classNamesMap: Map<string, string>;
|
|
13
|
+
fileTransformMap: Map<string, string>;
|
|
14
|
+
}): void;
|
|
15
|
+
export declare function createFsWatcherCacheInvalidator(invalidateFsCaches: () => void, invalidateTsconfigCaches: () => void, performCompilation: () => Promise<void>): () => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Compiles Angular TypeScript sources using `@angular/compiler-cli` (`NgtscProgram`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function ngtscCompilePlugin(ctxOrOptions?: AngularBuildContext | AngularBuildContextOptions): Plugin;
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function getFileMetadata(program: ts.BuilderProgram, angularCompiler?: NgtscProgram["compiler"], hmrEnabled?: boolean, disableTypeChecking?: boolean, classNamesMap?: Map<string, string>): (file: string) => FileMetadataResult;
|