@nx/angular-rspack 20.7.0 → 20.8.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/create-config.d.ts +75 -2
- package/dist/lib/config/create-config.d.ts.map +1 -1
- package/dist/lib/config/create-config.js +166 -138
- package/dist/lib/config/dev-server-config-utils.d.ts.map +1 -1
- package/dist/lib/config/dev-server-config-utils.js +3 -7
- package/dist/lib/config/entry-points.d.ts +9 -0
- package/dist/lib/config/entry-points.d.ts.map +1 -0
- package/dist/lib/config/entry-points.js +36 -0
- package/dist/lib/config/i18n/create-i18n-options.d.ts +1 -1
- package/dist/lib/config/i18n/create-i18n-options.d.ts.map +1 -1
- package/dist/lib/config/i18n/create-i18n-options.js +8 -6
- package/dist/lib/config/style-config-utils.d.ts +12 -306
- package/dist/lib/config/style-config-utils.d.ts.map +1 -1
- package/dist/lib/config/style-config-utils.js +180 -93
- package/dist/lib/models/angular-rspack-plugin-options.d.ts +39 -1
- package/dist/lib/models/angular-rspack-plugin-options.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 +68 -119
- package/dist/lib/models/unsupported-options.d.ts +0 -6
- package/dist/lib/models/unsupported-options.d.ts.map +1 -1
- package/dist/lib/models/unsupported-options.js +0 -6
- package/dist/lib/plugins/angular-rspack-plugin.d.ts +2 -2
- package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/angular-rspack-plugin.js +33 -26
- package/dist/lib/plugins/i18n-inline-plugin.d.ts +2 -2
- package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/i18n-inline-plugin.js +24 -58
- package/dist/lib/plugins/index-html-plugin.d.ts +21 -0
- package/dist/lib/plugins/index-html-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/index-html-plugin.js +114 -0
- package/dist/lib/plugins/ng-rspack.d.ts +8 -4
- package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
- package/dist/lib/plugins/ng-rspack.js +41 -39
- package/dist/lib/utils/find-project-for-path.d.ts +1 -1
- package/dist/lib/utils/find-project-for-path.d.ts.map +1 -1
- package/dist/lib/utils/find-project-for-path.js +2 -4
- package/dist/lib/utils/get-locale-base-href.d.ts +3 -0
- package/dist/lib/utils/get-locale-base-href.d.ts.map +1 -0
- package/dist/lib/utils/get-locale-base-href.js +17 -0
- package/dist/lib/utils/graph.d.ts +3 -0
- package/dist/lib/utils/graph.d.ts.map +1 -0
- package/dist/lib/utils/graph.js +25 -0
- package/dist/lib/utils/i18n.d.ts +4 -0
- package/dist/lib/utils/i18n.d.ts.map +1 -0
- package/dist/lib/utils/i18n.js +25 -0
- package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts +9 -0
- package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts.map +1 -0
- package/dist/lib/utils/index-file/add-event-dispatch-contract.js +27 -0
- package/dist/lib/utils/index-file/html-rewriting-stream.d.ts +16 -0
- package/dist/lib/utils/index-file/html-rewriting-stream.d.ts.map +1 -0
- package/dist/lib/utils/index-file/html-rewriting-stream.js +27 -0
- package/dist/lib/utils/misc-helpers.d.ts +6 -0
- package/dist/lib/utils/misc-helpers.d.ts.map +1 -0
- package/dist/lib/utils/misc-helpers.js +30 -0
- package/dist/lib/utils/rspack-diagnostics.d.ts +4 -0
- package/dist/lib/utils/rspack-diagnostics.d.ts.map +1 -0
- package/dist/lib/utils/rspack-diagnostics.js +10 -0
- package/dist/lib/utils/tailwind.d.ts +2 -0
- package/dist/lib/utils/tailwind.d.ts.map +1 -0
- package/dist/lib/utils/tailwind.js +31 -0
- package/dist/lib/utils/url-join.d.ts +9 -0
- package/dist/lib/utils/url-join.d.ts.map +1 -0
- package/dist/lib/utils/url-join.js +17 -0
- package/package.json +23 -6
|
@@ -1,6 +1,79 @@
|
|
|
1
|
-
import { Configuration } from '@rspack/core';
|
|
2
|
-
import { AngularRspackPluginOptions } from '../models';
|
|
1
|
+
import { type Configuration } from '@rspack/core';
|
|
2
|
+
import { type AngularRspackPluginOptions, type SourceMap } from '../models';
|
|
3
3
|
export declare function _createConfig(options: AngularRspackPluginOptions, rspackConfigOverrides?: Partial<Configuration>): Promise<Configuration[]>;
|
|
4
|
+
export declare function handleConfigurations(defaultOptions: {
|
|
5
|
+
options: AngularRspackPluginOptions;
|
|
6
|
+
rspackConfigOverrides?: Partial<Configuration>;
|
|
7
|
+
}, configurations: Record<string, {
|
|
8
|
+
options: Partial<AngularRspackPluginOptions>;
|
|
9
|
+
rspackConfigOverrides?: Partial<Configuration>;
|
|
10
|
+
}>, configurationModes: string[]): {
|
|
11
|
+
mergedConfigurationBuildOptions: {
|
|
12
|
+
aot?: boolean;
|
|
13
|
+
assets?: import("../models").AssetElement[];
|
|
14
|
+
baseHref?: string;
|
|
15
|
+
browser?: string;
|
|
16
|
+
commonChunk?: boolean;
|
|
17
|
+
crossOrigin?: "none" | "anonymous" | "use-credentials";
|
|
18
|
+
define?: Record<string, string>;
|
|
19
|
+
deleteOutputPath?: boolean;
|
|
20
|
+
deployUrl?: string;
|
|
21
|
+
devServer?: import("../models").DevServerOptions;
|
|
22
|
+
externalDependencies?: string[];
|
|
23
|
+
extractLicenses?: boolean;
|
|
24
|
+
fileReplacements?: import("@nx/angular-rspack-compiler").FileReplacement[];
|
|
25
|
+
index?: import("../models").IndexElement;
|
|
26
|
+
inlineStyleLanguage?: import("@nx/angular-rspack-compiler").InlineStyleLanguage;
|
|
27
|
+
i18nMetadata?: import("../models").I18nProjectMetadata;
|
|
28
|
+
i18nMissingTranslation?: "warning" | "error" | "ignore";
|
|
29
|
+
i18nDuplicateTranslation?: "warning" | "error" | "ignore";
|
|
30
|
+
localize?: boolean | string[];
|
|
31
|
+
namedChunks?: boolean;
|
|
32
|
+
ngswConfigPath?: string;
|
|
33
|
+
optimization?: boolean | import("../models").OptimizationOptions;
|
|
34
|
+
outputHashing?: import("../models").OutputHashing;
|
|
35
|
+
outputPath?: string | (Required<Pick<import("../models").OutputPath, "base">> & Partial<import("../models").OutputPath>);
|
|
36
|
+
polyfills?: string[];
|
|
37
|
+
preserveSymlinks?: boolean;
|
|
38
|
+
root?: string;
|
|
39
|
+
scripts?: import("../models").ScriptOrStyleEntry[];
|
|
40
|
+
server?: string;
|
|
41
|
+
serviceWorker?: boolean;
|
|
42
|
+
skipTypeChecking?: boolean;
|
|
43
|
+
sourceMap?: boolean | Partial<SourceMap>;
|
|
44
|
+
ssr?: boolean | {
|
|
45
|
+
entry: string;
|
|
46
|
+
experimentalPlatform?: "node" | "neutral";
|
|
47
|
+
};
|
|
48
|
+
stylePreprocessorOptions?: import("@nx/angular-rspack-compiler").StylePreprocessorOptions;
|
|
49
|
+
styles?: import("../models").ScriptOrStyleEntry[];
|
|
50
|
+
subresourceIntegrity?: boolean;
|
|
51
|
+
tsConfig?: string;
|
|
52
|
+
useTsProjectReferences?: boolean;
|
|
53
|
+
vendorChunk?: boolean;
|
|
54
|
+
webWorkerTsConfig?: string;
|
|
55
|
+
security?: {
|
|
56
|
+
autoCsp?: boolean | {
|
|
57
|
+
unsafeEval?: boolean;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
clearScreen?: boolean;
|
|
61
|
+
verbose?: boolean;
|
|
62
|
+
progress?: boolean;
|
|
63
|
+
watch?: boolean;
|
|
64
|
+
poll?: number;
|
|
65
|
+
statsJson?: boolean;
|
|
66
|
+
budgets?: import("../models/unsupported-options").BudgetEntry[];
|
|
67
|
+
allowedCommonJsDependencies?: string[];
|
|
68
|
+
prerender?: boolean | {
|
|
69
|
+
routesFile?: string;
|
|
70
|
+
discoverRoutes?: boolean;
|
|
71
|
+
};
|
|
72
|
+
appShell?: boolean;
|
|
73
|
+
outputMode?: "static" | "server";
|
|
74
|
+
};
|
|
75
|
+
mergedRspackConfigOverrides: Partial<import("@rspack/core").RspackOptions>;
|
|
76
|
+
};
|
|
4
77
|
export declare function createConfig(defaultOptions: {
|
|
5
78
|
options: AngularRspackPluginOptions;
|
|
6
79
|
rspackConfigOverrides?: Partial<Configuration>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/create-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/create-config.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,aAAa,EAUnB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,KAAK,0BAA0B,EAE/B,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AAqEnB,wBAAsB,aAAa,CACjC,OAAO,EAAE,0BAA0B,EACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC7C,OAAO,CAAC,aAAa,EAAE,CAAC,CA8c1B;AAED,wBAAgB,oBAAoB,CAClC,cAAc,EAAE;IACd,OAAO,EAAE,0BAA0B,CAAC;IACpC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,EACD,cAAc,EAAE,MAAM,CACpB,MAAM,EACN;IACE,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,CACF,EACD,kBAAkB,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAnajB,CAAC;;;;;;;;;;mBA/HgB,CAAC;0BAAgD,CAAC;;;;;;;;;;;;sBAOrB,CAAC;0BAClC,CAAC;;;;;;EA6iB1B;AAED,wBAAsB,YAAY,CAChC,cAAc,EAAE;IACd,OAAO,EAAE,0BAA0B,CAAC;IACpC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,EACD,cAAc,GAAE,MAAM,CACpB,MAAM,EACN;IACE,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,CACG,EACN,YAAY,SAAgB,GAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,CAW1B"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._createConfig = _createConfig;
|
|
4
|
+
exports.handleConfigurations = handleConfigurations;
|
|
4
5
|
exports.createConfig = createConfig;
|
|
5
|
-
const
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
|
|
6
8
|
const core_1 = require("@rspack/core");
|
|
7
|
-
const
|
|
9
|
+
const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
|
|
8
10
|
const path_1 = require("path");
|
|
11
|
+
const webpack_merge_1 = require("webpack-merge");
|
|
9
12
|
const models_1 = require("../models");
|
|
10
|
-
const
|
|
11
|
-
const style_config_utils_1 = require("./style-config-utils");
|
|
12
|
-
const helpers_1 = require("./helpers");
|
|
13
|
-
const dev_server_config_utils_1 = require("./dev-server-config-utils");
|
|
13
|
+
const ng_rspack_1 = require("../plugins/ng-rspack");
|
|
14
14
|
const dev_tools_ignore_plugin_1 = require("../plugins/tools/dev-tools-ignore-plugin");
|
|
15
|
+
const misc_helpers_1 = require("../utils/misc-helpers");
|
|
16
|
+
const dev_server_config_utils_1 = require("./dev-server-config-utils");
|
|
17
|
+
const entry_points_1 = require("./entry-points");
|
|
18
|
+
const helpers_1 = require("./helpers");
|
|
15
19
|
const create_i18n_options_1 = require("./i18n/create-i18n-options");
|
|
20
|
+
const style_config_utils_1 = require("./style-config-utils");
|
|
16
21
|
function configureSourceMap(sourceMap) {
|
|
17
22
|
const { scripts, styles, hidden, vendor } = sourceMap;
|
|
18
23
|
const sourceMapRules = [];
|
|
@@ -65,7 +70,7 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
65
70
|
: () => {
|
|
66
71
|
// no-op as i18n is not inlined
|
|
67
72
|
};
|
|
68
|
-
const normalizedOptions = (0, models_1.normalizeOptions)(_options);
|
|
73
|
+
const normalizedOptions = await (0, models_1.normalizeOptions)(_options);
|
|
69
74
|
const isProduction = process.env['NODE_ENV'] === 'production';
|
|
70
75
|
const isDevServer = process.env['WEBPACK_SERVE'];
|
|
71
76
|
const hashFormat = (0, helpers_1.getOutputHashFormat)(normalizedOptions.outputHashing);
|
|
@@ -74,19 +79,28 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
74
79
|
await (0, helpers_1.deleteOutputDir)(root, normalizedOptions.outputPath.base);
|
|
75
80
|
}
|
|
76
81
|
const { sourceMapRules, sourceMapPlugins } = configureSourceMap(normalizedOptions.sourceMap);
|
|
82
|
+
let crossOriginLoading = false;
|
|
83
|
+
if (normalizedOptions.subresourceIntegrity &&
|
|
84
|
+
normalizedOptions.crossOrigin === 'none') {
|
|
85
|
+
crossOriginLoading = 'anonymous';
|
|
86
|
+
}
|
|
87
|
+
else if (normalizedOptions.crossOrigin !== 'none') {
|
|
88
|
+
crossOriginLoading = normalizedOptions.crossOrigin;
|
|
89
|
+
}
|
|
77
90
|
const defaultConfig = {
|
|
78
91
|
context: root,
|
|
79
92
|
mode: isProduction ? 'production' : 'development',
|
|
80
93
|
devtool: normalizedOptions.sourceMap.scripts ? 'source-map' : undefined,
|
|
81
94
|
output: {
|
|
82
|
-
uniqueName: 'rspack-angular',
|
|
83
|
-
publicPath: '
|
|
95
|
+
uniqueName: normalizedOptions.projectName ?? 'rspack-angular',
|
|
96
|
+
publicPath: normalizedOptions.deployUrl ?? '',
|
|
84
97
|
clean: normalizedOptions.deleteOutputPath,
|
|
85
|
-
crossOriginLoading
|
|
98
|
+
crossOriginLoading,
|
|
86
99
|
trustedTypes: { policyName: 'angular#bundler' },
|
|
87
100
|
sourceMapFilename: normalizedOptions.sourceMap.scripts
|
|
88
101
|
? '[file].map'
|
|
89
102
|
: undefined,
|
|
103
|
+
scriptType: 'module',
|
|
90
104
|
},
|
|
91
105
|
resolve: {
|
|
92
106
|
extensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
@@ -107,6 +121,15 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
107
121
|
watchOptions: {
|
|
108
122
|
followSymlinks: normalizedOptions.preserveSymlinks,
|
|
109
123
|
},
|
|
124
|
+
ignoreWarnings: [
|
|
125
|
+
// https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83
|
|
126
|
+
/Failed to parse source map from/,
|
|
127
|
+
// https://github.com/webpack-contrib/postcss-loader/blob/bd261875fdf9c596af4ffb3a1a73fe3c549befda/src/index.js#L153-L158
|
|
128
|
+
/Add postcss as project dependency/,
|
|
129
|
+
// esbuild will issue a warning, while still hoists the @charset at the very top.
|
|
130
|
+
// This is caused by a bug in css-loader https://github.com/webpack-contrib/css-loader/issues/1212
|
|
131
|
+
/"@charset" must be the first rule in the file/,
|
|
132
|
+
],
|
|
110
133
|
module: {
|
|
111
134
|
parser: {
|
|
112
135
|
javascript: {
|
|
@@ -115,7 +138,13 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
115
138
|
},
|
|
116
139
|
},
|
|
117
140
|
rules: [
|
|
118
|
-
|
|
141
|
+
{
|
|
142
|
+
test: /\.?(svg|html)$/,
|
|
143
|
+
// Only process HTML and SVG which are known Angular component resources.
|
|
144
|
+
resourceQuery: /\?ngResource/,
|
|
145
|
+
type: 'asset/source',
|
|
146
|
+
},
|
|
147
|
+
...(await (0, style_config_utils_1.getStyleLoaders)(normalizedOptions)),
|
|
119
148
|
...sourceMapRules,
|
|
120
149
|
{ test: /[/\\]rxjs[/\\]add[/\\].+\.js$/, sideEffects: true },
|
|
121
150
|
{
|
|
@@ -155,7 +184,7 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
155
184
|
apply(compiler) {
|
|
156
185
|
compiler.hooks.compilation.tap('AngularRspackPlugin', (compilation) => {
|
|
157
186
|
core_1.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).chunkHash.tap('AngularRspackPlugin', (_, hash) => {
|
|
158
|
-
hash.update('$localize' + i18nHash);
|
|
187
|
+
hash.update(Buffer.from('$localize' + i18nHash));
|
|
159
188
|
});
|
|
160
189
|
});
|
|
161
190
|
},
|
|
@@ -176,18 +205,22 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
176
205
|
entry: {
|
|
177
206
|
server: {
|
|
178
207
|
import: [
|
|
179
|
-
|
|
208
|
+
...((0, misc_helpers_1.isPackageInstalled)(root, '@angular/platform-server')
|
|
209
|
+
? // This import must come before any imports (direct or transitive) that rely on DOM built-ins being
|
|
210
|
+
// available, such as `@angular/elements`.
|
|
211
|
+
['@angular/platform-server/init']
|
|
212
|
+
: []),
|
|
180
213
|
...(i18n.shouldInline ? ['@angular/localize/init'] : []),
|
|
214
|
+
normalizedOptions.ssr.entry,
|
|
181
215
|
],
|
|
182
216
|
},
|
|
183
217
|
},
|
|
184
218
|
output: {
|
|
185
219
|
...defaultConfig.output,
|
|
186
|
-
publicPath: '/',
|
|
187
|
-
clean: normalizedOptions.deleteOutputPath,
|
|
188
220
|
path: normalizedOptions.outputPath.server,
|
|
189
221
|
filename: '[name].js',
|
|
190
222
|
chunkFilename: '[name].js',
|
|
223
|
+
library: { type: 'commonjs' },
|
|
191
224
|
},
|
|
192
225
|
devServer: {
|
|
193
226
|
headers: {
|
|
@@ -234,63 +267,61 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
234
267
|
optimization: {
|
|
235
268
|
chunkIds: normalizedOptions.namedChunks ? 'named' : 'deterministic',
|
|
236
269
|
moduleIds: 'deterministic',
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
maxInitialRequests: 30,
|
|
247
|
-
cacheGroups: {
|
|
248
|
-
default: normalizedOptions.commonChunk && {
|
|
249
|
-
chunks: 'async',
|
|
250
|
-
minChunks: 2,
|
|
251
|
-
priority: 10,
|
|
252
|
-
},
|
|
253
|
-
common: normalizedOptions.commonChunk && {
|
|
254
|
-
name: 'common',
|
|
255
|
-
chunks: 'async',
|
|
256
|
-
minChunks: 2,
|
|
257
|
-
enforce: true,
|
|
258
|
-
priority: 5,
|
|
270
|
+
runtimeChunk: false,
|
|
271
|
+
emitOnErrors: false,
|
|
272
|
+
minimizer: normalizedOptions.optimization
|
|
273
|
+
? [
|
|
274
|
+
new core_1.SwcJsMinimizerRspackPlugin({
|
|
275
|
+
minimizerOptions: {
|
|
276
|
+
minify: true,
|
|
277
|
+
compress: {
|
|
278
|
+
passes: 2,
|
|
259
279
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
name: 'vendor',
|
|
263
|
-
chunks: (chunk) => chunk.name === 'main',
|
|
264
|
-
enforce: true,
|
|
265
|
-
test: VENDORS_TEST,
|
|
280
|
+
format: {
|
|
281
|
+
comments: false,
|
|
266
282
|
},
|
|
267
283
|
},
|
|
284
|
+
}),
|
|
285
|
+
new core_1.LightningCssMinimizerRspackPlugin(),
|
|
286
|
+
]
|
|
287
|
+
: [],
|
|
288
|
+
splitChunks: {
|
|
289
|
+
chunks: 'async',
|
|
290
|
+
minChunks: 1,
|
|
291
|
+
minSize: 20000,
|
|
292
|
+
maxAsyncRequests: 30,
|
|
293
|
+
maxInitialRequests: 30,
|
|
294
|
+
cacheGroups: {
|
|
295
|
+
default: normalizedOptions.commonChunk && {
|
|
296
|
+
chunks: 'async',
|
|
297
|
+
minChunks: 2,
|
|
298
|
+
priority: 10,
|
|
268
299
|
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
minimizer: [],
|
|
286
|
-
}),
|
|
300
|
+
common: normalizedOptions.commonChunk && {
|
|
301
|
+
name: 'common',
|
|
302
|
+
chunks: 'async',
|
|
303
|
+
minChunks: 2,
|
|
304
|
+
enforce: true,
|
|
305
|
+
priority: 5,
|
|
306
|
+
},
|
|
307
|
+
vendors: false,
|
|
308
|
+
defaultVendors: normalizedOptions.vendorChunk && {
|
|
309
|
+
name: 'vendor',
|
|
310
|
+
chunks: (chunk) => chunk.name === 'main',
|
|
311
|
+
enforce: true,
|
|
312
|
+
test: VENDORS_TEST,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
},
|
|
287
316
|
},
|
|
288
317
|
plugins: [
|
|
289
318
|
...(defaultConfig.plugins ?? []),
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
319
|
+
// Fixes Critical dependency: the request of a dependency is an expression
|
|
320
|
+
new core_1.ContextReplacementPlugin(/@?hapi|express[\\/]/),
|
|
321
|
+
new ng_rspack_1.NgRspackPlugin(normalizedOptions, {
|
|
322
|
+
i18nOptions: i18n,
|
|
323
|
+
platform: 'server',
|
|
324
|
+
}),
|
|
294
325
|
],
|
|
295
326
|
};
|
|
296
327
|
const mergedConfig = (0, webpack_merge_1.merge)(serverConfig, rspackConfigOverrides ?? {});
|
|
@@ -306,13 +337,13 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
306
337
|
entry: {
|
|
307
338
|
main: {
|
|
308
339
|
import: [
|
|
309
|
-
normalizedOptions.browser,
|
|
310
340
|
...(i18n.shouldInline ? ['@angular/localize/init'] : []),
|
|
341
|
+
normalizedOptions.browser,
|
|
311
342
|
],
|
|
312
343
|
},
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
344
|
+
...(0, entry_points_1.getPolyfillsEntry)(normalizedOptions.polyfills, normalizedOptions.aot),
|
|
345
|
+
...(0, entry_points_1.toRspackEntries)(normalizedOptions.globalStyles, normalizedOptions.root, 'ngGlobalStyles'),
|
|
346
|
+
...(0, entry_points_1.toRspackEntries)(normalizedOptions.globalScripts, normalizedOptions.root),
|
|
316
347
|
},
|
|
317
348
|
devServer: {
|
|
318
349
|
headers: {
|
|
@@ -366,8 +397,6 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
366
397
|
output: {
|
|
367
398
|
...defaultConfig.output,
|
|
368
399
|
hashFunction: isProduction ? 'xxhash64' : undefined,
|
|
369
|
-
publicPath: 'auto',
|
|
370
|
-
clean: normalizedOptions.deleteOutputPath,
|
|
371
400
|
path: normalizedOptions.outputPath.browser,
|
|
372
401
|
cssFilename: `[name]${hashFormat.file}.css`,
|
|
373
402
|
filename: `[name]${hashFormat.chunk}.js`,
|
|
@@ -377,87 +406,86 @@ async function _createConfig(options, rspackConfigOverrides) {
|
|
|
377
406
|
},
|
|
378
407
|
optimization: {
|
|
379
408
|
chunkIds: normalizedOptions.namedChunks ? 'named' : 'deterministic',
|
|
409
|
+
emitOnErrors: false,
|
|
380
410
|
moduleIds: 'deterministic',
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
maxInitialRequests: 30,
|
|
391
|
-
cacheGroups: {
|
|
392
|
-
default: normalizedOptions.commonChunk && {
|
|
393
|
-
chunks: 'async',
|
|
394
|
-
minChunks: 2,
|
|
395
|
-
priority: 10,
|
|
396
|
-
},
|
|
397
|
-
common: normalizedOptions.commonChunk && {
|
|
398
|
-
name: 'common',
|
|
399
|
-
chunks: 'async',
|
|
400
|
-
minChunks: 2,
|
|
401
|
-
enforce: true,
|
|
402
|
-
priority: 5,
|
|
411
|
+
runtimeChunk: 'single',
|
|
412
|
+
minimizer: normalizedOptions.optimization
|
|
413
|
+
? [
|
|
414
|
+
new core_1.SwcJsMinimizerRspackPlugin({
|
|
415
|
+
minimizerOptions: {
|
|
416
|
+
minify: true,
|
|
417
|
+
mangle: true,
|
|
418
|
+
compress: {
|
|
419
|
+
passes: 2,
|
|
403
420
|
},
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
name: 'vendor',
|
|
407
|
-
chunks: (chunk) => chunk.name === 'main',
|
|
408
|
-
enforce: true,
|
|
409
|
-
test: VENDORS_TEST,
|
|
421
|
+
format: {
|
|
422
|
+
comments: false,
|
|
410
423
|
},
|
|
411
424
|
},
|
|
425
|
+
}),
|
|
426
|
+
new core_1.LightningCssMinimizerRspackPlugin(),
|
|
427
|
+
]
|
|
428
|
+
: [],
|
|
429
|
+
splitChunks: {
|
|
430
|
+
chunks: 'all',
|
|
431
|
+
minChunks: 1,
|
|
432
|
+
minSize: 20000,
|
|
433
|
+
maxAsyncRequests: 30,
|
|
434
|
+
maxInitialRequests: 30,
|
|
435
|
+
cacheGroups: {
|
|
436
|
+
default: normalizedOptions.commonChunk && {
|
|
437
|
+
chunks: 'async',
|
|
438
|
+
minChunks: 2,
|
|
439
|
+
priority: 10,
|
|
412
440
|
},
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
minimize: false,
|
|
430
|
-
minimizer: [],
|
|
431
|
-
}),
|
|
441
|
+
common: normalizedOptions.commonChunk && {
|
|
442
|
+
name: 'common',
|
|
443
|
+
chunks: 'async',
|
|
444
|
+
minChunks: 2,
|
|
445
|
+
enforce: true,
|
|
446
|
+
priority: 5,
|
|
447
|
+
},
|
|
448
|
+
vendors: false,
|
|
449
|
+
defaultVendors: normalizedOptions.vendorChunk && {
|
|
450
|
+
name: 'vendor',
|
|
451
|
+
chunks: (chunk) => chunk.name === 'main',
|
|
452
|
+
enforce: true,
|
|
453
|
+
test: VENDORS_TEST,
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
},
|
|
432
457
|
},
|
|
433
458
|
plugins: [
|
|
434
459
|
...(defaultConfig.plugins ?? []),
|
|
435
|
-
new ng_rspack_1.NgRspackPlugin({
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}, i18n),
|
|
460
|
+
new ng_rspack_1.NgRspackPlugin(normalizedOptions, {
|
|
461
|
+
i18nOptions: i18n,
|
|
462
|
+
platform: 'browser',
|
|
463
|
+
}),
|
|
440
464
|
],
|
|
441
465
|
};
|
|
442
466
|
const mergedConfig = (0, webpack_merge_1.merge)(browserConfig, rspackConfigOverrides ?? {});
|
|
443
467
|
configs.unshift(mergedConfig);
|
|
444
468
|
return configs;
|
|
445
469
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const isDefault = configurationMode === 'default';
|
|
449
|
-
const isModeConfigured = configurationMode in configurations;
|
|
450
|
-
const mergedBuildOptionsOptions = {
|
|
451
|
-
...defaultOptions.options,
|
|
452
|
-
...((!isDefault && isModeConfigured
|
|
453
|
-
? configurations[configurationMode]?.options
|
|
454
|
-
: {}) ?? {}),
|
|
455
|
-
};
|
|
470
|
+
function handleConfigurations(defaultOptions, configurations, configurationModes) {
|
|
471
|
+
let mergedConfigurationBuildOptions = { ...defaultOptions.options };
|
|
456
472
|
let mergedRspackConfigOverrides = defaultOptions.rspackConfigOverrides ?? {};
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
473
|
+
for (const configurationName of configurationModes) {
|
|
474
|
+
if (configurationName in configurations) {
|
|
475
|
+
mergedConfigurationBuildOptions = (0, deepmerge_1.default)(mergedConfigurationBuildOptions, configurations[configurationName].options ?? {});
|
|
476
|
+
if (configurations[configurationName].rspackConfigOverrides) {
|
|
477
|
+
mergedRspackConfigOverrides = (0, webpack_merge_1.merge)(mergedRspackConfigOverrides, configurations[configurationName].rspackConfigOverrides);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
461
480
|
}
|
|
462
|
-
return
|
|
481
|
+
return { mergedConfigurationBuildOptions, mergedRspackConfigOverrides };
|
|
482
|
+
}
|
|
483
|
+
async function createConfig(defaultOptions, configurations = {}, configEnvVar = 'NGRS_CONFIG') {
|
|
484
|
+
const configurationMode = process.env[configEnvVar] ?? 'production';
|
|
485
|
+
const configurationModes = parseConfigurationMode(configurationMode);
|
|
486
|
+
const { mergedConfigurationBuildOptions, mergedRspackConfigOverrides } = handleConfigurations(defaultOptions, configurations, configurationModes);
|
|
487
|
+
return _createConfig(mergedConfigurationBuildOptions, mergedRspackConfigOverrides);
|
|
488
|
+
}
|
|
489
|
+
function parseConfigurationMode(configurationMode) {
|
|
490
|
+
return configurationMode.split(',').map((m) => m.trim());
|
|
463
491
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server-config-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/config/dev-server-config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server-config-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/config/dev-server-config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAO9C,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,GAAG,SAAS,EAC5C,gBAAgB,EAAE,OAAO,GAAG,SAAS,gCAUtC;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CA2EzC"}
|
|
@@ -7,6 +7,7 @@ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
|
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
8
|
const node_path_1 = require("node:path");
|
|
9
9
|
const node_url_1 = require("node:url");
|
|
10
|
+
const misc_helpers_1 = require("../utils/misc-helpers");
|
|
10
11
|
function getAllowedHostsConfig(allowedHosts, disableHostCheck) {
|
|
11
12
|
if (disableHostCheck || allowedHosts === true) {
|
|
12
13
|
return 'all';
|
|
@@ -47,7 +48,7 @@ async function getProxyConfig(root, proxyConfig) {
|
|
|
47
48
|
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
48
49
|
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
49
50
|
// changed to a direct dynamic import.
|
|
50
|
-
proxyConfiguration = (await loadEsmModule((0, node_url_1.pathToFileURL)(proxyPath))).default;
|
|
51
|
+
proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
|
|
51
52
|
break;
|
|
52
53
|
case '.cjs':
|
|
53
54
|
proxyConfiguration = require(proxyPath);
|
|
@@ -66,7 +67,7 @@ async function getProxyConfig(root, proxyConfig) {
|
|
|
66
67
|
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
67
68
|
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
68
69
|
// changed to a direct dynamic import.
|
|
69
|
-
proxyConfiguration = (await loadEsmModule((0, node_url_1.pathToFileURL)(proxyPath))).default;
|
|
70
|
+
proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
return normalizeProxyConfiguration(proxyConfiguration);
|
|
@@ -104,8 +105,3 @@ function assertIsError(value) {
|
|
|
104
105
|
'message' in value);
|
|
105
106
|
(0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
|
|
106
107
|
}
|
|
107
|
-
let load;
|
|
108
|
-
function loadEsmModule(modulePath) {
|
|
109
|
-
load ??= new Function('modulePath', `return import(modulePath);`);
|
|
110
|
-
return load(modulePath);
|
|
111
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GlobalEntry } from '../models';
|
|
2
|
+
export declare function getEntryPoints(globalStyles: GlobalEntry[], globalScripts: GlobalEntry[], isHMREnabled?: boolean): [name: string, isModule: boolean][];
|
|
3
|
+
export declare function getPolyfillsEntry(polyfills: string[], aot: boolean): {
|
|
4
|
+
polyfills?: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function toRspackEntries(entries: GlobalEntry[], root: string, queryString?: string): Record<string, {
|
|
7
|
+
import: string[];
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=entry-points.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-points.d.ts","sourceRoot":"","sources":["../../../src/lib/config/entry-points.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,wBAAgB,cAAc,CAC5B,YAAY,EAAE,WAAW,EAAE,EAC3B,aAAa,EAAE,WAAW,EAAE,EAC5B,YAAY,CAAC,EAAE,OAAO,GACrB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAerC;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EAAE,EACnB,GAAG,EAAE,OAAO,GACX;IAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAW1B;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM;YAEmB,MAAM,EAAE;GAahD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntryPoints = getEntryPoints;
|
|
4
|
+
exports.getPolyfillsEntry = getPolyfillsEntry;
|
|
5
|
+
exports.toRspackEntries = toRspackEntries;
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
function getEntryPoints(globalStyles, globalScripts, isHMREnabled) {
|
|
8
|
+
return [
|
|
9
|
+
['runtime', !isHMREnabled],
|
|
10
|
+
['polyfills', true],
|
|
11
|
+
...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
12
|
+
...globalScripts.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
13
|
+
['vendor', true],
|
|
14
|
+
['main', true],
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function getPolyfillsEntry(polyfills, aot) {
|
|
18
|
+
const normalizedPolyfills = [...polyfills];
|
|
19
|
+
if (!aot) {
|
|
20
|
+
normalizedPolyfills.push('@angular/compiler');
|
|
21
|
+
}
|
|
22
|
+
if (normalizedPolyfills.length) {
|
|
23
|
+
return { polyfills: normalizedPolyfills };
|
|
24
|
+
}
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
function toRspackEntries(entries, root, queryString) {
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const { files, name } of entries) {
|
|
30
|
+
result[name] ??= { import: [] };
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
result[name].import.push((0, node_path_1.join)(root, `${file}${queryString ? `?${queryString}` : ''}`));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AngularRspackPluginOptions } from '../../models';
|
|
1
|
+
import type { AngularRspackPluginOptions } from '../../models';
|
|
2
2
|
export declare function configureI18n(projectRoot: string, options: AngularRspackPluginOptions): Promise<{
|
|
3
3
|
options: AngularRspackPluginOptions;
|
|
4
4
|
i18n: import("@angular/build/private").I18nOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-i18n-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/i18n/create-i18n-options.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"create-i18n-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/i18n/create-i18n-options.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAgF/D,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,0BAA0B;;;GAmFpC"}
|