@nx/angular-rspack 23.0.0 → 23.0.2
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 +1 -2
- package/dist/lib/models/augmented-compilation.d.ts +1 -0
- package/dist/lib/models/augmented-compilation.d.ts.map +1 -1
- package/dist/lib/plugins/angular-rspack-plugin.d.ts +1 -0
- package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/angular-rspack-plugin.js +109 -39
- package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts.map +1 -1
- package/dist/lib/plugins/loaders/angular-partial-transform.loader.js +12 -4
- package/dist/lib/plugins/loaders/angular-transform.loader.d.ts.map +1 -1
- package/dist/lib/plugins/loaders/angular-transform.loader.js +8 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -7,13 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
<div style="text-align: center;">
|
|
9
9
|
|
|
10
|
-
[](https://circleci.com/gh/nrwl/nx)
|
|
11
10
|
[]()
|
|
12
11
|
[](https://www.npmjs.com/package/nx)
|
|
13
12
|
[]()
|
|
14
13
|
[](http://commitizen.github.io/cz-cli/)
|
|
15
|
-
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
16
14
|
[](https://go.nx.dev/community)
|
|
15
|
+
[](https://nx.dev/docs/features/ci-features/sandboxing)
|
|
17
16
|
|
|
18
17
|
</div>
|
|
19
18
|
|
|
@@ -5,6 +5,7 @@ export declare const NG_RSPACK_SYMBOL_NAME = "NG_RSPACK_BUILD";
|
|
|
5
5
|
export type NG_RSPACK_COMPILATION_STATE = {
|
|
6
6
|
javascriptTransformer: JavaScriptTransformer;
|
|
7
7
|
typescriptFileCache: SourceFileCache['typeScriptFileCache'];
|
|
8
|
+
angularCompilationFailed: boolean;
|
|
8
9
|
i18n?: I18nOptions;
|
|
9
10
|
};
|
|
10
11
|
export type NgRspackCompilation = Compilation & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"augmented-compilation.d.ts","sourceRoot":"","sources":["../../../src/lib/models/augmented-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,MAAM,MAAM,2BAA2B,GAAG;IACxC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,mBAAmB,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"augmented-compilation.d.ts","sourceRoot":"","sources":["../../../src/lib/models/augmented-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,MAAM,MAAM,2BAA2B,GAAG;IACxC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,mBAAmB,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;IAG5D,wBAAwB,EAAE,OAAO,CAAC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,CAAC,qBAAqB,CAAC,EAAE,MAAM,2BAA2B,CAAC;CAC5D,CAAC"}
|
|
@@ -5,5 +5,6 @@ export declare class AngularRspackPlugin implements RspackPluginInstance {
|
|
|
5
5
|
constructor(options: NormalizedAngularRspackPluginOptions, i18nOptions?: I18nOptions);
|
|
6
6
|
apply(compiler: Compiler): void;
|
|
7
7
|
private setupCompilation;
|
|
8
|
+
private buildAndAnalyze;
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=angular-rspack-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AAUnB,qBAAa,mBAAoB,YAAW,oBAAoB;;
|
|
1
|
+
{"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AAUnB,qBAAa,mBAAoB,YAAW,oBAAoB;;gBAY5D,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW;IAuB3B,KAAK,CAAC,QAAQ,EAAE,QAAQ;YAoZV,gBAAgB;YA2ChB,eAAe;CAgB9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _AngularRspackPlugin__options, _AngularRspackPlugin_i18n, _AngularRspackPlugin_sourceFileCache, _AngularRspackPlugin_javascriptTransformer, _AngularRspackPlugin_angularCompilation, _AngularRspackPlugin_collectedStylesheetAssets;
|
|
2
|
+
var _AngularRspackPlugin__options, _AngularRspackPlugin_i18n, _AngularRspackPlugin_sourceFileCache, _AngularRspackPlugin_javascriptTransformer, _AngularRspackPlugin_angularCompilation, _AngularRspackPlugin_collectedStylesheetAssets, _AngularRspackPlugin_initializationError, _AngularRspackPlugin_emitError;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.AngularRspackPlugin = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
@@ -24,6 +24,8 @@ class AngularRspackPlugin {
|
|
|
24
24
|
// This will be defined in the apply method correctly
|
|
25
25
|
_AngularRspackPlugin_angularCompilation.set(this, void 0);
|
|
26
26
|
_AngularRspackPlugin_collectedStylesheetAssets.set(this, []);
|
|
27
|
+
_AngularRspackPlugin_initializationError.set(this, void 0);
|
|
28
|
+
_AngularRspackPlugin_emitError.set(this, void 0);
|
|
27
29
|
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin__options, options, "f");
|
|
28
30
|
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_i18n, i18nOptions, "f");
|
|
29
31
|
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_sourceFileCache, new angular_rspack_compiler_1.SourceFileCache(), "f");
|
|
@@ -46,7 +48,7 @@ class AngularRspackPlugin {
|
|
|
46
48
|
compiler.hooks.beforeRun.tapAsync(PLUGIN_NAME, async (compiler, callback) => {
|
|
47
49
|
await this.setupCompilation(root, compiler.options.resolve.tsConfig);
|
|
48
50
|
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, async (params, callback) => {
|
|
49
|
-
await
|
|
51
|
+
await this.buildAndAnalyze();
|
|
50
52
|
callback();
|
|
51
53
|
});
|
|
52
54
|
callback();
|
|
@@ -73,7 +75,7 @@ class AngularRspackPlugin {
|
|
|
73
75
|
await this.setupCompilation(root, compiler.options.resolve.tsConfig, watchingModifiedFiles.size > 0
|
|
74
76
|
? watchingModifiedFiles
|
|
75
77
|
: undefined);
|
|
76
|
-
await
|
|
78
|
+
await this.buildAndAnalyze();
|
|
77
79
|
// Update shared state for compilation hook
|
|
78
80
|
currentWatchingModifiedFiles = watchingModifiedFiles;
|
|
79
81
|
callback();
|
|
@@ -82,6 +84,13 @@ class AngularRspackPlugin {
|
|
|
82
84
|
callback();
|
|
83
85
|
});
|
|
84
86
|
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
87
|
+
// Surface a failed Angular compilation as a build error (like
|
|
88
|
+
// @angular/build) instead of an exception that stalls the hooks chain.
|
|
89
|
+
// Watch builds recover on the next rebuild's re-init.
|
|
90
|
+
const angularCompilationError = tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_initializationError, "f") ?? tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_emitError, "f");
|
|
91
|
+
if (angularCompilationError) {
|
|
92
|
+
(0, rspack_diagnostics_1.addError)(compilation, angularCompilationError);
|
|
93
|
+
}
|
|
85
94
|
// Handle errors thrown by loaders that prevent sealing (but ignore for watch mode)
|
|
86
95
|
compilation.hooks.afterSeal.tapAsync(PLUGIN_NAME, (callback) => {
|
|
87
96
|
if (!watchRunInitialized && compilation.errors.length > 0) {
|
|
@@ -152,26 +161,43 @@ class AngularRspackPlugin {
|
|
|
152
161
|
});
|
|
153
162
|
});
|
|
154
163
|
compiler.hooks.emit.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
164
|
+
// Skip diagnostics when the Angular compilation failed to initialize:
|
|
165
|
+
// there is no (or only stale) compilation state to diagnose and the
|
|
166
|
+
// failure is already reported as a compilation error. After an emit
|
|
167
|
+
// failure diagnostics still run since they usually carry the root
|
|
168
|
+
// cause, matching @angular/build's application builder.
|
|
169
|
+
try {
|
|
170
|
+
if (!tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").skipTypeChecking && !tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_initializationError, "f")) {
|
|
171
|
+
const { errors, warnings } = await tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_angularCompilation, "f").diagnoseFiles(angular_rspack_compiler_1.DiagnosticModes.All);
|
|
172
|
+
for (const error of errors ?? []) {
|
|
173
|
+
compilation.errors.push({
|
|
174
|
+
name: PLUGIN_NAME,
|
|
175
|
+
message: error.text || '',
|
|
176
|
+
file: error.location?.file,
|
|
177
|
+
stack: error.text,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
for (const warning of warnings ?? []) {
|
|
181
|
+
compilation.warnings.push({
|
|
182
|
+
name: PLUGIN_NAME,
|
|
183
|
+
message: warning.text || '',
|
|
184
|
+
file: warning.location?.file,
|
|
185
|
+
stack: warning.text,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
172
188
|
}
|
|
173
189
|
}
|
|
174
|
-
|
|
190
|
+
catch (error) {
|
|
191
|
+
// A diagnostics failure must not leave the loader callback pending
|
|
192
|
+
// and hang the build. Surface it as a build error instead.
|
|
193
|
+
(0, rspack_diagnostics_1.addError)(compilation, `Angular diagnostics failed.\n${formatError(error)}`);
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
await tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_javascriptTransformer, "f").close();
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// Best-effort cleanup that must never hang the build.
|
|
200
|
+
}
|
|
175
201
|
callback();
|
|
176
202
|
});
|
|
177
203
|
// Store compilation reference for budget checking in done hook
|
|
@@ -221,6 +247,12 @@ class AngularRspackPlugin {
|
|
|
221
247
|
}
|
|
222
248
|
});
|
|
223
249
|
compiler.hooks.afterDone.tap(PLUGIN_NAME, (stats) => {
|
|
250
|
+
// Despite the typings, stats is undefined when the run fails before
|
|
251
|
+
// producing stats (e.g. the afterSeal hook above fails the seal for a
|
|
252
|
+
// build with errors). Rspack reports that failure itself.
|
|
253
|
+
if (!stats) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
224
256
|
// Get stats options - merge defaults with user's config if provided
|
|
225
257
|
const configStats = compiler.options.stats;
|
|
226
258
|
const defaultStatsOptions = (0, get_stats_options_1.getStatsOptions)(tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").verbose);
|
|
@@ -252,6 +284,19 @@ class AngularRspackPlugin {
|
|
|
252
284
|
}
|
|
253
285
|
callback();
|
|
254
286
|
});
|
|
287
|
+
// Failed builds skip the done hook (afterSeal fails the seal), so release
|
|
288
|
+
// the esbuild service and worker pool here too. Runs on close for both
|
|
289
|
+
// one-shot and watch; both teardowns are idempotent.
|
|
290
|
+
compiler.hooks.shutdown.tapAsync(`${PLUGIN_NAME}_cleanup`, async (callback) => {
|
|
291
|
+
try {
|
|
292
|
+
await tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_javascriptTransformer, "f").close();
|
|
293
|
+
await (0, angular_rspack_compiler_1.disposeComponentStylesheetBundler)();
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
// Best-effort cleanup that must never fail the compiler teardown.
|
|
297
|
+
}
|
|
298
|
+
callback();
|
|
299
|
+
});
|
|
255
300
|
compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, (normalModuleFactory) => {
|
|
256
301
|
normalModuleFactory.hooks.beforeResolve.tap(PLUGIN_NAME, (data) => {
|
|
257
302
|
if (data.request.startsWith('angular:jit:')) {
|
|
@@ -264,6 +309,8 @@ class AngularRspackPlugin {
|
|
|
264
309
|
compilation[models_1.NG_RSPACK_SYMBOL_NAME] = () => ({
|
|
265
310
|
javascriptTransformer: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_javascriptTransformer, "f"),
|
|
266
311
|
typescriptFileCache: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_sourceFileCache, "f").typeScriptFileCache,
|
|
312
|
+
angularCompilationFailed: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_initializationError, "f") !== undefined ||
|
|
313
|
+
tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_emitError, "f") !== undefined,
|
|
267
314
|
i18n: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_i18n, "f"),
|
|
268
315
|
});
|
|
269
316
|
});
|
|
@@ -291,29 +338,52 @@ class AngularRspackPlugin {
|
|
|
291
338
|
}
|
|
292
339
|
}
|
|
293
340
|
async setupCompilation(root, tsConfig, modifiedFiles) {
|
|
341
|
+
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_initializationError, undefined, "f");
|
|
342
|
+
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_emitError, undefined, "f");
|
|
294
343
|
const tsconfigPath = tsConfig
|
|
295
344
|
? typeof tsConfig === 'string'
|
|
296
345
|
? tsConfig
|
|
297
346
|
: tsConfig.configFile
|
|
298
347
|
: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").tsConfig;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
348
|
+
try {
|
|
349
|
+
const result = await (0, angular_rspack_compiler_1.setupCompilationWithAngularCompilation)({
|
|
350
|
+
source: {
|
|
351
|
+
tsconfigPath: tsconfigPath,
|
|
352
|
+
},
|
|
353
|
+
}, {
|
|
354
|
+
root,
|
|
355
|
+
aot: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").aot,
|
|
356
|
+
tsConfig: tsconfigPath,
|
|
357
|
+
inlineStyleLanguage: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").inlineStyleLanguage,
|
|
358
|
+
fileReplacements: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").fileReplacements,
|
|
359
|
+
useTsProjectReferences: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").useTsProjectReferences,
|
|
360
|
+
hasServer: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").hasServer,
|
|
361
|
+
includePaths: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").stylePreprocessorOptions?.includePaths,
|
|
362
|
+
sass: tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").stylePreprocessorOptions?.sass,
|
|
363
|
+
}, tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_sourceFileCache, "f"), tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_angularCompilation, "f"), modifiedFiles);
|
|
364
|
+
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_angularCompilation, result.angularCompilation, "f");
|
|
365
|
+
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_collectedStylesheetAssets, result.collectedStylesheetAssets, "f");
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_initializationError, `Angular compilation initialization failed.\n${formatError(error)}`, "f");
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async buildAndAnalyze() {
|
|
372
|
+
if (tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_initializationError, "f")) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
try {
|
|
376
|
+
await (0, angular_rspack_compiler_1.buildAndAnalyze)(tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_angularCompilation, "f"), tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_sourceFileCache, "f").typeScriptFileCache, tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_javascriptTransformer, "f"));
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_emitError, `Angular compilation emit failed.\n${formatError(error)}`, "f");
|
|
380
|
+
}
|
|
316
381
|
}
|
|
317
382
|
}
|
|
318
383
|
exports.AngularRspackPlugin = AngularRspackPlugin;
|
|
319
|
-
_AngularRspackPlugin__options = new WeakMap(), _AngularRspackPlugin_i18n = new WeakMap(), _AngularRspackPlugin_sourceFileCache = new WeakMap(), _AngularRspackPlugin_javascriptTransformer = new WeakMap(), _AngularRspackPlugin_angularCompilation = new WeakMap(), _AngularRspackPlugin_collectedStylesheetAssets = new WeakMap();
|
|
384
|
+
_AngularRspackPlugin__options = new WeakMap(), _AngularRspackPlugin_i18n = new WeakMap(), _AngularRspackPlugin_sourceFileCache = new WeakMap(), _AngularRspackPlugin_javascriptTransformer = new WeakMap(), _AngularRspackPlugin_angularCompilation = new WeakMap(), _AngularRspackPlugin_collectedStylesheetAssets = new WeakMap(), _AngularRspackPlugin_initializationError = new WeakMap(), _AngularRspackPlugin_emitError = new WeakMap();
|
|
385
|
+
function formatError(error) {
|
|
386
|
+
return error instanceof Error
|
|
387
|
+
? (error.stack ?? error.message)
|
|
388
|
+
: String(error);
|
|
389
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-partial-transform.loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/angular-partial-transform.loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"angular-partial-transform.loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/angular-partial-transform.loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,QAyD3E"}
|
|
@@ -9,7 +9,13 @@ function loader(content) {
|
|
|
9
9
|
callback(null, content);
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
12
|
-
const { javascriptTransformer, typescriptFileCache } = this._compilation[models_1.NG_RSPACK_SYMBOL_NAME]();
|
|
12
|
+
const { javascriptTransformer, typescriptFileCache, angularCompilationFailed, } = this._compilation[models_1.NG_RSPACK_SYMBOL_NAME]();
|
|
13
|
+
if (angularCompilationFailed) {
|
|
14
|
+
// The build is already failing with the Angular compilation error,
|
|
15
|
+
// so skip transforming and pass the original content through.
|
|
16
|
+
callback(null, content);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
13
19
|
const request = this.resourcePath;
|
|
14
20
|
if (request.startsWith('data:text/javascript') &&
|
|
15
21
|
request.includes('__module_federation_bundler_runtime__')) {
|
|
@@ -28,12 +34,14 @@ function loader(content) {
|
|
|
28
34
|
callback(null, existingContents);
|
|
29
35
|
return;
|
|
30
36
|
}
|
|
31
|
-
javascriptTransformer
|
|
32
|
-
.transformFile(request, false, false)
|
|
33
|
-
.then((contents) => {
|
|
37
|
+
javascriptTransformer.transformFile(request, false, false).then((contents) => {
|
|
34
38
|
const transformedCode = Buffer.from(contents).toString('utf8');
|
|
35
39
|
typescriptFileCache.set(request, transformedCode);
|
|
36
40
|
callback(null, transformedCode);
|
|
41
|
+
}, (error) => {
|
|
42
|
+
// Fail the module instead of leaving the loader callback pending,
|
|
43
|
+
// which would hang the build.
|
|
44
|
+
callback(error instanceof Error ? error : new Error(String(error)));
|
|
37
45
|
});
|
|
38
46
|
}
|
|
39
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-transform.loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/angular-transform.loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AAKrC,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE;IACJ,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C,
|
|
1
|
+
{"version":3,"file":"angular-transform.loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/angular-transform.loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AAKrC,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE;IACJ,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C,QAkDF"}
|
|
@@ -14,7 +14,14 @@ function loader(content, opt) {
|
|
|
14
14
|
callback(null, content);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
const { typescriptFileCache } = this._compilation[models_1.NG_RSPACK_SYMBOL_NAME]();
|
|
17
|
+
const { typescriptFileCache, angularCompilationFailed } = this._compilation[models_1.NG_RSPACK_SYMBOL_NAME]();
|
|
18
|
+
if (angularCompilationFailed) {
|
|
19
|
+
// The Angular compilation failure is already reported as a compilation
|
|
20
|
+
// error. Emit empty modules instead of raw TS sources that would only
|
|
21
|
+
// bury it under parser errors.
|
|
22
|
+
callback(null, '');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
18
25
|
const request = this.resourcePath.replace(/^[A-Z]:/, '');
|
|
19
26
|
const normalizedRequest = (0, path_1.normalize)(request);
|
|
20
27
|
const templateUrls = templateUrlsResolver.resolve(content, normalizedRequest);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular-rspack",
|
|
3
|
-
"version": "23.0.
|
|
3
|
+
"version": "23.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"tslib": "^2.3.0",
|
|
79
79
|
"webpack-merge": "^6.0.1",
|
|
80
80
|
"ws": "^8.18.0",
|
|
81
|
-
"@nx/angular-rspack-compiler": "23.0.
|
|
82
|
-
"@nx/devkit": "23.0.
|
|
81
|
+
"@nx/angular-rspack-compiler": "23.0.2",
|
|
82
|
+
"@nx/devkit": "23.0.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"jsonc-eslint-parser": "^2.4.0"
|