@nx/rspack 23.2.0-beta.11 → 23.2.0-beta.12
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/executors/rspack/schema.d.ts +1 -0
- package/dist/src/executors/rspack/schema.json +4 -0
- package/dist/src/generators/convert-webpack/convert-webpack.js +12 -0
- package/dist/src/plugins/plugin.js +5 -0
- package/dist/src/plugins/utils/get-css-module-local-ident.d.ts +1 -1
- package/dist/src/plugins/utils/get-css-module-local-ident.js +5 -2
- package/dist/src/plugins/utils/loaders/stylesheet-loaders.d.ts +1 -2
- package/dist/src/plugins/utils/loaders/stylesheet-loaders.js +1 -1
- package/dist/src/plugins/utils/models.d.ts +5 -0
- package/dist/src/utils/e2e-web-server-info-utils.js +5 -1
- package/dist/src/utils/resolve-user-defined-rspack-config.js +14 -0
- package/package.json +7 -7
|
@@ -7,6 +7,7 @@ export interface RspackExecutorSchema {
|
|
|
7
7
|
buildLibsFromSource?: boolean;
|
|
8
8
|
deployUrl?: string;
|
|
9
9
|
extractCss?: boolean;
|
|
10
|
+
cssModuleHashFunction?: string;
|
|
10
11
|
extractLicenses?: boolean;
|
|
11
12
|
externalDependencies?: 'all' | 'none' | string[];
|
|
12
13
|
fileReplacements?: FileReplacement[];
|
|
@@ -185,6 +185,10 @@
|
|
|
185
185
|
"type": "boolean",
|
|
186
186
|
"description": "Extract CSS into a `.css` file."
|
|
187
187
|
},
|
|
188
|
+
"cssModuleHashFunction": {
|
|
189
|
+
"type": "string",
|
|
190
|
+
"description": "Hash algorithm used to generate CSS module class names. Defaults to `md5`, which FIPS-restricted OpenSSL rejects. Changing it renames generated class names."
|
|
191
|
+
},
|
|
188
192
|
"externalDependencies": {
|
|
189
193
|
"oneOf": [
|
|
190
194
|
{
|
|
@@ -75,6 +75,18 @@ async function default_1(tree, options) {
|
|
|
75
75
|
target.executor = '@nx/rspack:module-federation-static-server';
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
if (webpackConfigsWithHelpersToConvert.length === 0 &&
|
|
79
|
+
webpackConfigsWithPluginsToConvert.length === 0) {
|
|
80
|
+
// Projects built by the inferred @nx/webpack/plugin target have no
|
|
81
|
+
// explicit webpack target to match, only a config file.
|
|
82
|
+
const webpackConfigPath = findWebpackConfigPath(tree, project.root);
|
|
83
|
+
if (webpackConfigPath) {
|
|
84
|
+
webpackConfigsWithPluginsToConvert.push([
|
|
85
|
+
webpackConfigPath,
|
|
86
|
+
webpackConfigPath.replace(/webpack(?!.*webpack)/, 'rspack'),
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
78
90
|
if (webpackConfigsWithHelpersToConvert.length === 0 &&
|
|
79
91
|
webpackConfigsWithPluginsToConvert.length === 0) {
|
|
80
92
|
console.error(`Project '${options.project}' does not have any webpack targets to convert.`);
|
|
@@ -102,6 +102,11 @@ async function createRspackTargets(configFilePath, projectRoot, options, context
|
|
|
102
102
|
args: ['--node-env=production'],
|
|
103
103
|
env,
|
|
104
104
|
},
|
|
105
|
+
configurations: {
|
|
106
|
+
development: {
|
|
107
|
+
args: ['--node-env=development'],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
105
110
|
cache: true,
|
|
106
111
|
dependsOn: [`^${options.buildTargetName}`],
|
|
107
112
|
inputs: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getCSSModuleLocalIdent(ctx: any, localIdentName: any, localName: any, options: any): any;
|
|
1
|
+
export declare function getCSSModuleLocalIdent(ctx: any, localIdentName: any, localName: any, options: any, hashFunction?: string): any;
|
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCSSModuleLocalIdent = getCSSModuleLocalIdent;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const loader_utils_1 = require("loader-utils");
|
|
6
|
-
function getCSSModuleLocalIdent(ctx, localIdentName, localName, options) {
|
|
6
|
+
function getCSSModuleLocalIdent(ctx, localIdentName, localName, options, hashFunction) {
|
|
7
7
|
// Use the filename or folder name, based on some uses the index.js / index.module.(css|scss|sass) project style
|
|
8
8
|
const fileNameOrFolder = ctx.resourcePath.match(/index\.module\.(css|scss|sass)$/)
|
|
9
9
|
? '[folder]'
|
|
10
10
|
: '[name]';
|
|
11
11
|
// Create a hash based on a the file location and class name. Will be unique across a project, and close to globally unique.
|
|
12
|
-
const hash = (0, loader_utils_1.getHashDigest)(path_1.posix.relative(ctx.rootContext, ctx.resourcePath) + localName,
|
|
12
|
+
const hash = (0, loader_utils_1.getHashDigest)(path_1.posix.relative(ctx.rootContext, ctx.resourcePath) + localName,
|
|
13
|
+
// md5 is unavailable under FIPS-restricted OpenSSL (nx#36829). Env var stays
|
|
14
|
+
// undocumented on purpose - `cssModuleHashFunction` is the documented option.
|
|
15
|
+
hashFunction || process.env.NX_CSS_MODULE_HASH_FUNCTION || 'md5', 'base64', 5);
|
|
13
16
|
// Use loaderUtils to find the file or folder name
|
|
14
17
|
const className = (0, loader_utils_1.interpolateName)(ctx, `${fileNameOrFolder}_${localName}__${hash}`, options);
|
|
15
18
|
// Remove the .module that appears in every classname when based on the file and replace all "." with "_".
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getCSSModuleLocalIdent } from '../get-css-module-local-ident';
|
|
2
1
|
interface PostcssOptions {
|
|
3
2
|
(loader: any): any;
|
|
4
3
|
config?: string;
|
|
@@ -11,7 +10,7 @@ export declare function getCommonLoadersForCssModules(options: any, includePaths
|
|
|
11
10
|
options: {
|
|
12
11
|
modules: {
|
|
13
12
|
mode: string;
|
|
14
|
-
getLocalIdent:
|
|
13
|
+
getLocalIdent: (ctx: any, localIdentName: any, localName: any, loaderOptions: any) => any;
|
|
15
14
|
namedExport: boolean;
|
|
16
15
|
exportLocalsConvention: string;
|
|
17
16
|
};
|
|
@@ -23,7 +23,7 @@ function getCommonLoadersForCssModules(options, includePaths, cssExtractLoader)
|
|
|
23
23
|
options: {
|
|
24
24
|
modules: {
|
|
25
25
|
mode: 'local',
|
|
26
|
-
getLocalIdent: get_css_module_local_ident_1.getCSSModuleLocalIdent,
|
|
26
|
+
getLocalIdent: (ctx, localIdentName, localName, loaderOptions) => (0, get_css_module_local_ident_1.getCSSModuleLocalIdent)(ctx, localIdentName, localName, loaderOptions, options.cssModuleHashFunction),
|
|
27
27
|
// css-loader 7 defaults namedExport to true, and to camel-case-only
|
|
28
28
|
// locals when it is off. Generated components import the default
|
|
29
29
|
// export and reference class names as authored, so pin both.
|
|
@@ -59,6 +59,11 @@ export interface NxAppRspackPluginOptions {
|
|
|
59
59
|
*/
|
|
60
60
|
buildLibsFromSource?: boolean;
|
|
61
61
|
commonChunk?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Hash algorithm used to generate CSS module class names. Defaults to `md5`,
|
|
64
|
+
* which FIPS-restricted OpenSSL rejects. Changing it renames generated class names.
|
|
65
|
+
*/
|
|
66
|
+
cssModuleHashFunction?: string;
|
|
62
67
|
/**
|
|
63
68
|
* The deploy path for the application. e.g. `/my-app/`
|
|
64
69
|
*/
|
|
@@ -8,7 +8,10 @@ async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, isPl
|
|
|
8
8
|
let e2ePort = e2ePortOverride ?? 4200;
|
|
9
9
|
const servePort = (0, internal_1.readTargetDefaultsForTarget)('serve', nxJson.targetDefaults)
|
|
10
10
|
?.options?.port;
|
|
11
|
-
|
|
11
|
+
// targetDefaults is a workspace-wide fallback, so it fills in only when the caller
|
|
12
|
+
// did not ask for a port. Letting it win over an explicit request would point e2e at
|
|
13
|
+
// a different port than the serve target the generator just wrote.
|
|
14
|
+
if (servePort && e2ePortOverride == null) {
|
|
12
15
|
e2ePort = servePort;
|
|
13
16
|
}
|
|
14
17
|
return (0, internal_1.getE2EWebServerInfo)(tree, projectName, {
|
|
@@ -22,5 +25,6 @@ async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, isPl
|
|
|
22
25
|
defaultE2EWebServerAddress: `http://localhost:${e2ePort}`,
|
|
23
26
|
defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
|
|
24
27
|
defaultE2EPort: e2ePort,
|
|
28
|
+
e2EPortIsExplicit: e2ePortOverride != null,
|
|
25
29
|
}, isPluginBeingAdded);
|
|
26
30
|
}
|
|
@@ -5,5 +5,19 @@ const internal_1 = require("@nx/devkit/internal");
|
|
|
5
5
|
async function resolveUserDefinedRspackConfig(path, tsConfig,
|
|
6
6
|
/** Skip require cache and return latest content */
|
|
7
7
|
reload = false) {
|
|
8
|
+
await preloadRspackCore();
|
|
8
9
|
return await (0, internal_1.loadConfigFile)(path);
|
|
9
10
|
}
|
|
11
|
+
// Node keeps @rspack/core cached un-instantiated when a config's require(esm)
|
|
12
|
+
// link fails (e.g. an extensionless `.ts` sibling import under native type
|
|
13
|
+
// stripping), and every later require('@rspack/core') then throws
|
|
14
|
+
// "Unexpected module status 0". See https://github.com/nrwl/nx/issues/36685
|
|
15
|
+
async function preloadRspackCore() {
|
|
16
|
+
try {
|
|
17
|
+
await new Function('return import("@rspack/core")')();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Not resolvable from here, or import() unavailable (e.g. under Jest).
|
|
21
|
+
// Whatever is actually wrong surfaces when the config itself loads.
|
|
22
|
+
}
|
|
23
|
+
}
|
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.2.0-beta.
|
|
4
|
+
"version": "23.2.0-beta.12",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -151,14 +151,14 @@
|
|
|
151
151
|
"tslib": "^2.3.0",
|
|
152
152
|
"webpack": "5.105.2",
|
|
153
153
|
"webpack-node-externals": "^3.0.0",
|
|
154
|
-
"@nx/
|
|
155
|
-
"@nx/js": "23.2.0-beta.
|
|
156
|
-
"@nx/
|
|
157
|
-
"@nx/
|
|
154
|
+
"@nx/web": "23.2.0-beta.12",
|
|
155
|
+
"@nx/js": "23.2.0-beta.12",
|
|
156
|
+
"@nx/devkit": "23.2.0-beta.12",
|
|
157
|
+
"@nx/module-federation": "23.2.0-beta.12"
|
|
158
158
|
},
|
|
159
159
|
"devDependencies": {
|
|
160
|
-
"nx": "23.2.0-beta.
|
|
161
|
-
"@nx/nest": "23.2.0-beta.
|
|
160
|
+
"nx": "23.2.0-beta.12",
|
|
161
|
+
"@nx/nest": "23.2.0-beta.12"
|
|
162
162
|
},
|
|
163
163
|
"peerDependencies": {
|
|
164
164
|
"@rspack/cli": "^1.0.0 || ^2.0.0",
|