@nx/angular-rspack 24.0.2 → 24.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"get-stats-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/get-stats-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,wBAAgB,eAAe,CAAC,OAAO,UAAQ,GAAG,YAAY,CAsC7D"}
1
+ {"version":3,"file":"get-stats-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/get-stats-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,wBAAgB,eAAe,CAAC,OAAO,UAAQ,GAAG,YAAY,CAoC7D"}
@@ -13,7 +13,6 @@ function getStatsOptions(verbose = false) {
13
13
  errors: true,
14
14
  assets: true, // required by custom stat output
15
15
  cachedAssets: true, // required for bundle size calculators
16
- // Needed for markAsyncChunksNonInitial.
17
16
  ids: true,
18
17
  entrypoints: true,
19
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAoBA,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AA+CnB,qBAAa,mBAAoB,YAAW,oBAAoB;;IAwB9D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EA0B1B;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAiYvB;IAED;;;;;;;OAOG;IACH,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,QAgC1C;YA8Ea,gBAAgB;YAyFhB,eAAe;CAyC9B"}
1
+ {"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAoBA,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AA+CnB,qBAAa,mBAAoB,YAAW,oBAAoB;;IAwB9D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EA0B1B;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAmYvB;IAED;;;;;;;OAOG;IACH,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,QAgC1C;YA8Ea,gBAAgB;YAyFhB,eAAe;CAyC9B"}
@@ -237,6 +237,7 @@ class AngularRspackPlugin {
237
237
  name: PLUGIN_NAME,
238
238
  message: error.text || '',
239
239
  file: error.location?.file,
240
+ ...toRspackLocation(error.location),
240
241
  stack: error.text,
241
242
  });
242
243
  }
@@ -245,6 +246,7 @@ class AngularRspackPlugin {
245
246
  name: PLUGIN_NAME,
246
247
  message: warning.text || '',
247
248
  file: warning.location?.file,
249
+ ...toRspackLocation(warning.location),
248
250
  stack: warning.text,
249
251
  });
250
252
  }
@@ -557,6 +559,14 @@ _AngularRspackPlugin__options = new WeakMap(), _AngularRspackPlugin_i18n = new W
557
559
  }
558
560
  tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_stylesheetMetafileInputs, flattened, "f");
559
561
  };
