@nx/angular-rspack 20.9.0 → 21.0.0
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/lib/config/config-utils/browser-config.d.ts.map +1 -1
- package/dist/lib/config/config-utils/browser-config.js +11 -0
- package/dist/lib/config/config-utils/common-config.d.ts.map +1 -1
- package/dist/lib/config/config-utils/common-config.js +32 -0
- package/dist/lib/config/config-utils/dev-server-config-utils.d.ts.map +1 -1
- package/dist/lib/config/config-utils/dev-server-config-utils.js +3 -1
- package/dist/lib/config/config-utils/get-stats-options.d.ts +3 -0
- package/dist/lib/config/config-utils/get-stats-options.d.ts.map +1 -0
- package/dist/lib/config/config-utils/get-stats-options.js +39 -0
- package/dist/lib/config/config-utils/optimization-config.d.ts.map +1 -1
- package/dist/lib/config/config-utils/optimization-config.js +3 -1
- package/dist/lib/config/config-utils/server-config.d.ts.map +1 -1
- package/dist/lib/config/config-utils/server-config.js +2 -1
- package/dist/lib/config/config-utils/style-config-utils.d.ts.map +1 -1
- package/dist/lib/config/config-utils/style-config-utils.js +8 -9
- package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts +7 -14
- package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts.map +1 -1
- package/dist/lib/models/angular-rspack-plugin-options.d.ts +100 -6
- package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -1
- package/dist/lib/models/augmented-compilation.d.ts +2 -2
- package/dist/lib/models/augmented-compilation.d.ts.map +1 -1
- package/dist/lib/models/normalize-options.d.ts +2 -2
- package/dist/lib/models/normalize-options.d.ts.map +1 -1
- package/dist/lib/models/normalize-options.js +63 -28
- package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/angular-rspack-plugin.js +58 -12
- package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts +19 -0
- package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/any-component-style-budget-checker-plugin.js +65 -0
- package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/i18n-inline-plugin.js +5 -3
- package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts.map +1 -1
- package/dist/lib/plugins/loaders/angular-partial-transform.loader.js +4 -1
- package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts +11 -0
- package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/hmr-accept-loader.js +24 -0
- package/dist/lib/plugins/loaders/hmr-accept.d.ts +9 -0
- package/dist/lib/plugins/loaders/hmr-accept.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/hmr-accept.js +183 -0
- package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
- package/dist/lib/plugins/ng-rspack.js +35 -15
- package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/prerender-plugin.js +75 -10
- package/dist/lib/plugins/progress-plugin.d.ts +12 -0
- package/dist/lib/plugins/progress-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/progress-plugin.js +36 -0
- package/dist/lib/plugins/stats-json-plugin.d.ts +14 -0
- package/dist/lib/plugins/stats-json-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/stats-json-plugin.js +70 -0
- package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts +5 -0
- package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.js +34 -0
- package/dist/lib/plugins/tools/dev-tools-ignore-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/tools/dev-tools-ignore-plugin.js +1 -1
- package/dist/lib/plugins/transfer-size-plugin.d.ts +12 -0
- package/dist/lib/plugins/transfer-size-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/transfer-size-plugin.js +49 -0
- package/dist/lib/plugins/watch-file-logs-plugin.d.ts +12 -0
- package/dist/lib/plugins/watch-file-logs-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/watch-file-logs-plugin.js +27 -0
- package/dist/lib/utils/async-chunks.d.ts +17 -0
- package/dist/lib/utils/async-chunks.d.ts.map +1 -0
- package/dist/lib/utils/async-chunks.js +44 -0
- package/dist/lib/utils/color.d.ts +11 -0
- package/dist/lib/utils/color.d.ts.map +1 -0
- package/dist/lib/utils/color.js +41 -0
- package/dist/lib/utils/index-file/get-index-input-file.d.ts +3 -0
- package/dist/lib/utils/index-file/get-index-input-file.d.ts.map +1 -0
- package/dist/lib/utils/index-file/get-index-input-file.js +9 -0
- package/dist/lib/utils/misc-helpers.d.ts +1 -0
- package/dist/lib/utils/misc-helpers.d.ts.map +1 -1
- package/dist/lib/utils/misc-helpers.js +4 -0
- package/dist/lib/utils/rspack-diagnostics.d.ts +3 -3
- package/dist/lib/utils/rspack-diagnostics.d.ts.map +1 -1
- package/dist/lib/utils/rspack-diagnostics.js +16 -4
- package/dist/lib/utils/spinner.d.ts +21 -0
- package/dist/lib/utils/spinner.d.ts.map +1 -0
- package/dist/lib/utils/spinner.js +53 -0
- package/dist/lib/utils/stats.d.ts +35 -0
- package/dist/lib/utils/stats.d.ts.map +1 -0
- package/dist/lib/utils/stats.js +312 -0
- package/dist/lib/utils/tty.d.ts +9 -0
- package/dist/lib/utils/tty.d.ts.map +1 -0
- package/dist/lib/utils/tty.js +22 -0
- package/package.json +6 -2
- package/dist/lib/models/unsupported-options.d.ts +0 -39
- package/dist/lib/models/unsupported-options.d.ts.map +0 -1
- package/dist/lib/models/unsupported-options.js +0 -22
|
@@ -4,8 +4,8 @@ exports.INDEX_HTML_CSR = void 0;
|
|
|
4
4
|
exports.resolveFileReplacements = resolveFileReplacements;
|
|
5
5
|
exports.getHasServer = getHasServer;
|
|
6
6
|
exports.validateSsr = validateSsr;
|
|
7
|
-
exports.validateOptimization = validateOptimization;
|
|
8
7
|
exports.normalizeOptions = normalizeOptions;
|
|
8
|
+
exports.normalizeOptimization = normalizeOptimization;
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const private_1 = require("@angular/build/private");
|
|
11
11
|
const devkit_1 = require("@nx/devkit");
|
|
@@ -14,7 +14,6 @@ const node_fs_1 = require("node:fs");
|
|
|
14
14
|
const node_path_1 = require("node:path");
|
|
15
15
|
const find_project_for_path_1 = require("../utils/find-project-for-path");
|
|
16
16
|
const graph_1 = require("../utils/graph");
|
|
17
|
-
const unsupported_options_1 = require("./unsupported-options");
|
|
18
17
|
exports.INDEX_HTML_CSR = 'index.csr.html';
|
|
19
18
|
/**
|
|
20
19
|
* Resolves file replacement paths to absolute paths based on the provided root directory.
|
|
@@ -51,26 +50,7 @@ function validateSsr(ssr) {
|
|
|
51
50
|
console.warn('The "ssr.experimentalPlatform" option is not currently supported. Node will be used as the platform.');
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
function validateOptimization(optimization) {
|
|
55
|
-
if (typeof optimization === 'boolean' || optimization === undefined) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (typeof optimization === 'object')
|
|
59
|
-
console.warn('The "optimization" option currently only supports a boolean value. Please check the documentation.');
|
|
60
|
-
}
|
|
61
|
-
function validateGeneralUnsupportedOptions(options) {
|
|
62
|
-
const topLevelUnsupportedOptions = unsupported_options_1.TOP_LEVEL_OPTIONS_PENDING_SUPPORT.filter((option) => options[option] !== undefined).sort();
|
|
63
|
-
const devServerUnsupportedOptions = unsupported_options_1.DEV_SERVER_OPTIONS_PENDING_SUPPORT.filter((option) => options.devServer?.[option] !== undefined).sort();
|
|
64
|
-
const unsupportedOptions = [
|
|
65
|
-
...topLevelUnsupportedOptions.map((option) => `"${option}"`),
|
|
66
|
-
...devServerUnsupportedOptions.map((option) => `"devServer.${option}"`),
|
|
67
|
-
];
|
|
68
|
-
if (unsupportedOptions.length > 0) {
|
|
69
|
-
console.warn(`The following options are not yet supported:\n ${unsupportedOptions.join('\n ')}\n`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
53
|
async function normalizeOptions(options) {
|
|
73
|
-
validateGeneralUnsupportedOptions(options);
|
|
74
54
|
const { fileReplacements = [], server, ssr, optimization } = options;
|
|
75
55
|
validateSsr(ssr);
|
|
76
56
|
const normalizedSsr = !ssr
|
|
@@ -81,16 +61,13 @@ async function normalizeOptions(options) {
|
|
|
81
61
|
experimentalPlatform: 'node', // @TODO: Add support for neutral platform
|
|
82
62
|
}
|
|
83
63
|
: ssr;
|
|
84
|
-
|
|
85
|
-
const normalizedOptimization = optimization !== false; // @TODO: Add support for optimization options
|
|
64
|
+
const normalizedOptimization = normalizeOptimization(optimization);
|
|
86
65
|
const root = options.root ?? process.cwd();
|
|
87
66
|
const tsConfig = options.tsConfig
|
|
88
67
|
? (0, node_path_1.resolve)(root, options.tsConfig)
|
|
89
68
|
: (0, node_path_1.join)(root, 'tsconfig.app.json');
|
|
90
69
|
const aot = options.aot ?? true;
|
|
91
|
-
|
|
92
|
-
// const advancedOptimizations = aot && normalizedOptimization.scripts;
|
|
93
|
-
const advancedOptimizations = aot && normalizedOptimization;
|
|
70
|
+
const advancedOptimizations = aot && normalizedOptimization.scripts;
|
|
94
71
|
const project = await getProject(root);
|
|
95
72
|
const assets = project && options.assets?.length
|
|
96
73
|
? normalizeAssetPatterns(options.assets, root, project.data.root, project.data.sourceRoot)
|
|
@@ -135,8 +112,7 @@ async function normalizeOptions(options) {
|
|
|
135
112
|
// : indexBaseName;
|
|
136
113
|
indexOutput = indexBaseName;
|
|
137
114
|
const entryPoints = [
|
|
138
|
-
|
|
139
|
-
['runtime', false],
|
|
115
|
+
['runtime', !options.devServer?.hmr],
|
|
140
116
|
['polyfills', true],
|
|
141
117
|
...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
142
118
|
...globalScripts.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
@@ -158,10 +134,12 @@ async function normalizeOptions(options) {
|
|
|
158
134
|
};
|
|
159
135
|
return {
|
|
160
136
|
advancedOptimizations,
|
|
137
|
+
appShell: options.appShell ?? false,
|
|
161
138
|
assets,
|
|
162
139
|
aot,
|
|
163
140
|
baseHref: options.baseHref,
|
|
164
141
|
browser: options.browser ?? './src/main.ts',
|
|
142
|
+
budgets: options.budgets ?? [],
|
|
165
143
|
commonChunk: options.commonChunk ?? true,
|
|
166
144
|
crossOrigin: options.crossOrigin ?? 'none',
|
|
167
145
|
define: options.define ?? {},
|
|
@@ -181,21 +159,76 @@ async function normalizeOptions(options) {
|
|
|
181
159
|
optimization: normalizedOptimization,
|
|
182
160
|
outputHashing: options.outputHashing ?? 'none',
|
|
183
161
|
outputPath: normalizeOutputPath(root, options.outputPath),
|
|
162
|
+
poll: options.poll ?? undefined,
|
|
184
163
|
polyfills: options.polyfills ?? [],
|
|
185
164
|
prerender: options.prerender ?? false,
|
|
186
165
|
projectName: project?.name ?? undefined,
|
|
166
|
+
progress: options.progress ?? true,
|
|
187
167
|
root,
|
|
168
|
+
scripts: options.scripts ?? [],
|
|
188
169
|
serviceWorker: options.serviceWorker,
|
|
189
170
|
server,
|
|
190
171
|
skipTypeChecking: options.skipTypeChecking ?? false,
|
|
191
172
|
sourceMap: normalizeSourceMap(options.sourceMap),
|
|
192
173
|
ssr: normalizedSsr,
|
|
174
|
+
statsJson: options.statsJson ?? false,
|
|
175
|
+
styles: options.styles ?? [],
|
|
193
176
|
stylePreprocessorOptions: options.stylePreprocessorOptions,
|
|
194
177
|
subresourceIntegrity: options.subresourceIntegrity ?? false,
|
|
195
178
|
supportedBrowsers: (0, private_1.getSupportedBrowsers)(root, { warn: console.warn }),
|
|
196
179
|
tsConfig,
|
|
197
180
|
useTsProjectReferences: options.useTsProjectReferences ?? false,
|
|
198
181
|
vendorChunk: options.vendorChunk ?? false,
|
|
182
|
+
verbose: options.verbose ?? false,
|
|
183
|
+
watch: options.watch ?? false,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function normalizeOptimization(optimization) {
|
|
187
|
+
if (typeof optimization === 'boolean') {
|
|
188
|
+
return {
|
|
189
|
+
fonts: {
|
|
190
|
+
inline: optimization,
|
|
191
|
+
},
|
|
192
|
+
scripts: optimization,
|
|
193
|
+
styles: {
|
|
194
|
+
minify: optimization,
|
|
195
|
+
inlineCritical: optimization,
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
else if (optimization === undefined) {
|
|
200
|
+
return {
|
|
201
|
+
fonts: {
|
|
202
|
+
inline: true,
|
|
203
|
+
},
|
|
204
|
+
scripts: true,
|
|
205
|
+
styles: {
|
|
206
|
+
minify: true,
|
|
207
|
+
inlineCritical: true,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
fonts: {
|
|
213
|
+
inline: optimization.fonts === undefined
|
|
214
|
+
? true
|
|
215
|
+
: typeof optimization.fonts === 'boolean'
|
|
216
|
+
? optimization.fonts
|
|
217
|
+
: optimization.fonts.inline ?? true,
|
|
218
|
+
},
|
|
219
|
+
scripts: optimization.scripts ?? true,
|
|
220
|
+
styles: {
|
|
221
|
+
minify: optimization.styles === undefined
|
|
222
|
+
? true
|
|
223
|
+
: typeof optimization.styles === 'boolean'
|
|
224
|
+
? optimization.styles
|
|
225
|
+
: optimization.styles.minify ?? true,
|
|
226
|
+
inlineCritical: optimization.styles === undefined
|
|
227
|
+
? true
|
|
228
|
+
: typeof optimization.styles === 'boolean'
|
|
229
|
+
? optimization.styles
|
|
230
|
+
: optimization.styles.inlineCritical ?? true,
|
|
231
|
+
},
|
|
199
232
|
};
|
|
200
233
|
}
|
|
201
234
|
function normalizeSourceMap(sourceMap) {
|
|
@@ -231,10 +264,12 @@ function normalizeDevServer(devServer) {
|
|
|
231
264
|
host: defaultHost,
|
|
232
265
|
liveReload: true,
|
|
233
266
|
port: defaultPort,
|
|
267
|
+
open: false,
|
|
234
268
|
};
|
|
235
269
|
}
|
|
236
270
|
return {
|
|
237
271
|
...devServer,
|
|
272
|
+
open: devServer.open ?? false,
|
|
238
273
|
allowedHosts: devServer.allowedHosts ?? [],
|
|
239
274
|
host: devServer.host ?? defaultHost,
|
|
240
275
|
liveReload: devServer.liveReload ?? true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,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;;gBAW5D,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW;IAuB3B,KAAK,CAAC,QAAQ,EAAE,QAAQ;YA8PV,gBAAgB;CAgC/B"}
|
|
@@ -8,11 +8,15 @@ const core_1 = require("@rspack/core");
|
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const models_1 = require("../models");
|
|
10
10
|
const get_locale_base_href_1 = require("../utils/get-locale-base-href");
|
|
11
|
+
const rspack_diagnostics_1 = require("../utils/rspack-diagnostics");
|
|
12
|
+
const misc_helpers_1 = require("../utils/misc-helpers");
|
|
13
|
+
const stats_1 = require("../utils/stats");
|
|
14
|
+
const get_stats_options_1 = require("../config/config-utils/get-stats-options");
|
|
11
15
|
const PLUGIN_NAME = 'AngularRspackPlugin';
|
|
12
16
|
class AngularRspackPlugin {
|
|
13
17
|
#_options;
|
|
14
18
|
#i18n;
|
|
15
|
-
#
|
|
19
|
+
#sourceFileCache;
|
|
16
20
|
#javascriptTransformer;
|
|
17
21
|
// This will be defined in the apply method correctly
|
|
18
22
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -21,7 +25,7 @@ class AngularRspackPlugin {
|
|
|
21
25
|
constructor(options, i18nOptions) {
|
|
22
26
|
this.#_options = options;
|
|
23
27
|
this.#i18n = i18nOptions;
|
|
24
|
-
this.#
|
|
28
|
+
this.#sourceFileCache = new angular_rspack_compiler_1.SourceFileCache();
|
|
25
29
|
this.#javascriptTransformer = new angular_rspack_compiler_1.JavaScriptTransformer({
|
|
26
30
|
/**
|
|
27
31
|
* Matches https://github.com/angular/angular-cli/blob/33ed6e875e509ebbaa0cbdb57be9e932f9915dff/packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts#L89
|
|
@@ -41,7 +45,7 @@ class AngularRspackPlugin {
|
|
|
41
45
|
compiler.hooks.beforeRun.tapAsync(PLUGIN_NAME, async (compiler, callback) => {
|
|
42
46
|
await this.setupCompilation(root, compiler.options.resolve.tsConfig);
|
|
43
47
|
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, async (params, callback) => {
|
|
44
|
-
await (0, angular_rspack_compiler_1.
|
|
48
|
+
await (0, angular_rspack_compiler_1.buildAndAnalyze)(this.#angularCompilation, this.#sourceFileCache.typeScriptFileCache, this.#javascriptTransformer);
|
|
45
49
|
callback();
|
|
46
50
|
});
|
|
47
51
|
callback();
|
|
@@ -53,9 +57,13 @@ class AngularRspackPlugin {
|
|
|
53
57
|
?.modifiedFiles
|
|
54
58
|
? new Set(compiler.watching.compiler.modifiedFiles)
|
|
55
59
|
: new Set();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
if (this.#angularCompilation) {
|
|
61
|
+
this.#sourceFileCache.invalidate(watchingModifiedFiles);
|
|
62
|
+
}
|
|
63
|
+
await this.setupCompilation(root, compiler.options.resolve.tsConfig, watchingModifiedFiles.size > 0
|
|
64
|
+
? watchingModifiedFiles
|
|
65
|
+
: undefined);
|
|
66
|
+
await (0, angular_rspack_compiler_1.buildAndAnalyze)(this.#angularCompilation, this.#sourceFileCache.typeScriptFileCache, this.#javascriptTransformer);
|
|
59
67
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
60
68
|
watchingModifiedFiles.forEach((file) => {
|
|
61
69
|
compilation.fileDependencies.add(file);
|
|
@@ -93,7 +101,7 @@ class AngularRspackPlugin {
|
|
|
93
101
|
setLocaleContent += `(globalThis.$localize ??= {}).locale = "${this.#i18n.sourceLocale}";\n`;
|
|
94
102
|
}
|
|
95
103
|
const concatLocaleSource = new core_1.sources.ConcatSource(setLocaleContent, originalSource);
|
|
96
|
-
compilation.updateAsset(assetName, concatLocaleSource);
|
|
104
|
+
compilation.updateAsset(assetName, concatLocaleSource, (assetInfo) => assetInfo);
|
|
97
105
|
}
|
|
98
106
|
});
|
|
99
107
|
});
|
|
@@ -121,10 +129,46 @@ class AngularRspackPlugin {
|
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
|
-
await this.#angularCompilation.close();
|
|
125
132
|
await this.#javascriptTransformer.close();
|
|
126
133
|
callback();
|
|
127
134
|
});
|
|
135
|
+
compiler.hooks.afterEmit.tap(PLUGIN_NAME, (compilation) => {
|
|
136
|
+
// Check for budget errors and display them to the user.
|
|
137
|
+
const budgets = this.#_options.budgets;
|
|
138
|
+
let budgetFailures;
|
|
139
|
+
compiler.hooks.done.tap(PLUGIN_NAME, (statsValue) => {
|
|
140
|
+
const stats = statsValue.toJson();
|
|
141
|
+
if (budgets?.length) {
|
|
142
|
+
budgetFailures = [...(0, private_1.checkBudgets)(budgets, stats)];
|
|
143
|
+
for (const { severity, message } of budgetFailures) {
|
|
144
|
+
switch (severity) {
|
|
145
|
+
case private_1.ThresholdSeverity.Warning:
|
|
146
|
+
(0, rspack_diagnostics_1.addWarning)(compilation, {
|
|
147
|
+
message,
|
|
148
|
+
name: PLUGIN_NAME,
|
|
149
|
+
hideStack: true,
|
|
150
|
+
});
|
|
151
|
+
break;
|
|
152
|
+
case private_1.ThresholdSeverity.Error:
|
|
153
|
+
(0, rspack_diagnostics_1.addError)(compilation, {
|
|
154
|
+
message,
|
|
155
|
+
name: PLUGIN_NAME,
|
|
156
|
+
hideStack: true,
|
|
157
|
+
});
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
(0, misc_helpers_1.assertNever)(severity);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
compiler.hooks.afterDone.tap(PLUGIN_NAME, (stats) => {
|
|
166
|
+
(0, stats_1.rspackStatsLogger)(stats, (0, get_stats_options_1.getStatsOptions)(this.#_options.verbose));
|
|
167
|
+
if (stats.hasErrors()) {
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
128
172
|
compiler.hooks.normalModuleFactory.tap(PLUGIN_NAME, (normalModuleFactory) => {
|
|
129
173
|
normalModuleFactory.hooks.beforeResolve.tap(PLUGIN_NAME, (data) => {
|
|
130
174
|
if (data.request.startsWith('angular:jit:')) {
|
|
@@ -137,7 +181,7 @@ class AngularRspackPlugin {
|
|
|
137
181
|
compilation[models_1.NG_RSPACK_SYMBOL_NAME] = () => ({
|
|
138
182
|
javascriptTransformer: this
|
|
139
183
|
.#javascriptTransformer,
|
|
140
|
-
typescriptFileCache: this.#
|
|
184
|
+
typescriptFileCache: this.#sourceFileCache.typeScriptFileCache,
|
|
141
185
|
i18n: this.#i18n,
|
|
142
186
|
});
|
|
143
187
|
});
|
|
@@ -164,13 +208,13 @@ class AngularRspackPlugin {
|
|
|
164
208
|
});
|
|
165
209
|
}
|
|
166
210
|
}
|
|
167
|
-
async setupCompilation(root, tsConfig) {
|
|
211
|
+
async setupCompilation(root, tsConfig, modifiedFiles) {
|
|
168
212
|
const tsconfigPath = tsConfig
|
|
169
213
|
? typeof tsConfig === 'string'
|
|
170
214
|
? tsConfig
|
|
171
215
|
: tsConfig.configFile
|
|
172
216
|
: this.#_options.tsConfig;
|
|
173
|
-
this.#angularCompilation = await (0, angular_rspack_compiler_1.
|
|
217
|
+
this.#angularCompilation = await (0, angular_rspack_compiler_1.setupCompilationWithAngularCompilation)({
|
|
174
218
|
source: {
|
|
175
219
|
tsconfigPath: tsconfigPath,
|
|
176
220
|
},
|
|
@@ -182,7 +226,9 @@ class AngularRspackPlugin {
|
|
|
182
226
|
fileReplacements: this.#_options.fileReplacements,
|
|
183
227
|
useTsProjectReferences: this.#_options.useTsProjectReferences,
|
|
184
228
|
hasServer: this.#_options.hasServer,
|
|
185
|
-
|
|
229
|
+
includePaths: this.#_options.stylePreprocessorOptions?.includePaths,
|
|
230
|
+
sass: this.#_options.stylePreprocessorOptions?.sass,
|
|
231
|
+
}, this.#sourceFileCache, this.#angularCompilation, modifiedFiles);
|
|
186
232
|
}
|
|
187
233
|
}
|
|
188
234
|
exports.AngularRspackPlugin = AngularRspackPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { BudgetEntry } from '@angular/build/private';
|
|
9
|
+
import { type Compiler, RspackPluginInstance } from '@rspack/core';
|
|
10
|
+
/**
|
|
11
|
+
* Check budget sizes for component styles by emitting a warning or error if a
|
|
12
|
+
* budget is exceeded by a particular component's styles.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AnyComponentStyleBudgetChecker implements RspackPluginInstance {
|
|
15
|
+
private readonly budgets;
|
|
16
|
+
constructor(budgets: BudgetEntry[]);
|
|
17
|
+
apply(compiler: Compiler): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=any-component-style-budget-checker-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"any-component-style-budget-checker-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/any-component-style-budget-checker-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,WAAW,EAIZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAe,KAAK,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMhF;;;GAGG;AACH,qBAAa,8BAA+B,YAAW,oBAAoB;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;gBAE5B,OAAO,EAAE,WAAW,EAAE;IAMlC,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAgDzB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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.AnyComponentStyleBudgetChecker = void 0;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const private_1 = require("@angular/build/private");
|
|
13
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
14
|
+
const core_1 = require("@rspack/core");
|
|
15
|
+
const rspack_diagnostics_1 = require("../utils/rspack-diagnostics");
|
|
16
|
+
const misc_helpers_1 = require("../utils/misc-helpers");
|
|
17
|
+
const PLUGIN_NAME = 'AnyComponentStyleBudgetChecker';
|
|
18
|
+
/**
|
|
19
|
+
* Check budget sizes for component styles by emitting a warning or error if a
|
|
20
|
+
* budget is exceeded by a particular component's styles.
|
|
21
|
+
*/
|
|
22
|
+
class AnyComponentStyleBudgetChecker {
|
|
23
|
+
budgets;
|
|
24
|
+
constructor(budgets) {
|
|
25
|
+
this.budgets = budgets.filter((budget) => budget.type === private_1.BudgetType.AnyComponentStyle);
|
|
26
|
+
}
|
|
27
|
+
apply(compiler) {
|
|
28
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
29
|
+
compilation.hooks.processAssets.tap({
|
|
30
|
+
name: PLUGIN_NAME,
|
|
31
|
+
stage: core_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE,
|
|
32
|
+
}, () => {
|
|
33
|
+
// No budgets.
|
|
34
|
+
if (this.budgets.length === 0) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// In AOT compilations component styles get processed in child compilations.
|
|
38
|
+
if (!compilation.compiler.parentCompilation) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const cssExtensions = ['.css', '.scss', '.less', '.sass'];
|
|
42
|
+
const componentStyles = Object.keys(compilation.assets)
|
|
43
|
+
.filter((name) => cssExtensions.includes(path.extname(name)))
|
|
44
|
+
.map((name) => ({
|
|
45
|
+
name,
|
|
46
|
+
size: compilation.assets[name].size(),
|
|
47
|
+
componentStyle: true,
|
|
48
|
+
}));
|
|
49
|
+
for (const { severity, message } of (0, private_1.checkBudgets)(this.budgets, { chunks: [], assets: componentStyles }, true)) {
|
|
50
|
+
switch (severity) {
|
|
51
|
+
case private_1.ThresholdSeverity.Warning:
|
|
52
|
+
(0, rspack_diagnostics_1.addWarning)(compilation, message);
|
|
53
|
+
break;
|
|
54
|
+
case private_1.ThresholdSeverity.Error:
|
|
55
|
+
(0, rspack_diagnostics_1.addError)(compilation, message);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
(0, misc_helpers_1.assertNever)(severity);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.AnyComponentStyleBudgetChecker = AnyComponentStyleBudgetChecker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-inline-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/i18n-inline-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,WAAW,CAAC;AAWnB,qBAAa,gBAAiB,YAAW,oBAAoB;;gBAWzD,aAAa,EAAE,oCAAoC,EACnD,WAAW,EAAE,WAAW;IAO1B,KAAK,CAAC,QAAQ,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"i18n-inline-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/i18n-inline-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,WAAW,CAAC;AAWnB,qBAAa,gBAAiB,YAAW,oBAAoB;;gBAWzD,aAAa,EAAE,oCAAoC,EACnD,WAAW,EAAE,WAAW;IAO1B,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAsOzB"}
|
|
@@ -66,11 +66,13 @@ class I18nInlinePlugin {
|
|
|
66
66
|
for (const [localeSubPath, files] of filesToOutput.entries()) {
|
|
67
67
|
for (const [filename, { text, map }] of files.entries()) {
|
|
68
68
|
const localeFileName = `${localeSubPath}/${filename}`;
|
|
69
|
+
const asset = compilation.getAsset(filename);
|
|
70
|
+
const assetInfo = asset?.info;
|
|
69
71
|
if (map) {
|
|
70
|
-
compilation.emitAsset(localeFileName, new core_2.sources.SourceMapSource(text, localeFileName, map));
|
|
72
|
+
compilation.emitAsset(localeFileName, new core_2.sources.SourceMapSource(text, localeFileName, map), (newAssetInfo) => ({ ...assetInfo, ...newAssetInfo }));
|
|
71
73
|
}
|
|
72
|
-
compilation.emitAsset(localeFileName, new core_2.sources.RawSource(text));
|
|
73
|
-
if (
|
|
74
|
+
compilation.emitAsset(localeFileName, new core_2.sources.RawSource(text), (newAssetInfo) => ({ ...assetInfo, ...newAssetInfo }));
|
|
75
|
+
if (asset) {
|
|
74
76
|
compilation.deleteAsset(filename);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
@@ -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,QA2C3E"}
|
|
@@ -22,7 +22,10 @@ function loader(content) {
|
|
|
22
22
|
}
|
|
23
23
|
const existingTransform = typescriptFileCache.get(request);
|
|
24
24
|
if (existingTransform) {
|
|
25
|
-
|
|
25
|
+
const existingContents = typeof existingTransform === 'string'
|
|
26
|
+
? existingTransform
|
|
27
|
+
: Buffer.from(existingTransform).toString('utf8');
|
|
28
|
+
callback(null, existingContents);
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
javascriptTransformer
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { LoaderContext, LoaderDefinitionFunction } from '@rspack/core';
|
|
9
|
+
export declare const HmrLoader: string;
|
|
10
|
+
export default function localizeExtractLoader(this: LoaderContext, content: string, map: Parameters<LoaderDefinitionFunction>[1]): void;
|
|
11
|
+
//# sourceMappingURL=hmr-accept-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr-accept-loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/hmr-accept-loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEvE,eAAO,MAAM,SAAS,QAAa,CAAC;AAGpC,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,UAAU,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,QAY7C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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.HmrLoader = void 0;
|
|
11
|
+
exports.default = localizeExtractLoader;
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
exports.HmrLoader = __filename;
|
|
14
|
+
const hmrAcceptPath = (0, node_path_1.join)(__dirname, './hmr-accept.js').replace(/\\/g, '/');
|
|
15
|
+
function localizeExtractLoader(content, map) {
|
|
16
|
+
const source = `${content}
|
|
17
|
+
|
|
18
|
+
// HMR Accept Code
|
|
19
|
+
import ngHmrAccept from '${hmrAcceptPath}';
|
|
20
|
+
ngHmrAccept(module);
|
|
21
|
+
`;
|
|
22
|
+
this.callback(null, source, map);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export default function (mod: any): void;
|
|
9
|
+
//# sourceMappingURL=hmr-accept.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr-accept.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/loaders/hmr-accept.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH,MAAM,CAAC,OAAO,WAAW,GAAG,EAAE,GAAG,GAAG,IAAI,CA+FvC"}
|