@nx/angular-rspack-compiler 24.0.0-beta.2 → 24.0.0-beta.4
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/dist/compilation/build-and-analyze.d.ts +2 -1
- package/dist/compilation/build-and-analyze.d.ts.map +1 -1
- package/dist/compilation/setup-compilation.d.ts +2 -1
- package/dist/compilation/setup-compilation.d.ts.map +1 -1
- package/dist/compilation/setup-compilation.js +25 -6
- package/dist/compilation/setup-with-angular-compilation.d.ts.map +1 -1
- package/dist/compilation/setup-with-angular-compilation.js +59 -28
- package/dist/utils/angular-build-file.d.ts +6 -0
- package/dist/utils/angular-build-file.d.ts.map +1 -0
- package/dist/utils/angular-build-file.js +14 -0
- package/dist/utils/angular-build-hash.d.ts +7 -0
- package/dist/utils/angular-build-hash.d.ts.map +1 -0
- package/dist/utils/angular-build-hash.js +17 -0
- package/dist/utils/angular-build-sass.d.ts +13 -0
- package/dist/utils/angular-build-sass.d.ts.map +1 -0
- package/dist/utils/angular-build-sass.js +28 -0
- package/dist/utils/angular-build-version.d.ts +7 -0
- package/dist/utils/angular-build-version.d.ts.map +1 -0
- package/dist/utils/angular-build-version.js +14 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/javascript-transformer-cache.d.ts.map +1 -1
- package/dist/utils/javascript-transformer-cache.js +19 -13
- package/dist/utils/javascript-transformer.d.ts +21 -0
- package/dist/utils/javascript-transformer.d.ts.map +1 -0
- package/dist/utils/javascript-transformer.js +55 -0
- package/dist/utils/utils.d.ts +6 -0
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +14 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JavaScriptTransformer } from '@angular/build/private';
|
|
2
2
|
import { AngularCompilation } from '../models';
|
|
3
|
+
import type { JavaScriptTransformerAdapter } from '../utils/javascript-transformer';
|
|
3
4
|
import { type TransformedSource } from '../utils/source-file-cache';
|
|
4
5
|
/**
|
|
5
6
|
* Emits the affected files of the Angular compilation into the given file
|
|
@@ -12,5 +13,5 @@ import { type TransformedSource } from '../utils/source-file-cache';
|
|
|
12
13
|
* @param javascriptTransformer Unused. Kept for signature compatibility; the
|
|
13
14
|
* transformer now runs in the loaders.
|
|
14
15
|
*/
|
|
15
|
-
export declare function buildAndAnalyze(angularCompilation: AngularCompilation, typescriptFileCache: Map<string, string | TransformedSource>, javascriptTransformer: JavaScriptTransformer): Promise<void>;
|
|
16
|
+
export declare function buildAndAnalyze(angularCompilation: AngularCompilation, typescriptFileCache: Map<string, string | TransformedSource>, javascriptTransformer: JavaScriptTransformer | JavaScriptTransformerAdapter): Promise<void>;
|
|
16
17
|
//# sourceMappingURL=build-and-analyze.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-and-analyze.d.ts","sourceRoot":"","sources":["../../src/compilation/build-and-analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"build-and-analyze.d.ts","sourceRoot":"","sources":["../../src/compilation/build-and-analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAEpF,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,kBAAkB,EAAE,kBAAkB,EACtC,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,EAC5D,qBAAqB,EAAE,qBAAqB,GAAG,4BAA4B,iBAgB5E"}
|
|
@@ -59,7 +59,8 @@ export declare function setupCompilation(config: Pick<RsbuildConfig, 'mode' | 's
|
|
|
59
59
|
* esbuild service - a child process and its sockets - alive until disposed,
|
|
60
60
|
* which prevents a one-shot `rspack build` from exiting once the bundle is
|
|
61
61
|
* written. Angular's own application builder disposes it in a `finally` block;
|
|
62
|
-
* we must do the same since we drive the bundler directly.
|
|
62
|
+
* we must do the same since we drive the bundler directly. The Sass compiler
|
|
63
|
+
* the bundler uses is stopped with it (see `shutdownAngularBuildSass`).
|
|
63
64
|
*/
|
|
64
65
|
export declare function disposeComponentStylesheetBundler(): Promise<void>;
|
|
65
66
|
export declare function styleTransform(componentStylesheetBundler: ComponentStylesheetBundler): (styles: string, containingFile: string, stylesheetFile?: string) => Promise<StylesheetTransformResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-compilation.d.ts","sourceRoot":"","sources":["../../src/compilation/setup-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"setup-compilation.d.ts","sourceRoot":"","sources":["../../src/compilation/setup-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAO5E,OAAO,EACL,0BAA0B,EAK3B,MAAM,wBAAwB,CAAC;AAIhC,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,uEAAuE;IACvE,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,MAAM,CACb,MAAM,EACN;YAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;gBAAE,aAAa,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,CACtD,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,OAAO,CAAC;IACb,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,gBAAgB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACzC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC,eAe5C,CAAC;AAKF;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,CAAC,EAC9C,OAAO,EAAE,uBAAuB;;;;;GAkJjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC,CAUvE;AAED,wBAAgB,cAAc,CAC5B,0BAA0B,EAAE,0BAA0B,YAG5C,MAAM,kBACE,MAAM,mBACL,MAAM,KACtB,OAAO,CAAC,yBAAyB,CAAC,CAmCtC"}
|
|
@@ -9,6 +9,9 @@ const ts = tslib_1.__importStar(require("typescript"));
|
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const typescript_compiler_options_1 = require("../utils/typescript-compiler-options");
|
|
11
11
|
const assert_supported_versions_1 = require("../utils/assert-supported-versions");
|
|
12
|
+
const angular_build_hash_1 = require("../utils/angular-build-hash");
|
|
13
|
+
const angular_build_sass_1 = require("../utils/angular-build-sass");
|
|
14
|
+
const angular_build_version_1 = require("../utils/angular-build-version");
|
|
12
15
|
const private_1 = require("@angular/build/private");
|
|
13
16
|
const targets_from_browsers_1 = require("../utils/targets-from-browsers");
|
|
14
17
|
const node_module_1 = require("node:module");
|
|
@@ -25,6 +28,8 @@ exports.DEFAULT_NG_COMPILER_OPTIONS = {
|
|
|
25
28
|
sourceRoot: undefined,
|
|
26
29
|
supportTestBed: false,
|
|
27
30
|
supportJitMode: false,
|
|
31
|
+
// TypeScript would also strip annotations such as `/* @__PURE__ */`.
|
|
32
|
+
removeComments: false,
|
|
28
33
|
};
|
|
29
34
|
let COMPONENT_STYLESHEET_BUNDLER = undefined;
|
|
30
35
|
/**
|
|
@@ -40,12 +45,16 @@ let COMPONENT_STYLESHEET_BUNDLER = undefined;
|
|
|
40
45
|
*/
|
|
41
46
|
async function setupCompilation(config, options) {
|
|
42
47
|
(0, assert_supported_versions_1.assertSupportedAngularRspackCompilerVersions)();
|
|
48
|
+
await (0, angular_build_hash_1.initializeAngularBuildHash)();
|
|
49
|
+
// From @angular/build 22.2 the compilation reads the tsconfig itself and
|
|
50
|
+
// takes no `isolatedModules` override, so the option can't apply.
|
|
51
|
+
const ignoreTsProjectReferences = !!options.useTsProjectReferences && (0, angular_build_version_1.isAngularBuildVersionAtLeast)('22.2.0');
|
|
43
52
|
const { readConfiguration } = await (0, utils_1.loadCompilerCli)();
|
|
44
53
|
const { options: tsCompilerOptions, rootNames } = readConfiguration(config.source?.tsconfigPath ?? options.tsConfig, {
|
|
45
54
|
...exports.DEFAULT_NG_COMPILER_OPTIONS,
|
|
46
|
-
// Sourcemaps must be inline to survive the loader chain
|
|
47
|
-
// them forgoes
|
|
48
|
-
// script sourcemaps are requested.
|
|
55
|
+
// Sourcemaps must be inline to survive the loader chain. Before
|
|
56
|
+
// @angular/build 22.1, emitting them forgoes the raw-TS emit path, so
|
|
57
|
+
// only emit them when script sourcemaps are requested.
|
|
49
58
|
inlineSources: !!options.sourceMap,
|
|
50
59
|
inlineSourceMap: !!options.sourceMap,
|
|
51
60
|
sourceMap: undefined,
|
|
@@ -55,7 +64,7 @@ async function setupCompilation(config, options) {
|
|
|
55
64
|
// The bundler resolves symlinks based on this option alone; the
|
|
56
65
|
// program must resolve the same way, so the tsconfig value is ignored.
|
|
57
66
|
preserveSymlinks: options.preserveSymlinks,
|
|
58
|
-
...(options.useTsProjectReferences
|
|
67
|
+
...(options.useTsProjectReferences && !ignoreTsProjectReferences
|
|
59
68
|
? {
|
|
60
69
|
sourceMap: false,
|
|
61
70
|
inlineSourceMap: false,
|
|
@@ -66,6 +75,10 @@ async function setupCompilation(config, options) {
|
|
|
66
75
|
});
|
|
67
76
|
const compilerOptions = tsCompilerOptions;
|
|
68
77
|
const setupWarnings = [];
|
|
78
|
+
if (ignoreTsProjectReferences) {
|
|
79
|
+
setupWarnings.push("The 'useTsProjectReferences' option has no effect with Angular 22.2 and later. " +
|
|
80
|
+
"If the TypeScript configuration sets 'noEmit', set 'isolatedModules' to 'true' or remove 'noEmit'.");
|
|
81
|
+
}
|
|
69
82
|
const hasExplicitUseDefineForClassFields = compilerOptions.useDefineForClassFields !== undefined;
|
|
70
83
|
if ((0, typescript_compiler_options_1.applyEs2022TargetDefaults)(compilerOptions)) {
|
|
71
84
|
setupWarnings.push(hasExplicitUseDefineForClassFields
|
|
@@ -149,13 +162,19 @@ async function setupCompilation(config, options) {
|
|
|
149
162
|
* esbuild service - a child process and its sockets - alive until disposed,
|
|
150
163
|
* which prevents a one-shot `rspack build` from exiting once the bundle is
|
|
151
164
|
* written. Angular's own application builder disposes it in a `finally` block;
|
|
152
|
-
* we must do the same since we drive the bundler directly.
|
|
165
|
+
* we must do the same since we drive the bundler directly. The Sass compiler
|
|
166
|
+
* the bundler uses is stopped with it (see `shutdownAngularBuildSass`).
|
|
153
167
|
*/
|
|
154
168
|
async function disposeComponentStylesheetBundler() {
|
|
155
169
|
if (COMPONENT_STYLESHEET_BUNDLER) {
|
|
156
170
|
const bundler = COMPONENT_STYLESHEET_BUNDLER;
|
|
157
171
|
COMPONENT_STYLESHEET_BUNDLER = undefined;
|
|
158
|
-
|
|
172
|
+
try {
|
|
173
|
+
await bundler.dispose();
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
(0, angular_build_sass_1.shutdownAngularBuildSass)();
|
|
177
|
+
}
|
|
159
178
|
}
|
|
160
179
|
}
|
|
161
180
|
function styleTransform(componentStylesheetBundler) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-with-angular-compilation.d.ts","sourceRoot":"","sources":["../../src/compilation/setup-with-angular-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAEL,kBAAkB,EAClB,eAAe,EAEhB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"setup-with-angular-compilation.d.ts","sourceRoot":"","sources":["../../src/compilation/setup-with-angular-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAEL,kBAAkB,EAClB,eAAe,EAEhB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAGL,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD;AAwBD,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,EACrC,OAAO,EAAE,uBAAuB,EAChC,eAAe,CAAC,EAAE,eAAe,EACjC,kBAAkB,CAAC,EAAE,kBAAkB,EACvC,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;;;cA4CoB,MAAM;cAAQ,MAAM;;;;;;GAmJpE"}
|
|
@@ -3,19 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setupCompilationWithAngularCompilation = setupCompilationWithAngularCompilation;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
5
|
const models_1 = require("../models");
|
|
6
|
+
const angular_build_sass_1 = require("../utils/angular-build-sass");
|
|
7
|
+
const angular_build_version_1 = require("../utils/angular-build-version");
|
|
6
8
|
const setup_compilation_1 = require("./setup-compilation");
|
|
9
|
+
// The declarations are those of the installed @angular/build, so only its
|
|
10
|
+
// version tells whether `initialize` has the pre-22.2 signature.
|
|
11
|
+
function hasLegacyInitialize(compilation) {
|
|
12
|
+
return !(0, angular_build_version_1.isAngularBuildVersionAtLeast)('22.2.0');
|
|
13
|
+
}
|
|
7
14
|
async function setupCompilationWithAngularCompilation(config, options, sourceFileCache, angularCompilation, modifiedFiles) {
|
|
8
15
|
const { rootNames, compilerOptions, componentStylesheetBundler, setupWarnings, } = await (0, setup_compilation_1.setupCompilation)(config, options);
|
|
9
|
-
// Persist the TypeScript incremental state to the cache directory when one
|
|
10
|
-
// is available so later cold builds resume from it.
|
|
11
|
-
if (sourceFileCache?.persistentCachePath &&
|
|
12
|
-
compilerOptions.incremental !== false) {
|
|
13
|
-
compilerOptions.incremental = true;
|
|
14
|
-
compilerOptions.tsBuildInfoFile = (0, node_path_1.join)(sourceFileCache.persistentCachePath, '.tsbuildinfo');
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
compilerOptions.incremental = false;
|
|
18
|
-
}
|
|
19
16
|
// Mirrors @angular/build's NG_BUILD_PARALLEL_TS switch: anything but
|
|
20
17
|
// 0/false runs the Angular compilation in a worker thread, so type
|
|
21
18
|
// checking overlaps with the bundling work.
|
|
@@ -35,6 +32,7 @@ async function setupCompilationWithAngularCompilation(config, options, sourceFil
|
|
|
35
32
|
// stylesheets get rebuilt; there's nothing to invalidate on the first build.
|
|
36
33
|
if (modifiedFiles) {
|
|
37
34
|
componentStylesheetBundler.invalidate(modifiedFiles);
|
|
35
|
+
(0, angular_build_sass_1.resetAngularBuildSassCaches)(modifiedFiles);
|
|
38
36
|
}
|
|
39
37
|
modifiedFiles ?? (modifiedFiles = new Set(rootNames));
|
|
40
38
|
const fileReplacements = options.fileReplacements.reduce((r, f) => {
|
|
@@ -68,20 +66,50 @@ async function setupCompilationWithAngularCompilation(config, options, sourceFil
|
|
|
68
66
|
// Return just the contents string as expected by Angular compilation
|
|
69
67
|
return result.contents;
|
|
70
68
|
};
|
|
69
|
+
const tsconfig = config.source?.tsconfigPath ?? options.tsConfig;
|
|
70
|
+
const hostOptions = {
|
|
71
|
+
fileReplacements,
|
|
72
|
+
modifiedFiles,
|
|
73
|
+
transformStylesheet: wrappedTransformStylesheet,
|
|
74
|
+
processWebWorker(workerFile) {
|
|
75
|
+
return workerFile;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
71
78
|
// Initialization errors are rethrown for callers to surface as build
|
|
72
79
|
// errors instead of continuing with a compilation that was never
|
|
73
80
|
// initialized.
|
|
74
81
|
let initializationResult;
|
|
75
82
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
83
|
+
if (hasLegacyInitialize(angularCompilation)) {
|
|
84
|
+
// Persist the TypeScript incremental state to the cache directory when
|
|
85
|
+
// one is available so later cold builds resume from it.
|
|
86
|
+
if (sourceFileCache?.persistentCachePath &&
|
|
87
|
+
compilerOptions.incremental !== false) {
|
|
88
|
+
compilerOptions.incremental = true;
|
|
89
|
+
compilerOptions.tsBuildInfoFile = (0, node_path_1.join)(sourceFileCache.persistentCachePath, '.tsbuildinfo');
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
compilerOptions.incremental = false;
|
|
93
|
+
}
|
|
94
|
+
// @angular/build 22.1 gates the emit on this flag, and its application
|
|
95
|
+
// builder sets it to `!isolatedModules`. Earlier versions ignore it and
|
|
96
|
+
// use the fallback's expression.
|
|
97
|
+
if ((0, angular_build_version_1.isAngularBuildVersionAtLeast)('22.1.0')) {
|
|
98
|
+
compilerOptions['_useTypeScriptTranspilation'] =
|
|
99
|
+
!compilerOptions.isolatedModules;
|
|
100
|
+
}
|
|
101
|
+
initializationResult = await angularCompilation.initialize(tsconfig, { ...hostOptions, sourceFileCache }, () => compilerOptions);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// The compilation reads and adjusts the tsconfig itself, like
|
|
105
|
+
// `setupCompilation` does; only these overrides reach it.
|
|
106
|
+
initializationResult = await angularCompilation.initialize(tsconfig, hostOptions, {
|
|
107
|
+
sourcemap: !!options.sourceMap,
|
|
108
|
+
preserveSymlinks: options.preserveSymlinks,
|
|
109
|
+
cachePath: sourceFileCache?.persistentCachePath,
|
|
110
|
+
customConditions: options.customConditions,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
85
113
|
}
|
|
86
114
|
catch (error) {
|
|
87
115
|
// A worker-based compilation spawns its worker thread on construction;
|
|
@@ -115,15 +143,12 @@ async function setupCompilationWithAngularCompilation(config, options, sourceFil
|
|
|
115
143
|
}
|
|
116
144
|
}
|
|
117
145
|
// Only the AOT emit branches between TypeScript transpilation and raw
|
|
118
|
-
// Angular-transformed TypeScript
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
const useTypeScriptTranspilation = !initializedCompilerOptions?.isolatedModules ||
|
|
125
|
-
!!initializedCompilerOptions?.sourceMap ||
|
|
126
|
-
!!initializedCompilerOptions?.inlineSourceMap;
|
|
146
|
+
// Angular-transformed TypeScript (JIT always transpiles). The loaders
|
|
147
|
+
// classify the emitted cache entries with this flag, so it must never
|
|
148
|
+
// diverge from the emit's gate. Worker-based compilations before
|
|
149
|
+
// @angular/build 22.1 report only `allowJs` and the options the fallback
|
|
150
|
+
// reads.
|
|
151
|
+
const useTypeScriptTranspilation = initializedCompilerOptions?.['_useTypeScriptTranspilation'] ?? isTypeScriptTranspiled(initializedCompilerOptions);
|
|
127
152
|
return {
|
|
128
153
|
angularCompilation,
|
|
129
154
|
collectedStylesheetAssets,
|
|
@@ -133,6 +158,12 @@ async function setupCompilationWithAngularCompilation(config, options, sourceFil
|
|
|
133
158
|
setupWarnings,
|
|
134
159
|
};
|
|
135
160
|
}
|
|
161
|
+
// The AOT emit gate of @angular/build < 22.1.
|
|
162
|
+
function isTypeScriptTranspiled(compilerOptions) {
|
|
163
|
+
return (!compilerOptions?.isolatedModules ||
|
|
164
|
+
!!compilerOptions.sourceMap ||
|
|
165
|
+
!!compilerOptions.inlineSourceMap);
|
|
166
|
+
}
|
|
136
167
|
// Callers report initialization failures as build errors; hand them the
|
|
137
168
|
// setup warnings so they are not lost with the failed build.
|
|
138
169
|
function attachSetupWarnings(error, setupWarnings) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads a file of the installed `@angular/build` that its exports map does not
|
|
3
|
+
* expose. Loading it by path shares the module instance its own tools use.
|
|
4
|
+
*/
|
|
5
|
+
export declare function requireAngularBuildFile(relativePath: string): any;
|
|
6
|
+
//# sourceMappingURL=angular-build-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-build-file.d.ts","sourceRoot":"","sources":["../../src/utils/angular-build-file.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,OAK3D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireAngularBuildFile = requireAngularBuildFile;
|
|
4
|
+
const node_module_1 = require("node:module");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const requireFn = (0, node_module_1.createRequire)(__filename);
|
|
7
|
+
/**
|
|
8
|
+
* Loads a file of the installed `@angular/build` that its exports map does not
|
|
9
|
+
* expose. Loading it by path shares the module instance its own tools use.
|
|
10
|
+
*/
|
|
11
|
+
function requireAngularBuildFile(relativePath) {
|
|
12
|
+
const angularBuildDir = (0, node_path_1.dirname)(requireFn.resolve('@angular/build/package.json'));
|
|
13
|
+
return requireFn((0, node_path_1.join)(angularBuildDir, relativePath));
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initializes the hashing that `@angular/build` >= 22.2 tools assert on. Its
|
|
3
|
+
* builders run this at startup; it is not exported, so it is loaded by path,
|
|
4
|
+
* which shares the module instance those tools use.
|
|
5
|
+
*/
|
|
6
|
+
export declare function initializeAngularBuildHash(): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=angular-build-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-build-hash.d.ts","sourceRoot":"","sources":["../../src/utils/angular-build-hash.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAQhE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initializeAngularBuildHash = initializeAngularBuildHash;
|
|
4
|
+
const angular_build_file_1 = require("./angular-build-file");
|
|
5
|
+
const angular_build_version_1 = require("./angular-build-version");
|
|
6
|
+
/**
|
|
7
|
+
* Initializes the hashing that `@angular/build` >= 22.2 tools assert on. Its
|
|
8
|
+
* builders run this at startup; it is not exported, so it is loaded by path,
|
|
9
|
+
* which shares the module instance those tools use.
|
|
10
|
+
*/
|
|
11
|
+
async function initializeAngularBuildHash() {
|
|
12
|
+
if (!(0, angular_build_version_1.isAngularBuildVersionAtLeast)('22.2.0')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const { initializeHash } = (0, angular_build_file_1.requireAngularBuildFile)('src/utils/hash.js');
|
|
16
|
+
await initializeHash();
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stops the Sass compiler `@angular/build` keeps for component stylesheets.
|
|
3
|
+
* From 22.2 it runs Dart Sass in a child process, which keeps a one-shot build
|
|
4
|
+
* from exiting until stopped.
|
|
5
|
+
*/
|
|
6
|
+
export declare function shutdownAngularBuildSass(): void;
|
|
7
|
+
/**
|
|
8
|
+
* `@angular/build` >= 22.2 keeps the directory listings Sass imports resolve
|
|
9
|
+
* from across compilations, so a stylesheet change must drop them for added or
|
|
10
|
+
* removed files to resolve.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resetAngularBuildSassCaches(changedFiles: Set<string>): void;
|
|
13
|
+
//# sourceMappingURL=angular-build-sass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-build-sass.d.ts","sourceRoot":"","sources":["../../src/utils/angular-build-sass.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAQ3E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shutdownAngularBuildSass = shutdownAngularBuildSass;
|
|
4
|
+
exports.resetAngularBuildSassCaches = resetAngularBuildSassCaches;
|
|
5
|
+
const angular_build_file_1 = require("./angular-build-file");
|
|
6
|
+
function loadSassLanguage() {
|
|
7
|
+
return (0, angular_build_file_1.requireAngularBuildFile)('src/tools/esbuild/stylesheets/sass-language.js');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Stops the Sass compiler `@angular/build` keeps for component stylesheets.
|
|
11
|
+
* From 22.2 it runs Dart Sass in a child process, which keeps a one-shot build
|
|
12
|
+
* from exiting until stopped.
|
|
13
|
+
*/
|
|
14
|
+
function shutdownAngularBuildSass() {
|
|
15
|
+
loadSassLanguage().shutdownSassWorkerPool();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `@angular/build` >= 22.2 keeps the directory listings Sass imports resolve
|
|
19
|
+
* from across compilations, so a stylesheet change must drop them for added or
|
|
20
|
+
* removed files to resolve.
|
|
21
|
+
*/
|
|
22
|
+
function resetAngularBuildSassCaches(changedFiles) {
|
|
23
|
+
const { resetSassWorkerPoolCaches } = loadSassLanguage();
|
|
24
|
+
if (resetSassWorkerPoolCaches &&
|
|
25
|
+
[...changedFiles].some((file) => /\.(scss|sass|css)$/i.test(file))) {
|
|
26
|
+
resetSassWorkerPoolCaches();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the `@angular/build` this package loads `@angular/build/private`
|
|
3
|
+
* from is at least `version`. Prereleases count as their release, since
|
|
4
|
+
* private API changes land in them first.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isAngularBuildVersionAtLeast(version: string): boolean;
|
|
7
|
+
//# sourceMappingURL=angular-build-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-build-version.d.ts","sourceRoot":"","sources":["../../src/utils/angular-build-version.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAKrE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAngularBuildVersionAtLeast = isAngularBuildVersionAtLeast;
|
|
4
|
+
const node_module_1 = require("node:module");
|
|
5
|
+
const semver_1 = require("semver");
|
|
6
|
+
/**
|
|
7
|
+
* Whether the `@angular/build` this package loads `@angular/build/private`
|
|
8
|
+
* from is at least `version`. Prereleases count as their release, since
|
|
9
|
+
* private API changes land in them first.
|
|
10
|
+
*/
|
|
11
|
+
function isAngularBuildVersionAtLeast(version) {
|
|
12
|
+
const { version: installedVersion } = (0, node_module_1.createRequire)(__filename)('@angular/build/package.json');
|
|
13
|
+
return (0, semver_1.gte)((0, semver_1.coerce)(installedVersion), version);
|
|
14
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './regex-filters';
|
|
2
|
+
export * from './angular-build-version';
|
|
2
3
|
export * from './component-resolvers';
|
|
4
|
+
export * from './javascript-transformer';
|
|
3
5
|
export * from './javascript-transformer-cache';
|
|
4
6
|
export * from './load-compiler-cli';
|
|
5
7
|
export * from './typescript-compiler-options';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.maxWorkers = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./regex-filters"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./angular-build-version"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./component-resolvers"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./javascript-transformer"), exports);
|
|
7
9
|
tslib_1.__exportStar(require("./javascript-transformer-cache"), exports);
|
|
8
10
|
tslib_1.__exportStar(require("./load-compiler-cli"), exports);
|
|
9
11
|
tslib_1.__exportStar(require("./typescript-compiler-options"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript-transformer-cache.d.ts","sourceRoot":"","sources":["../../src/utils/javascript-transformer-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"javascript-transformer-cache.d.ts","sourceRoot":"","sources":["../../src/utils/javascript-transformer-cache.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGpD,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAC9C,mBAAmB,EAAE,MAAM,GAC1B,0BAA0B,GAAG,SAAS,CAmBxC"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createJavascriptTransformerCache = createJavascriptTransformerCache;
|
|
4
|
-
const node_module_1 = require("node:module");
|
|
5
4
|
const node_path_1 = require("node:path");
|
|
5
|
+
const angular_build_file_1 = require("./angular-build-file");
|
|
6
|
+
// `@angular/build` 22.2 moved the store out of `src/tools/esbuild`.
|
|
7
|
+
const LMDB_CACHE_STORE_PATHS = [
|
|
8
|
+
'src/utils/cache/lmdb-cache-store.js',
|
|
9
|
+
'src/tools/esbuild/lmdb-cache-store.js',
|
|
10
|
+
];
|
|
6
11
|
/**
|
|
7
12
|
* Creates the persistent store the esbuild application builder uses for
|
|
8
13
|
* `JavaScriptTransformer` results, so Angular package linking is only paid
|
|
@@ -15,17 +20,18 @@ const node_path_1 = require("node:path");
|
|
|
15
20
|
* case the transformer runs uncached.
|
|
16
21
|
*/
|
|
17
22
|
function createJavascriptTransformerCache(persistentCachePath) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
for (const storePath of LMDB_CACHE_STORE_PATHS) {
|
|
24
|
+
try {
|
|
25
|
+
const { LmdbCacheStore, } = (0, angular_build_file_1.requireAngularBuildFile)(storePath);
|
|
26
|
+
const store = new LmdbCacheStore((0, node_path_1.join)(persistentCachePath, 'angular-compiler.db'));
|
|
27
|
+
return {
|
|
28
|
+
cache: store.createCache('jstransformer'),
|
|
29
|
+
close: () => store.close(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Not loadable from this location; try the next one.
|
|
34
|
+
}
|
|
30
35
|
}
|
|
36
|
+
return undefined;
|
|
31
37
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Cache, JavaScriptTransformer } from '@angular/build/private';
|
|
2
|
+
type JavaScriptTransformerOptions = Omit<ConstructorParameters<typeof JavaScriptTransformer>[0], 'maxConcurrency'>;
|
|
3
|
+
/**
|
|
4
|
+
* The `JavaScriptTransformer` API as it was before `@angular/build` 22.2,
|
|
5
|
+
* which moved the per-transform flags into an options object, plus
|
|
6
|
+
* `transformFileUncached`.
|
|
7
|
+
*/
|
|
8
|
+
export interface JavaScriptTransformerAdapter {
|
|
9
|
+
transformData(filename: string, data: string, skipLinker: boolean, sideEffects?: boolean): Promise<Uint8Array>;
|
|
10
|
+
transformFile(filename: string, skipLinker?: boolean, sideEffects?: boolean): Promise<Uint8Array>;
|
|
11
|
+
/** Like `transformFile`, but never reads or writes the cache. */
|
|
12
|
+
transformFileUncached(filename: string, skipLinker?: boolean, sideEffects?: boolean): Promise<Uint8Array>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates the `@angular/build` JavaScript transformer for the installed
|
|
17
|
+
* version, sized with that version's worker count, exposing the pre-22.2 API.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createJavaScriptTransformer(options: JavaScriptTransformerOptions, cache?: Cache<Uint8Array>): JavaScriptTransformerAdapter;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=javascript-transformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-transformer.d.ts","sourceRoot":"","sources":["../../src/utils/javascript-transformer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAItE,KAAK,4BAA4B,GAAG,IAAI,CACtC,qBAAqB,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,EACtD,gBAAgB,CACjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,OAAO,EACnB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,OAAO,EACpB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,iEAAiE;IACjE,qBAAqB,CACnB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,OAAO,EACpB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAiBD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,EACrC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,GACxB,4BAA4B,CAkD9B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createJavaScriptTransformer = createJavaScriptTransformer;
|
|
4
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const private_1 = require("@angular/build/private");
|
|
7
|
+
const angular_build_version_1 = require("./angular-build-version");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
// The declarations are those of the installed @angular/build, so only its
|
|
10
|
+
// version tells whether the class has the pre-22.2 constructor.
|
|
11
|
+
function hasLegacyConstructor(transformer) {
|
|
12
|
+
return !(0, angular_build_version_1.isAngularBuildVersionAtLeast)('22.2.0');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates the `@angular/build` JavaScript transformer for the installed
|
|
16
|
+
* version, sized with that version's worker count, exposing the pre-22.2 API.
|
|
17
|
+
*/
|
|
18
|
+
function createJavaScriptTransformer(options, cache) {
|
|
19
|
+
if (hasLegacyConstructor(private_1.JavaScriptTransformer)) {
|
|
20
|
+
const transformer = new private_1.JavaScriptTransformer(options, (0, utils_1.maxWorkers)(), cache);
|
|
21
|
+
return {
|
|
22
|
+
transformData: transformer.transformData.bind(transformer),
|
|
23
|
+
transformFile: transformer.transformFile.bind(transformer),
|
|
24
|
+
// `transformData` never uses the cache before 22.2.
|
|
25
|
+
transformFileUncached: async (filename, skipLinker, sideEffects) => transformer.transformData(filename, await (0, promises_1.readFile)(filename, 'utf8'), skipLinker, sideEffects),
|
|
26
|
+
close: transformer.close.bind(transformer),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const skipCache = new node_async_hooks_1.AsyncLocalStorage();
|
|
30
|
+
const transformer = new private_1.JavaScriptTransformer({ ...options, maxConcurrency: (0, utils_1.maxTransformWorkers)() }, cache && createSkippableCache(cache, skipCache));
|
|
31
|
+
const toTransformOptions = (skipLinker, sideEffects) => ({
|
|
32
|
+
skipLinker,
|
|
33
|
+
sideEffects: sideEffects === undefined ? undefined : async () => sideEffects,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
transformData: (filename, data, skipLinker, sideEffects) => transformer.transformData(filename, data, toTransformOptions(skipLinker, sideEffects)),
|
|
37
|
+
transformFile: (filename, skipLinker, sideEffects) => transformer.transformFile(filename, toTransformOptions(skipLinker, sideEffects)),
|
|
38
|
+
transformFileUncached: (filename, skipLinker, sideEffects) => skipCache.run(true, () => transformer.transformFile(filename, toTransformOptions(skipLinker, sideEffects))),
|
|
39
|
+
close: () => transformer.close(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// `@angular/build` 20 does not export `Cache`, so it may only be referenced
|
|
43
|
+
// at runtime on the 22.2 path.
|
|
44
|
+
function createSkippableCache(cache, skipCache) {
|
|
45
|
+
return new private_1.Cache({
|
|
46
|
+
get: (key) => (skipCache.getStore() ? undefined : cache.get(key)),
|
|
47
|
+
has: async (key) => !skipCache.getStore() && (await cache.get(key)) !== undefined,
|
|
48
|
+
async set(key, value) {
|
|
49
|
+
if (!skipCache.getStore()) {
|
|
50
|
+
await cache.put(key, value);
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -2,4 +2,10 @@ export declare const isUsingWindows: () => boolean;
|
|
|
2
2
|
export declare function isPresent(variable: string | undefined): variable is string;
|
|
3
3
|
export declare function parseMaxWorkers(value: string | undefined): number | null;
|
|
4
4
|
export declare const maxWorkers: () => number;
|
|
5
|
+
/**
|
|
6
|
+
* The JavaScript transformer's worker count on `@angular/build` >= 22.2, as
|
|
7
|
+
* its `maxTransformWorkers` computes it. That transformer keeps a fixed pool of
|
|
8
|
+
* this size and rejects anything but an integer >= 1.
|
|
9
|
+
*/
|
|
10
|
+
export declare const maxTransformWorkers: () => number;
|
|
5
11
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,eAA+B,CAAC;AAE3D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,IAAI,MAAM,CAE1E;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIxE;AAED,eAAO,MAAM,UAAU,cAKtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,eAA+B,CAAC;AAE3D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,IAAI,MAAM,CAE1E;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIxE;AAED,eAAO,MAAM,UAAU,cAKtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,cAM/B,CAAC"}
|
package/dist/utils/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maxWorkers = exports.isUsingWindows = void 0;
|
|
3
|
+
exports.maxTransformWorkers = exports.maxWorkers = exports.isUsingWindows = void 0;
|
|
4
4
|
exports.isPresent = isPresent;
|
|
5
5
|
exports.parseMaxWorkers = parseMaxWorkers;
|
|
6
6
|
const node_os_1 = require("node:os");
|
|
@@ -23,3 +23,16 @@ const maxWorkers = () => {
|
|
|
23
23
|
: Math.min(4, Math.max((0, node_os_1.availableParallelism)() - 1, 1));
|
|
24
24
|
};
|
|
25
25
|
exports.maxWorkers = maxWorkers;
|
|
26
|
+
/**
|
|
27
|
+
* The JavaScript transformer's worker count on `@angular/build` >= 22.2, as
|
|
28
|
+
* its `maxTransformWorkers` computes it. That transformer keeps a fixed pool of
|
|
29
|
+
* this size and rejects anything but an integer >= 1.
|
|
30
|
+
*/
|
|
31
|
+
const maxTransformWorkers = () => {
|
|
32
|
+
const value = process.env[constants_1.ENV_NG_BUILD_MAX_WORKERS];
|
|
33
|
+
const parsed = isPresent(value) ? Number(value) : NaN;
|
|
34
|
+
return Number.isInteger(parsed) && parsed >= 1
|
|
35
|
+
? parsed
|
|
36
|
+
: Math.max(1, Math.min(6, Math.floor((0, node_os_1.availableParallelism)() / 4)));
|
|
37
|
+
};
|
|
38
|
+
exports.maxTransformWorkers = maxTransformWorkers;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular-rspack-compiler",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "24.0.0-beta.
|
|
4
|
+
"version": "24.0.0-beta.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@nx/devkit": "24.0.0-beta.
|
|
43
|
+
"@nx/devkit": "24.0.0-beta.4",
|
|
44
44
|
"sass-embedded": "^1.97.2",
|
|
45
45
|
"semver": "^7.6.3",
|
|
46
46
|
"tslib": "^2.3.0",
|