@analogjs/vite-plugin-angular 3.0.0-beta.2 → 3.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +13 -2
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- 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 -14
- package/src/lib/angular-build-optimizer-plugin.js +6 -3
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +20 -5
- package/src/lib/angular-vite-plugin.js +28 -13
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compiler/compile.js +5 -2
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +5 -0
- package/src/lib/compiler/dts-reader.js +9 -3
- 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 +3 -3
- 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/registry.d.ts +6 -0
- package/src/lib/compiler/registry.js +21 -1
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/fast-compile-plugin.d.ts +3 -0
- package/src/lib/fast-compile-plugin.js +97 -15
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +4 -3
- package/src/lib/live-reload-plugin.js +4 -3
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-plugin.d.ts +3 -0
- package/src/lib/ngp-compile-plugin.js +344 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +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 +9 -0
- package/src/lib/utils/plugin-config.js +10 -1
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/migrations/migrations.json +0 -9
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +0 -2
- package/migrations/update-3-0-0/migrate-setup-vitest.js +0 -37
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SourceFileCache, angularFullVersion, createJitResourceTransformer } from "./utils/devkit.js";
|
|
2
2
|
import { activateDeferredDebug, applyDebugOption, debugCompiler, debugCompilerV, debugEmit, debugEmitV, debugHmr, debugHmrV, debugStyles, debugStylesV } from "./utils/debug.js";
|
|
3
3
|
import { createCompilerPlugin, createRolldownCompilerPlugin } from "./compiler-plugin.js";
|
|
4
|
-
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX, createTsConfigGetter, getTsConfigPath, isProdMode } from "./utils/plugin-config.js";
|
|
4
|
+
import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX, createTsConfigGetter, getTsConfigPath, isProdMode, isServerEnvironment } from "./utils/plugin-config.js";
|
|
5
5
|
import { TsconfigResolver } from "./utils/tsconfig-resolver.js";
|
|
6
6
|
import { getJsTransformConfigKey, isRolldown } from "./utils/rolldown.js";
|
|
7
7
|
import { AnalogStylesheetRegistry, preprocessStylesheet, rewriteRelativeCssImports } from "./stylesheet-registry.js";
|
|
@@ -26,6 +26,7 @@ import { StyleUrlsResolver, TemplateUrlsResolver } from "./component-resolvers.j
|
|
|
26
26
|
import { augmentHostWithCaching, augmentHostWithModuleResolution, augmentHostWithResources, augmentProgramWithVersioning, mergeTransformers } from "./host.js";
|
|
27
27
|
import { markStylePathSafe } from "./utils/safe-module-paths.js";
|
|
28
28
|
import { fastCompilePlugin } from "./fast-compile-plugin.js";
|
|
29
|
+
import { ngpCompilePlugin } from "./ngp-compile-plugin.js";
|
|
29
30
|
import { union } from "es-toolkit";
|
|
30
31
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
31
32
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
@@ -42,10 +43,12 @@ function evictDeletedFileMetadata(file, { classNamesMap, fileTransformMap }) {
|
|
|
42
43
|
}
|
|
43
44
|
function angular(options) {
|
|
44
45
|
applyDebugOption(options?.debug, options?.workspaceRoot);
|
|
45
|
-
const liveReload = options?.liveReload ?? true;
|
|
46
46
|
let externalizeStylesRequested = false;
|
|
47
47
|
let configureStylesheetRegistry;
|
|
48
48
|
let transformFilter;
|
|
49
|
+
const isTest = process.env.NODE_ENV === "test" || !!process.env["VITEST"];
|
|
50
|
+
const compilation = options?.compilation === "ngp" && !(isTest && options.jit === void 0) ? "ngp" : "ngtsc";
|
|
51
|
+
const liveReload = options?.liveReload ?? compilation !== "ngp";
|
|
49
52
|
/**
|
|
50
53
|
* Normalize plugin options so defaults
|
|
51
54
|
* are used for values not provided.
|
|
@@ -57,9 +60,10 @@ function angular(options) {
|
|
|
57
60
|
jit: options?.jit,
|
|
58
61
|
include: options?.include ?? [],
|
|
59
62
|
liveReload,
|
|
60
|
-
disableTypeChecking: options?.disableTypeChecking ??
|
|
63
|
+
disableTypeChecking: options?.disableTypeChecking ?? compilation !== "ngp",
|
|
61
64
|
fileReplacements: options?.fileReplacements ?? [],
|
|
62
|
-
fastCompile: options?.fastCompile ?? false,
|
|
65
|
+
fastCompile: options?.compilation === void 0 && (options?.fastCompile ?? false),
|
|
66
|
+
compilation,
|
|
63
67
|
fastCompileMode: options?.fastCompileMode ?? "full",
|
|
64
68
|
stylePreprocessor: void 0
|
|
65
69
|
};
|
|
@@ -70,7 +74,6 @@ function angular(options) {
|
|
|
70
74
|
let nextProgram;
|
|
71
75
|
let cachedHost;
|
|
72
76
|
let cachedHostKey;
|
|
73
|
-
const isTest = process.env.NODE_ENV === "test" || !!process.env["VITEST"];
|
|
74
77
|
const tsconfigResolver = new TsconfigResolver({
|
|
75
78
|
workspaceRoot: pluginOptions.workspaceRoot,
|
|
76
79
|
include: pluginOptions.include,
|
|
@@ -163,6 +166,7 @@ function angular(options) {
|
|
|
163
166
|
return emittedResult;
|
|
164
167
|
};
|
|
165
168
|
let initialCompilation = false;
|
|
169
|
+
let activeBuilds = 0;
|
|
166
170
|
const declarationFiles = [];
|
|
167
171
|
const fileTransformMap = /* @__PURE__ */ new Map();
|
|
168
172
|
let styleTransform;
|
|
@@ -271,6 +275,7 @@ function angular(options) {
|
|
|
271
275
|
});
|
|
272
276
|
},
|
|
273
277
|
async buildStart() {
|
|
278
|
+
activeBuilds++;
|
|
274
279
|
if (!jit) styleTransform = (code, filename) => preprocessCSS(code, filename, resolvedConfig);
|
|
275
280
|
if (!deferInitialCompilation) {
|
|
276
281
|
pendingCompilation = performCompilation(this.environment?.config ?? resolvedConfig);
|
|
@@ -280,7 +285,8 @@ function angular(options) {
|
|
|
280
285
|
}
|
|
281
286
|
},
|
|
282
287
|
buildEnd() {
|
|
283
|
-
|
|
288
|
+
activeBuilds = Math.max(0, activeBuilds - 1);
|
|
289
|
+
if (watchMode || activeBuilds > 0) return;
|
|
284
290
|
nextProgram = void 0;
|
|
285
291
|
cachedHost = void 0;
|
|
286
292
|
cachedHostKey = void 0;
|
|
@@ -731,7 +737,8 @@ function angular(options) {
|
|
|
731
737
|
delete sourceMap.sourceRoot;
|
|
732
738
|
return JSON.stringify(sourceMap);
|
|
733
739
|
}
|
|
734
|
-
const
|
|
740
|
+
const createFastCompilePlugin = pluginOptions.compilation === "ngp" ? ngpCompilePlugin : fastCompilePlugin;
|
|
741
|
+
const compilationPlugin = pluginOptions.compilation === "ngp" || pluginOptions.fastCompile ? createFastCompilePlugin({
|
|
735
742
|
tsconfigGetter: pluginOptions.tsconfigGetter,
|
|
736
743
|
workspaceRoot: pluginOptions.workspaceRoot,
|
|
737
744
|
inlineStylesExtension: pluginOptions.inlineStylesExtension,
|
|
@@ -739,18 +746,20 @@ function angular(options) {
|
|
|
739
746
|
liveReload: pluginOptions.liveReload,
|
|
740
747
|
isTest,
|
|
741
748
|
isAstroIntegration,
|
|
742
|
-
fastCompileMode: pluginOptions.fastCompileMode
|
|
749
|
+
fastCompileMode: pluginOptions.fastCompileMode,
|
|
750
|
+
disableTypeChecking: pluginOptions.disableTypeChecking,
|
|
751
|
+
typeChecker: options?.typeChecker
|
|
743
752
|
}) : angularPlugin();
|
|
744
753
|
return [
|
|
745
754
|
cssExtensionStyleResolverPlugin(),
|
|
746
755
|
replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),
|
|
747
756
|
virtualModulesPlugin({ jit }),
|
|
748
|
-
pluginOptions.liveReload && liveReloadPlugin({
|
|
757
|
+
pluginOptions.liveReload && liveReloadPlugin(pluginOptions.compilation === "ngp" ? compilationPlugin.api.componentUpdates : {
|
|
749
758
|
classNames,
|
|
750
759
|
fileEmitter
|
|
751
760
|
}),
|
|
752
761
|
compilationPlugin,
|
|
753
|
-
!pluginOptions.fastCompile && pluginOptions.liveReload && liveReloadPlugin({
|
|
762
|
+
!pluginOptions.fastCompile && pluginOptions.compilation === "ngtsc" && pluginOptions.liveReload && liveReloadPlugin({
|
|
754
763
|
classNames,
|
|
755
764
|
fileEmitter
|
|
756
765
|
}),
|
|
@@ -873,7 +882,10 @@ function angular(options) {
|
|
|
873
882
|
typeScriptProgram = builder.getProgram();
|
|
874
883
|
}
|
|
875
884
|
if (!watchMode) builder = ts.createAbstractBuilder(typeScriptProgram, host, oldBuilder);
|
|
876
|
-
if (angularCompiler)
|
|
885
|
+
if (angularCompiler) {
|
|
886
|
+
await angularCompiler.analyzeAsync();
|
|
887
|
+
if (!pluginOptions.disableTypeChecking) typeScriptProgram.getOptionsDiagnostics();
|
|
888
|
+
}
|
|
877
889
|
const beforeTransformers = jit ? [compilerCli.constructorParametersDownlevelTransform(builder.getProgram()), createJitResourceTransformer(() => builder.getProgram().getTypeChecker())] : [];
|
|
878
890
|
const transformers = mergeTransformers({ before: beforeTransformers }, jit ? {} : angularCompiler.prepareEmit().transformers);
|
|
879
891
|
const fileMetadata = getFileMetadata(builder, angularCompiler, pluginOptions.liveReload, pluginOptions.disableTypeChecking);
|
|
@@ -1008,8 +1020,11 @@ function devServerModePlugin() {
|
|
|
1008
1020
|
return {
|
|
1009
1021
|
name: "@analogjs/vite-plugin-angular-dev-server-mode",
|
|
1010
1022
|
apply: "serve",
|
|
1011
|
-
configEnvironment
|
|
1012
|
-
|
|
1023
|
+
configEnvironment: {
|
|
1024
|
+
order: "post",
|
|
1025
|
+
handler(name, config) {
|
|
1026
|
+
if (isServerEnvironment(name, config)) return { define: { ngServerMode: "true" } };
|
|
1027
|
+
}
|
|
1013
1028
|
}
|
|
1014
1029
|
};
|
|
1015
1030
|
}
|