562
+ function toRspackLocation(location) {
563
+ if (location?.line === undefined) {
564
+ return {};
565
+ }
566
+ // Angular's columns are 0-based, rspack's `loc` columns are 1-based.
567
+ const column = location.column === undefined ? undefined : location.column + 1;
568
+ return { loc: { start: { line: location.line, column } } };
569
+ }
560
570
  function formatError(error) {
561
571
  return error instanceof Error
562
572
  ? (error.stack ?? error.message)
@@ -7,17 +7,12 @@
7
7
  */
8
8
  import { BudgetCalculatorResult } from '@angular/build/private';
9
9
  import { Configuration, StatsCompilation, Stats, StatsOptions } from '@rspack/core';
10
- import { NormalizedAngularRspackPluginOptions, NormalizedEntryPoint, ScriptOrStyleEntry } from '../models/angular-rspack-plugin-options';
11
- export interface RspackLoggingCallback {
12
- (stats: Stats, config: Configuration): void;
13
- }
10
+ import { NormalizedAngularRspackPluginOptions } from '../models/angular-rspack-plugin-options';
14
11
  export type RspackStatsOptions = Exclude<Configuration['stats'], string | boolean | undefined>;
15
- export declare function normalizeExtraEntryPoints(extraEntryPoints: ScriptOrStyleEntry[], defaultBundleName: string): NormalizedEntryPoint[];
16
12
  export declare function statsWarningsToString(json: StatsCompilation, statsConfig: RspackStatsOptions): string;
17
13
  export declare function statsErrorsToString(json: StatsCompilation, statsConfig: RspackStatsOptions): string;
18
14
  export declare function statsHasErrors(json: StatsCompilation): boolean;
19
15
  export declare function statsHasWarnings(json: StatsCompilation): boolean;
20
- export declare function createRspackLoggingCallback(options: NormalizedAngularRspackPluginOptions): (stats: any, config: any) => void;
21
16
  export interface BuildEventStats {
22
17
  aot: boolean;
23
18
  optimization: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,sBAAsB,EAGvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,YAAY,EACb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oCAAoC,EACpC,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAMjD,MAAM,WAAW,qBAAqB;IACpC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,aAAa,CAAC,OAAO,CAAC,EAC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.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.normalizeExtraEntryPoints = normalizeExtraEntryPoints;
11
10
  exports.statsWarningsToString = statsWarningsToString;
12
11
  exports.statsErrorsToString = statsErrorsToString;
13
12
  exports.statsHasErrors = statsHasErrors;
14
13
  exports.statsHasWarnings = statsHasWarnings;
15
- exports.createRspackLoggingCallback = createRspackLoggingCallback;
16
14
  exports.generateBuildEventStats = generateBuildEventStats;
17
15
  exports.rspackStatsLogger = rspackStatsLogger;
18
16
  const tslib_1 = require("tslib");
@@ -21,28 +19,6 @@ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
21
19
  const path = tslib_1.__importStar(require("node:path"));
22
20
  const normalize_options_1 = require("../models/normalize-options");
23
21
  const color_1 = require("./color");
24
- const async_chunks_1 = require("./async-chunks");
25
- const get_stats_options_1 = require("../config/config-utils/get-stats-options");
26
- function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
27
- return extraEntryPoints.map((entry) => {
28
- if (typeof entry === 'string') {
29
- return { input: entry, inject: true, bundleName: defaultBundleName };
30
- }
31
- const { inject = true, ...newEntry } = entry;
32
- let bundleName;
33
- if (entry.bundleName) {
34
- bundleName = entry.bundleName;
35
- }
36
- else if (!inject) {
37
- // Lazy entry points use the file name as bundle name.
38
- bundleName = path.parse(entry.input).name;
39
- }
40
- else {
41
- bundleName = defaultBundleName;
42
- }
43
- return { ...newEntry, inject, bundleName };
44
- });
45
- }
46
22
  function getBuildDuration(rspackStats) {
47
23
  (0, node_assert_1.default)(rspackStats.builtAt, 'buildAt cannot be undefined');
48
24
  (0, node_assert_1.default)(rspackStats.time, 'time cannot be undefined');
@@ -201,14 +177,12 @@ function statsWarningsToString(json, statsConfig) {
201
177
  }
202
178
  output += ' - ';
203
179
  }
204
- if (!/^error/i.test(warning.message)) {
205
- const errorIndex = warning.message.indexOf('Error: ');
206
- warning.message = warning.message.substring(errorIndex + 7);
207
- }
208
- if (!/^warning/i.test(warning.message)) {
180
+ // rspack 1.3 prefixes an Error warning with its name, e.g. " ⚠ Error: ".
181
+ const message = warning.message.replace(/^\s*⚠\s*Error: /, '');
182
+ if (!/^warning/i.test(message)) {
209
183
  output += y('Warning: ');
210
184
  }
211
- output += `${warning.message}\n\n`;
185
+ output += `${message}\n\n`;
212
186
  }
213
187
  }
214
188
  return output ? '\n' + output : output;
