@nx/rspack 23.1.0 → 23.1.1
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/src/plugins/utils/apply-base-config.js +3 -4
- package/dist/src/plugins/utils/apply-web-config.js +3 -3
- package/dist/src/plugins/utils/get-non-buildable-libs.js +14 -2
- package/dist/src/plugins/utils/plugins/postcss-cli-resources.js +8 -4
- package/dist/src/utils/create-compiler.d.ts +1 -1
- package/dist/src/utils/create-compiler.js +4 -2
- package/dist/src/utils/load-rspack-core.d.ts +2 -0
- package/dist/src/utils/load-rspack-core.js +10 -0
- package/package.json +7 -7
|
@@ -6,6 +6,7 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
6
6
|
const license_webpack_plugin_1 = require("license-webpack-plugin");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
8
|
const version_utils_1 = require("../../utils/version-utils");
|
|
9
|
+
const load_rspack_core_1 = require("../../utils/load-rspack-core");
|
|
9
10
|
const stats_json_plugin_1 = require("./plugins/stats-json-plugin");
|
|
10
11
|
const generate_package_json_plugin_1 = require("./plugins/generate-package-json-plugin");
|
|
11
12
|
const hash_format_1 = require("./hash-format");
|
|
@@ -36,10 +37,8 @@ function applyBaseConfig(options, config = {}, { useNormalizedEntry, compiler, }
|
|
|
36
37
|
options.progress ??= true;
|
|
37
38
|
options.outputHashing ??= 'all';
|
|
38
39
|
// Lazy-require avoids loading @rspack/core (pure ESM in v2) at module
|
|
39
|
-
// parse time, so Jest can still load this file.
|
|
40
|
-
const rspackCore = compiler
|
|
41
|
-
? compiler.rspack
|
|
42
|
-
: require('@rspack/core');
|
|
40
|
+
// parse time, so Jest can still load this file. See load-rspack-core.ts.
|
|
41
|
+
const rspackCore = (0, load_rspack_core_1.loadRspackCore)(compiler);
|
|
43
42
|
applyNxIndependentConfig(options, config, rspackCore);
|
|
44
43
|
// Some of the options only work during actual tasks, not when reading the rspack config during CreateNodes.
|
|
45
44
|
if (global.NX_GRAPH_CREATION)
|
|
@@ -8,15 +8,15 @@ const hash_format_1 = require("./hash-format");
|
|
|
8
8
|
const instantiate_script_plugins_1 = require("./instantiate-script-plugins");
|
|
9
9
|
const stylesheet_loaders_1 = require("./loaders/stylesheet-loaders");
|
|
10
10
|
const normalize_entry_1 = require("./normalize-entry");
|
|
11
|
+
const load_rspack_core_1 = require("../../utils/load-rspack-core");
|
|
11
12
|
function applyWebConfig(options, config = {}, { useNormalizedEntry, compiler, } = {}) {
|
|
12
13
|
if (global.NX_GRAPH_CREATION)
|
|
13
14
|
return;
|
|
14
15
|
// Prefer compiler.rspack when available; otherwise lazy-require
|
|
15
16
|
// @rspack/core (works on Node 22.12+ via require(esm), and keeps the
|
|
16
17
|
// file Jest-loadable since the require is inside the function body).
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
: require('@rspack/core');
|
|
18
|
+
// See load-rspack-core.ts.
|
|
19
|
+
const rspackCore = (0, load_rspack_core_1.loadRspackCore)(compiler);
|
|
20
20
|
const { CssExtractRspackPlugin, DefinePlugin, EnvironmentPlugin, HtmlRspackPlugin, LightningCssMinimizerRspackPlugin, } = rspackCore;
|
|
21
21
|
const cssExtractLoader = CssExtractRspackPlugin.loader;
|
|
22
22
|
// Defaults that was applied from executor schema previously.
|
|
@@ -16,12 +16,24 @@ function resolveConditionalExport(target) {
|
|
|
16
16
|
if (typeof target === 'string') {
|
|
17
17
|
return target;
|
|
18
18
|
}
|
|
19
|
+
// Fallback arrays: take the first non-empty target. Node resolves them in
|
|
20
|
+
// order on disk; for the allowlist any valid target marks the subpath.
|
|
21
|
+
if (Array.isArray(target)) {
|
|
22
|
+
for (const candidate of target) {
|
|
23
|
+
const resolved = resolveConditionalExport(candidate);
|
|
24
|
+
if (resolved) {
|
|
25
|
+
return resolved;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
19
30
|
if (typeof target === 'object' && target !== null) {
|
|
20
31
|
// Priority order for conditions
|
|
21
32
|
const conditions = ['development', 'import', 'require', 'default'];
|
|
22
33
|
for (const condition of conditions) {
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
const resolved = resolveConditionalExport(target[condition]);
|
|
35
|
+
if (resolved) {
|
|
36
|
+
return resolved;
|
|
25
37
|
}
|
|
26
38
|
}
|
|
27
39
|
}
|
|
@@ -4,7 +4,6 @@ exports.PostcssCliResources = PostcssCliResources;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const loader_utils_1 = require("loader-utils");
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
|
-
const url_1 = require("url");
|
|
8
7
|
function wrapUrl(url) {
|
|
9
8
|
let wrappedUrl;
|
|
10
9
|
const hasSingleQuotes = url.indexOf("'") >= 0;
|
|
@@ -80,14 +79,19 @@ function PostcssCliResources(options) {
|
|
|
80
79
|
// Separate URL query/hash from the file path before resolving
|
|
81
80
|
const [, filePath, urlSuffix] = inputUrl.match(/^([^?#]*)(.*)$/);
|
|
82
81
|
const resolvedPath = path.resolve(context, filePath.replace(/\\/g, '/'));
|
|
83
|
-
|
|
82
|
+
// Resolve a relative filesystem path, not a file:// URL pathname: on Windows the
|
|
83
|
+
// pathname is `/C:/...` (spaces as %20), which the resolver cannot find. Relative
|
|
84
|
+
// (not absolute) lets `resolve()`'s `./`-prefixed lookup succeed on the first try.
|
|
85
|
+
const resolveRequest = path
|
|
86
|
+
.relative(context, resolvedPath)
|
|
87
|
+
.replace(/\\/g, '/');
|
|
84
88
|
let hash = '';
|
|
85
89
|
let search = '';
|
|
86
90
|
if (urlSuffix) {
|
|
87
91
|
({ hash, search } = new URL(`file:///dummy${urlSuffix}`));
|
|
88
92
|
}
|
|
89
93
|
const resolver = (file, base) => new Promise((resolve, reject) => {
|
|
90
|
-
loader.resolve(base,
|
|
94
|
+
loader.resolve(base, file, (err, result) => {
|
|
91
95
|
if (err) {
|
|
92
96
|
reject(err);
|
|
93
97
|
return;
|
|
@@ -95,7 +99,7 @@ function PostcssCliResources(options) {
|
|
|
95
99
|
resolve(result);
|
|
96
100
|
});
|
|
97
101
|
});
|
|
98
|
-
const result = await resolve(
|
|
102
|
+
const result = await resolve(resolveRequest, context, resolver);
|
|
99
103
|
return new Promise((resolve, reject) => {
|
|
100
104
|
loader.fs.readFile(result, (err, content) => {
|
|
101
105
|
if (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import {
|
|
2
|
+
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
3
3
|
import { NormalizedRspackExecutorSchema } from '../executors/rspack/schema';
|
|
4
4
|
export declare function createCompiler(options: NormalizedRspackExecutorSchema & {
|
|
5
5
|
devServer?: any;
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCompiler = createCompiler;
|
|
4
4
|
exports.isMultiCompiler = isMultiCompiler;
|
|
5
|
-
const core_1 = require("@rspack/core");
|
|
6
5
|
const config_1 = require("../executors/rspack/lib/config");
|
|
6
|
+
const load_rspack_core_1 = require("./load-rspack-core");
|
|
7
7
|
async function createCompiler(options, context) {
|
|
8
8
|
const config = await (0, config_1.getRspackConfigs)(options, context);
|
|
9
9
|
if (!options.standardRspackConfigFunction) {
|
|
10
10
|
validateConfig(config);
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
// Lazy-loaded to avoid resolving @rspack/core (pure ESM) before a build runs; see load-rspack-core.ts.
|
|
13
|
+
const { rspack } = (0, load_rspack_core_1.loadRspackCore)();
|
|
14
|
+
return rspack(config);
|
|
13
15
|
}
|
|
14
16
|
function isMultiCompiler(compiler) {
|
|
15
17
|
return 'compilers' in compiler;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadRspackCore = loadRspackCore;
|
|
4
|
+
// @rspack/core v2 is pure ESM; lazy-require avoids resolving it before a Compiler exists.
|
|
5
|
+
function loadRspackCore(compiler) {
|
|
6
|
+
// Reuse the compiler's already-resolved module to avoid ending up with a second, possibly different copy.
|
|
7
|
+
return compiler
|
|
8
|
+
? compiler.rspack
|
|
9
|
+
: require('@rspack/core');
|
|
10
|
+
}
|
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": "23.1.
|
|
4
|
+
"version": "23.1.1",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -152,14 +152,14 @@
|
|
|
152
152
|
"tslib": "^2.3.0",
|
|
153
153
|
"webpack": "5.105.2",
|
|
154
154
|
"webpack-node-externals": "^3.0.0",
|
|
155
|
-
"@nx/devkit": "23.1.
|
|
156
|
-
"@nx/
|
|
157
|
-
"@nx/module-federation": "23.1.
|
|
158
|
-
"@nx/
|
|
155
|
+
"@nx/devkit": "23.1.1",
|
|
156
|
+
"@nx/web": "23.1.1",
|
|
157
|
+
"@nx/module-federation": "23.1.1",
|
|
158
|
+
"@nx/js": "23.1.1"
|
|
159
159
|
},
|
|
160
160
|
"devDependencies": {
|
|
161
|
-
"nx": "23.1.
|
|
162
|
-
"@nx/nest": "23.1.
|
|
161
|
+
"nx": "23.1.1",
|
|
162
|
+
"@nx/nest": "23.1.1"
|
|
163
163
|
},
|
|
164
164
|
"peerDependencies": {
|
|
165
165
|
"@rspack/cli": "^1.0.0 || ^2.0.0",
|