@nx/rspack 20.2.0-beta.1 → 20.2.0-beta.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/package.json +4 -4
- package/src/executors/rspack/lib/config.d.ts +6 -0
- package/src/executors/rspack/lib/config.js +39 -0
- package/src/executors/rspack/rspack.impl.js +11 -12
- package/src/executors/rspack/schema.d.ts +39 -18
- package/src/executors/rspack/schema.json +191 -0
- package/src/plugins/utils/apply-base-config.js +1 -5
- package/src/plugins/utils/apply-web-config.js +0 -7
- package/src/plugins/utils/models.d.ts +2 -2
- package/src/utils/create-compiler.d.ts +2 -2
- package/src/utils/create-compiler.js +10 -49
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +7 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/rspack",
|
|
3
3
|
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
|
|
4
|
-
"version": "20.2.0-beta.
|
|
4
|
+
"version": "20.2.0-beta.2",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"generators": "./generators.json",
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nx/js": "20.2.0-beta.
|
|
28
|
-
"@nx/devkit": "20.2.0-beta.
|
|
29
|
-
"@nx/web": "20.2.0-beta.
|
|
27
|
+
"@nx/js": "20.2.0-beta.2",
|
|
28
|
+
"@nx/devkit": "20.2.0-beta.2",
|
|
29
|
+
"@nx/web": "20.2.0-beta.2",
|
|
30
30
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
31
31
|
"@rspack/core": "^1.0.4",
|
|
32
32
|
"@rspack/dev-server": "^1.0.4",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { type Configuration } from '@rspack/core';
|
|
3
|
+
import { type NormalizedRspackExecutorSchema } from '../schema';
|
|
4
|
+
export declare function getRspackConfigs(options: NormalizedRspackExecutorSchema & {
|
|
5
|
+
devServer?: any;
|
|
6
|
+
}, context: ExecutorContext): Promise<Configuration | Configuration[]>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRspackConfigs = getRspackConfigs;
|
|
4
|
+
const config_1 = require("../../../utils/config");
|
|
5
|
+
const resolve_user_defined_rspack_config_1 = require("../../../utils/resolve-user-defined-rspack-config");
|
|
6
|
+
const with_nx_1 = require("../../../utils/with-nx");
|
|
7
|
+
const with_web_1 = require("../../../utils/with-web");
|
|
8
|
+
async function getRspackConfigs(options, context) {
|
|
9
|
+
let userDefinedConfig = (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)(options.rspackConfig, options.tsConfig);
|
|
10
|
+
if (typeof userDefinedConfig.then === 'function') {
|
|
11
|
+
userDefinedConfig = await userDefinedConfig;
|
|
12
|
+
}
|
|
13
|
+
const config = (options.target === 'web'
|
|
14
|
+
? (0, config_1.composePluginsSync)((0, with_nx_1.withNx)(options), (0, with_web_1.withWeb)(options))
|
|
15
|
+
: (0, with_nx_1.withNx)(options))({}, { options, context });
|
|
16
|
+
if ((typeof userDefinedConfig === 'function' &&
|
|
17
|
+
(0, config_1.isNxRspackComposablePlugin)(userDefinedConfig)) ||
|
|
18
|
+
!options.standardRspackConfigFunction) {
|
|
19
|
+
// Old behavior, call the Nx-specific rspack config function that user exports
|
|
20
|
+
return await userDefinedConfig(config, {
|
|
21
|
+
options,
|
|
22
|
+
context,
|
|
23
|
+
configuration: context.configurationName,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else if (userDefinedConfig) {
|
|
27
|
+
if (typeof userDefinedConfig === 'function') {
|
|
28
|
+
// assume it's an async standard rspack config function which operates similar to webpack
|
|
29
|
+
// https://webpack.js.org/configuration/configuration-types/#exporting-a-promise
|
|
30
|
+
return await userDefinedConfig(process.env.NODE_ENV, {});
|
|
31
|
+
}
|
|
32
|
+
// New behavior, we want the rspack config to export object
|
|
33
|
+
return userDefinedConfig;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// Fallback case, if we cannot find a rspack config path
|
|
37
|
+
return config;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = runExecutor;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
7
6
|
const js_1 = require("@nx/js");
|
|
8
7
|
const fs_1 = require("fs");
|
|
9
|
-
const path = tslib_1.__importStar(require("path"));
|
|
10
8
|
const create_compiler_1 = require("../../utils/create-compiler");
|
|
11
9
|
const mode_utils_1 = require("../../utils/mode-utils");
|
|
12
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
11
|
+
const path_1 = require("path");
|
|
13
12
|
async function* runExecutor(options, context) {
|
|
14
13
|
process.env.NODE_ENV ??= options.mode ?? 'production';
|
|
15
14
|
options.target ??= 'web';
|
|
15
|
+
const metadata = context.projectsConfigurations.projects[context.projectName];
|
|
16
|
+
const sourceRoot = metadata.sourceRoot;
|
|
17
|
+
const normalizedOptions = (0, normalize_options_1.normalizeOptions)(options, context.root, metadata.root, sourceRoot);
|
|
16
18
|
if ((0, mode_utils_1.isMode)(process.env.NODE_ENV)) {
|
|
17
|
-
|
|
19
|
+
normalizedOptions.mode = process.env.NODE_ENV;
|
|
18
20
|
}
|
|
19
|
-
if (
|
|
20
|
-
await executeTypeCheck(
|
|
21
|
+
if (normalizedOptions.typeCheck) {
|
|
22
|
+
await executeTypeCheck(normalizedOptions, context);
|
|
21
23
|
}
|
|
22
24
|
// Mimic --clean from webpack.
|
|
23
|
-
(0, fs_1.rmSync)(
|
|
25
|
+
(0, fs_1.rmSync)((0, path_1.join)(context.root, normalizedOptions.outputPath), {
|
|
24
26
|
force: true,
|
|
25
27
|
recursive: true,
|
|
26
28
|
});
|
|
27
|
-
const metadata = context.projectsConfigurations.projects[context.projectName];
|
|
28
|
-
const sourceRoot = metadata.sourceRoot;
|
|
29
|
-
const normalizedOptions = (0, normalize_options_1.normalizeOptions)(options, context.root, metadata.root, sourceRoot);
|
|
30
29
|
const compiler = await (0, create_compiler_1.createCompiler)(normalizedOptions, context);
|
|
31
30
|
const iterable = (0, async_iterable_1.createAsyncIterable)(async ({ next, done }) => {
|
|
32
31
|
if (options.watch) {
|
|
@@ -49,7 +48,7 @@ async function* runExecutor(options, context) {
|
|
|
49
48
|
}
|
|
50
49
|
next({
|
|
51
50
|
success: !stats.hasErrors(),
|
|
52
|
-
outfile:
|
|
51
|
+
outfile: (0, path_1.resolve)(context.root, normalizedOptions.outputPath, 'main.js'),
|
|
53
52
|
});
|
|
54
53
|
});
|
|
55
54
|
registerCleanupCallback(() => {
|
|
@@ -79,7 +78,7 @@ async function* runExecutor(options, context) {
|
|
|
79
78
|
}
|
|
80
79
|
next({
|
|
81
80
|
success: !stats.hasErrors(),
|
|
82
|
-
outfile:
|
|
81
|
+
outfile: (0, path_1.resolve)(context.root, normalizedOptions.outputPath, 'main.js'),
|
|
83
82
|
});
|
|
84
83
|
done();
|
|
85
84
|
});
|
|
@@ -103,7 +102,7 @@ function registerCleanupCallback(callback) {
|
|
|
103
102
|
async function executeTypeCheck(options, context) {
|
|
104
103
|
const projectConfiguration = context.projectGraph.nodes[context.projectName].data;
|
|
105
104
|
const result = await (0, js_1.runTypeCheck)({
|
|
106
|
-
workspaceRoot:
|
|
105
|
+
workspaceRoot: (0, path_1.resolve)(projectConfiguration.root),
|
|
107
106
|
tsConfigPath: options.tsConfig,
|
|
108
107
|
mode: 'noEmit',
|
|
109
108
|
});
|
|
@@ -1,28 +1,49 @@
|
|
|
1
|
-
import type { Mode } from '@rspack/core';
|
|
1
|
+
import type { DevTool, Mode } from '@rspack/core';
|
|
2
2
|
|
|
3
3
|
export interface RspackExecutorSchema {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
index?: string;
|
|
7
|
-
tsConfig?: string;
|
|
8
|
-
typeCheck?: boolean;
|
|
9
|
-
skipTypeChecking?: boolean;
|
|
10
|
-
outputPath?: string;
|
|
11
|
-
outputFileName?: string;
|
|
12
|
-
index?: string;
|
|
13
|
-
indexHtml?: string;
|
|
14
|
-
mode?: Mode;
|
|
15
|
-
watch?: boolean;
|
|
4
|
+
additionalEntryPoints?: AdditionalEntryPoint[];
|
|
5
|
+
assets?: Array<AssetGlobPattern | string>;
|
|
16
6
|
baseHref?: string;
|
|
7
|
+
buildLibsFromSource?: boolean;
|
|
17
8
|
deployUrl?: string;
|
|
18
|
-
|
|
19
|
-
rspackConfig: string;
|
|
20
|
-
optimization?: boolean | OptimizationOptions;
|
|
21
|
-
sourceMap?: boolean | string;
|
|
22
|
-
assets?: any[];
|
|
9
|
+
extractCss?: boolean;
|
|
23
10
|
extractLicenses?: boolean;
|
|
11
|
+
externalDependencies?: 'all' | 'none' | string[];
|
|
24
12
|
fileReplacements?: FileReplacement[];
|
|
13
|
+
generateIndexHtml?: boolean;
|
|
25
14
|
generatePackageJson?: boolean;
|
|
15
|
+
index?: string;
|
|
16
|
+
indexHtml?: string;
|
|
17
|
+
main?: string;
|
|
18
|
+
memoryLimit?: number;
|
|
19
|
+
mode?: Mode;
|
|
20
|
+
namedChunks?: boolean;
|
|
21
|
+
optimization?: boolean | OptimizationOptions;
|
|
22
|
+
outputFileName?: string;
|
|
23
|
+
outputHashing?: any;
|
|
24
|
+
outputPath?: string;
|
|
25
|
+
poll?: number;
|
|
26
|
+
polyfills?: string;
|
|
27
|
+
postcssConfig?: string;
|
|
28
|
+
progress?: boolean;
|
|
29
|
+
publicPath?: string;
|
|
30
|
+
rebaseRootRelative?: boolean;
|
|
31
|
+
rspackConfig: string;
|
|
32
|
+
runtimeChunk?: boolean;
|
|
33
|
+
scripts?: Array<ExtraEntryPointClass | string>;
|
|
34
|
+
skipTypeChecking?: boolean;
|
|
35
|
+
sourceMap?: boolean | DevTool;
|
|
36
|
+
standardRspackConfigFunction?: boolean;
|
|
37
|
+
statsJson?: boolean;
|
|
38
|
+
stylePreprocessorOptions?: any;
|
|
39
|
+
styles?: Array<ExtraEntryPointClass | string>;
|
|
40
|
+
target?: 'web' | 'node';
|
|
41
|
+
transformers?: TransformerEntry[];
|
|
42
|
+
tsConfig?: string;
|
|
43
|
+
typeCheck?: boolean;
|
|
44
|
+
verbose?: boolean;
|
|
45
|
+
vendorChunk?: boolean;
|
|
46
|
+
watch?: boolean;
|
|
26
47
|
}
|
|
27
48
|
|
|
28
49
|
export interface AssetGlobPattern {
|
|
@@ -129,6 +129,144 @@
|
|
|
129
129
|
"generatePackageJson": {
|
|
130
130
|
"type": "boolean",
|
|
131
131
|
"description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated."
|
|
132
|
+
},
|
|
133
|
+
"additionalEntryPoints": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"entryName": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"description": "Name of the additional entry file."
|
|
141
|
+
},
|
|
142
|
+
"entryPath": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"description": "Path to the additional entry file.",
|
|
145
|
+
"x-completion-type": "file",
|
|
146
|
+
"x-completion-glob": "**/*@(.js|.ts)"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"buildLibsFromSource": {
|
|
152
|
+
"type": "boolean",
|
|
153
|
+
"description": "Read buildable libraries from source instead of building them separately. If set to `false`, the `tsConfig` option must also be set to remap paths.",
|
|
154
|
+
"default": true
|
|
155
|
+
},
|
|
156
|
+
"extractCss": {
|
|
157
|
+
"type": "boolean",
|
|
158
|
+
"description": "Extract CSS into a `.css` file."
|
|
159
|
+
},
|
|
160
|
+
"externalDependencies": {
|
|
161
|
+
"oneOf": [
|
|
162
|
+
{
|
|
163
|
+
"type": "string",
|
|
164
|
+
"enum": ["none", "all"]
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"type": "array",
|
|
168
|
+
"items": {
|
|
169
|
+
"type": "string"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"description": "Dependencies to keep external to the bundle. (`all` (default), `none`, or an array of module names)"
|
|
174
|
+
},
|
|
175
|
+
"generateIndexHtml": {
|
|
176
|
+
"type": "boolean",
|
|
177
|
+
"description": "Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`."
|
|
178
|
+
},
|
|
179
|
+
"memoryLimit": {
|
|
180
|
+
"type": "number",
|
|
181
|
+
"description": "Memory limit for type checking service process in `MB`."
|
|
182
|
+
},
|
|
183
|
+
"namedChunks": {
|
|
184
|
+
"type": "boolean",
|
|
185
|
+
"description": "Names the produced bundles according to their entry file."
|
|
186
|
+
},
|
|
187
|
+
"outputHashing": {
|
|
188
|
+
"type": "string",
|
|
189
|
+
"description": "Define the output filename cache-busting hashing mode.",
|
|
190
|
+
"enum": ["none", "all", "media", "bundles"]
|
|
191
|
+
},
|
|
192
|
+
"poll": {
|
|
193
|
+
"type": "number",
|
|
194
|
+
"description": "Enable and define the file watching poll time period."
|
|
195
|
+
},
|
|
196
|
+
"polyfills": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"description": "Polyfills to load before application",
|
|
199
|
+
"x-completion-type": "file",
|
|
200
|
+
"x-completion-glob": "**/*@(.js|.ts|.tsx)"
|
|
201
|
+
},
|
|
202
|
+
"postcssConfig": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"description": "Set a path to PostCSS config that applies to the app and all libs. Defaults to `undefined`, which auto-detects postcss.config.js files in each `app`/`lib` directory."
|
|
205
|
+
},
|
|
206
|
+
"progress": {
|
|
207
|
+
"type": "boolean",
|
|
208
|
+
"description": "Log progress to the console while building."
|
|
209
|
+
},
|
|
210
|
+
"publicPath": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"description": "Set a public path for assets resources with absolute paths."
|
|
213
|
+
},
|
|
214
|
+
"rebaseRootRelative": {
|
|
215
|
+
"type": "boolean",
|
|
216
|
+
"description": "Whether to rebase absolute path for assets in postcss cli resources."
|
|
217
|
+
},
|
|
218
|
+
"runtimeChunk": {
|
|
219
|
+
"type": "boolean",
|
|
220
|
+
"description": "Use a separate bundle containing the runtime."
|
|
221
|
+
},
|
|
222
|
+
"scripts": {
|
|
223
|
+
"type": "array",
|
|
224
|
+
"description": "External Scripts which will be included before the main application entry.",
|
|
225
|
+
"items": {
|
|
226
|
+
"$ref": "#/definitions/extraEntryPoint"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"standardRspackConfigFunction": {
|
|
230
|
+
"type": "boolean",
|
|
231
|
+
"description": "Set to true if the rspack config exports a standard rspack function, not an Nx-specific one. See: https://rspack.dev/config/",
|
|
232
|
+
"default": false
|
|
233
|
+
},
|
|
234
|
+
"statsJson": {
|
|
235
|
+
"type": "boolean",
|
|
236
|
+
"description": "Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' See: https://rspack.dev/guide/optimization/analysis"
|
|
237
|
+
},
|
|
238
|
+
"stylePreprocessorOptions": {
|
|
239
|
+
"description": "Options to pass to style preprocessors.",
|
|
240
|
+
"type": "object",
|
|
241
|
+
"properties": {
|
|
242
|
+
"includePaths": {
|
|
243
|
+
"description": "Paths to include. Paths will be resolved to project root.",
|
|
244
|
+
"type": "array",
|
|
245
|
+
"items": {
|
|
246
|
+
"type": "string"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"additionalProperties": false
|
|
251
|
+
},
|
|
252
|
+
"styles": {
|
|
253
|
+
"type": "array",
|
|
254
|
+
"description": "External Styles which will be included with the application",
|
|
255
|
+
"items": {
|
|
256
|
+
"$ref": "#/definitions/extraEntryPoint"
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
"transformers": {
|
|
260
|
+
"type": "array",
|
|
261
|
+
"description": "List of TypeScript Compiler Transfomers Plugins.",
|
|
262
|
+
"aliases": ["tsPlugins"],
|
|
263
|
+
"items": {
|
|
264
|
+
"$ref": "#/definitions/transformerPattern"
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
"vendorChunk": {
|
|
268
|
+
"type": "boolean",
|
|
269
|
+
"description": "Use a separate bundle containing only vendor libraries."
|
|
132
270
|
}
|
|
133
271
|
},
|
|
134
272
|
"required": ["rspackConfig"],
|
|
@@ -170,6 +308,59 @@
|
|
|
170
308
|
"type": "string"
|
|
171
309
|
}
|
|
172
310
|
]
|
|
311
|
+
},
|
|
312
|
+
"extraEntryPoint": {
|
|
313
|
+
"oneOf": [
|
|
314
|
+
{
|
|
315
|
+
"type": "object",
|
|
316
|
+
"properties": {
|
|
317
|
+
"input": {
|
|
318
|
+
"type": "string",
|
|
319
|
+
"description": "The file to include.",
|
|
320
|
+
"x-completion-type": "file",
|
|
321
|
+
"x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)"
|
|
322
|
+
},
|
|
323
|
+
"bundleName": {
|
|
324
|
+
"type": "string",
|
|
325
|
+
"description": "The bundle name for this extra entry point."
|
|
326
|
+
},
|
|
327
|
+
"inject": {
|
|
328
|
+
"type": "boolean",
|
|
329
|
+
"description": "If the bundle will be referenced in the HTML file.",
|
|
330
|
+
"default": true
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"additionalProperties": false,
|
|
334
|
+
"required": ["input"]
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"type": "string",
|
|
338
|
+
"description": "The file to include.",
|
|
339
|
+
"x-completion-type": "file",
|
|
340
|
+
"x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)"
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
},
|
|
344
|
+
"transformerPattern": {
|
|
345
|
+
"oneOf": [
|
|
346
|
+
{
|
|
347
|
+
"type": "string"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"type": "object",
|
|
351
|
+
"properties": {
|
|
352
|
+
"name": {
|
|
353
|
+
"type": "string"
|
|
354
|
+
},
|
|
355
|
+
"options": {
|
|
356
|
+
"type": "object",
|
|
357
|
+
"additionalProperties": true
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
"additionalProperties": false,
|
|
361
|
+
"required": ["name"]
|
|
362
|
+
}
|
|
363
|
+
]
|
|
173
364
|
}
|
|
174
365
|
}
|
|
175
366
|
}
|
|
@@ -59,11 +59,7 @@ function applyNxIndependentConfig(options, config) {
|
|
|
59
59
|
// So to mitigate this we enable in memory caching when target is Node and in watch mode.
|
|
60
60
|
config.cache = options.target === 'node' && options.watch ? true : undefined;
|
|
61
61
|
config.devtool =
|
|
62
|
-
options.sourceMap === '
|
|
63
|
-
? 'hidden-source-map'
|
|
64
|
-
: options.sourceMap
|
|
65
|
-
? 'source-map'
|
|
66
|
-
: false;
|
|
62
|
+
options.sourceMap === true ? 'source-map' : options.sourceMap;
|
|
67
63
|
config.output = {
|
|
68
64
|
...(config.output ?? {}),
|
|
69
65
|
libraryTarget: config.output?.libraryTarget ??
|
|
@@ -70,13 +70,6 @@ function applyWebConfig(options, config = {}, { useNormalizedEntry, } = {}) {
|
|
|
70
70
|
const resolvedPath = style.input.startsWith('.')
|
|
71
71
|
? style.input
|
|
72
72
|
: (0, path_1.resolve)(options.root, style.input);
|
|
73
|
-
// Add style entry points.
|
|
74
|
-
if (entries[style.bundleName]) {
|
|
75
|
-
entries[style.bundleName].import.push(resolvedPath);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
entries[style.bundleName] = { import: [resolvedPath] };
|
|
79
|
-
}
|
|
80
73
|
// Add global css paths.
|
|
81
74
|
globalStylePaths.push(resolvedPath);
|
|
82
75
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Mode } from '@rspack/core';
|
|
1
|
+
import type { DevTool, Mode } from '@rspack/core';
|
|
2
2
|
import type { ProjectGraph } from '@nx/devkit';
|
|
3
3
|
import type { AssetGlob } from '@nx/js/src/utils/assets/assets';
|
|
4
4
|
export interface SvgrOptions {
|
|
@@ -171,7 +171,7 @@ export interface NxAppRspackPluginOptions {
|
|
|
171
171
|
/**
|
|
172
172
|
* Generate source maps.
|
|
173
173
|
*/
|
|
174
|
-
sourceMap?: boolean |
|
|
174
|
+
sourceMap?: boolean | DevTool;
|
|
175
175
|
/**
|
|
176
176
|
* When `true`, `process.env.NODE_ENV` will be excluded from the bundle. Useful for building a web application to run in a Node environment.
|
|
177
177
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { Compiler, MultiCompiler } from '@rspack/core';
|
|
3
|
-
import {
|
|
4
|
-
export declare function createCompiler(options:
|
|
3
|
+
import { NormalizedRspackExecutorSchema } from '../executors/rspack/schema';
|
|
4
|
+
export declare function createCompiler(options: NormalizedRspackExecutorSchema & {
|
|
5
5
|
devServer?: any;
|
|
6
6
|
}, context: ExecutorContext): Promise<Compiler | MultiCompiler>;
|
|
7
7
|
export declare function isMultiCompiler(compiler: Compiler | MultiCompiler): compiler is MultiCompiler;
|
|
@@ -1,52 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.createCompiler = createCompiler;
|
|
27
4
|
exports.isMultiCompiler = isMultiCompiler;
|
|
28
5
|
const core_1 = require("@rspack/core");
|
|
29
|
-
const
|
|
6
|
+
const config_1 = require("../executors/rspack/lib/config");
|
|
30
7
|
async function createCompiler(options, context) {
|
|
31
|
-
const
|
|
32
|
-
let userDefinedConfig = {};
|
|
33
|
-
if (options.tsConfig) {
|
|
34
|
-
userDefinedConfig = (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)(pathToConfig, options.tsConfig);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
userDefinedConfig = await Promise.resolve(`${pathToConfig}`).then(s => __importStar(require(s))).then((x) => x.default || x);
|
|
38
|
-
}
|
|
39
|
-
if (typeof userDefinedConfig.then === 'function') {
|
|
40
|
-
userDefinedConfig = await userDefinedConfig;
|
|
41
|
-
}
|
|
42
|
-
let config = {};
|
|
43
|
-
if (typeof userDefinedConfig === 'function') {
|
|
44
|
-
config = await userDefinedConfig({ devServer: options.devServer }, { options, context });
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
config = userDefinedConfig;
|
|
48
|
-
config.devServer ??= options.devServer;
|
|
49
|
-
}
|
|
8
|
+
const config = await (0, config_1.getRspackConfigs)(options, context);
|
|
50
9
|
validateConfig(config);
|
|
51
10
|
return (0, core_1.rspack)(config);
|
|
52
11
|
}
|
|
@@ -54,10 +13,12 @@ function isMultiCompiler(compiler) {
|
|
|
54
13
|
return 'compilers' in compiler;
|
|
55
14
|
}
|
|
56
15
|
function validateConfig(config) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
16
|
+
[config].flat().forEach((config) => {
|
|
17
|
+
if (!config.entry) {
|
|
18
|
+
throw new Error('Entry is required. Please set the `main` option in the executor or the `entry` property in the rspack config.');
|
|
19
|
+
}
|
|
20
|
+
if (!config.output) {
|
|
21
|
+
throw new Error('Output is required. Please set the `outputPath` option in the executor or the `output` property in the rspack config.');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
63
24
|
}
|
|
@@ -13,6 +13,9 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
|
13
13
|
return (config, { context }) => {
|
|
14
14
|
config.target = 'async-node';
|
|
15
15
|
config.output.uniqueName = options.name;
|
|
16
|
+
config.output.library = {
|
|
17
|
+
type: 'commonjs-module',
|
|
18
|
+
};
|
|
16
19
|
config.optimization = {
|
|
17
20
|
...(config.optimization ?? {}),
|
|
18
21
|
runtimeChunk: false,
|
|
@@ -28,6 +31,10 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
|
28
31
|
...sharedDependencies,
|
|
29
32
|
},
|
|
30
33
|
isServer: true,
|
|
34
|
+
library: {
|
|
35
|
+
type: 'commonjs-module',
|
|
36
|
+
},
|
|
37
|
+
remoteType: 'script',
|
|
31
38
|
/**
|
|
32
39
|
* Apply user-defined config overrides
|
|
33
40
|
*/
|