@@ -274,25 +248,6 @@ function statsHasErrors(json) {
274
248
  function statsHasWarnings(json) {
275
249
  return !!(json.warnings?.length || json.children?.some((c) => c.warnings?.length));
276
250
  }
277
- function createRspackLoggingCallback(options) {
278
- const { verbose = false, scripts = [], styles = [] } = options;
279
- const extraEntryPoints = [
280
- ...normalizeExtraEntryPoints(styles, 'styles'),
281
- ...normalizeExtraEntryPoints(scripts, 'scripts'),
282
- ];
283
- return (stats, config) => {
284
- if (verbose && config.stats !== false) {
285
- const statsOptions = config.stats === true ? undefined : config.stats;
286
- console.info(stats.toString(statsOptions));
287
- }
288
- const rawStats = stats.toJson((0, get_stats_options_1.getStatsOptions)(false));
289
- const rspackStats = {
290
- ...rawStats,
291
- chunks: (0, async_chunks_1.markAsyncChunksNonInitial)(rawStats, extraEntryPoints),
292
- };
293
- rspackStatsLogger(rspackStats, config);
294
- };
295
- }
296
251
  function generateBuildEventStats(rspackStats, options) {
297
252
  const { chunks = [], assets = [] } = rspackStats;
298
253
  let jsSizeInBytes = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular-rspack",
3
- "version": "24.0.2",
3
+ "version": "24.0.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -56,8 +56,8 @@
56
56
  "@ampproject/remapping": "2.3.0",
57
57
  "@babel/core": "^7.29.6",
58
58
  "@discoveryjs/json-ext": "0.6.3",
59
- "@nx/angular-rspack-compiler": "24.0.2",
60
- "@nx/devkit": "24.0.2",
59
+ "@nx/angular-rspack-compiler": "24.0.3",
60
+ "@nx/devkit": "24.0.3",
61
61
  "ansi-colors": "4.1.3",
62
62
  "autoprefixer": "^10.4.9",
63
63
  "deepmerge": "^4.3.1",
@@ -1,17 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.dev/license
7
- */
8
- import { StatsChunk, StatsCompilation } from '@rspack/core';
9
- import { NormalizedEntryPoint } from '../models/angular-rspack-plugin-options';
10
- /**
11
- * Webpack stats may incorrectly mark extra entry points `initial` chunks, when
12
- * they are actually loaded asynchronously and thus not in the main bundle. This
13
- * function finds extra entry points in Webpack stats and corrects this value
14
- * whereever necessary. Does not modify {@param webpackStats}.
15
- */
16
- export declare function markAsyncChunksNonInitial(webpackStats: StatsCompilation, extraEntryPoints: NormalizedEntryPoint[]): StatsChunk[];
17
- //# sourceMappingURL=async-chunks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-chunks.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/async-chunks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,gBAAgB,EAC9B,gBAAgB,EAAE,oBAAoB,EAAE,GACvC,UAAU,EAAE,CAqCd"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.dev/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.markAsyncChunksNonInitial = markAsyncChunksNonInitial;
11
- /**
12
- * Webpack stats may incorrectly mark extra entry points `initial` chunks, when
13
- * they are actually loaded asynchronously and thus not in the main bundle. This
14
- * function finds extra entry points in Webpack stats and corrects this value
15
- * whereever necessary. Does not modify {@param webpackStats}.
16
- */
17
- function markAsyncChunksNonInitial(webpackStats, extraEntryPoints) {
18
- const { chunks = [], entrypoints: entryPoints = {} } = webpackStats;
19
- // Find all Webpack chunk IDs not injected into the main bundle. We don't have
20
- // to worry about transitive dependencies because extra entry points cannot be
21
- // depended upon in Webpack, thus any extra entry point with `inject: false`,
22
- // **cannot** be loaded in main bundle.
23
- const asyncChunkIds = extraEntryPoints
24
- .filter((entryPoint) => !entryPoint.inject && entryPoints[entryPoint.bundleName])
25
- .flatMap((entryPoint) => entryPoints[entryPoint.bundleName].chunks?.filter((n) => n !== 'runtime'));
26
- // Find chunks for each ID.
27
- const asyncChunks = asyncChunkIds.map((chunkId) => {
28
- const chunk = chunks.find((chunk) => chunk.id === chunkId);
29
- if (!chunk) {
30
- throw new Error(`Failed to find chunk (${chunkId}) in set:\n${JSON.stringify(chunks)}`);
31
- }
32
- return chunk;
33
- });
34
- // A chunk is considered `initial` only if Webpack already belives it to be initial
35
- // and the application developer did not mark it async via an extra entry point.
36
- return chunks.map((chunk) => {
37
- return asyncChunks.find((asyncChunk) => asyncChunk === chunk)
38
- ? {
39
- ...chunk,
40
- initial: false,
41
- }
42
- : chunk;
43
- });
44
- }