@nx/rspack 20.0.0-beta.4 → 20.0.0-beta.6
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/migrations.json +1 -25
- package/package.json +5 -6
- package/src/generators/application/application.js +3 -1
- package/src/generators/application/lib/normalize-options.d.ts +1 -3
- package/src/generators/application/lib/normalize-options.js +8 -20
- package/src/generators/application/schema.d.ts +2 -2
- package/src/generators/application/schema.json +10 -11
- package/src/generators/configuration/configuration.js +2 -0
- package/src/generators/init/init.js +2 -0
- package/src/generators/preset/preset.js +1 -0
- package/src/utils/module-federation/remotes.js +11 -4
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +1 -1
- package/src/utils/module-federation/with-module-federation/with-module-federation.js +1 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
package/migrations.json
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generators": {
|
|
3
|
-
"update-16-0-0-add-nx-packages": {
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "16.0.0-beta.1",
|
|
6
|
-
"description": "Replace @nrwl/rspack with @nx/rspack",
|
|
7
|
-
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
-
}
|
|
9
|
-
},
|
|
2
|
+
"generators": {},
|
|
10
3
|
"packageJsonUpdates": {
|
|
11
|
-
"16.1.3": {
|
|
12
|
-
"version": "16.1.3-beta.0",
|
|
13
|
-
"packages": {
|
|
14
|
-
"@rspack/core": {
|
|
15
|
-
"version": "~0.1.12",
|
|
16
|
-
"alwaysAddToPackageJson": false
|
|
17
|
-
},
|
|
18
|
-
"@rspack/dev-server": {
|
|
19
|
-
"version": "~0.1.12",
|
|
20
|
-
"alwaysAddToPackageJson": false
|
|
21
|
-
},
|
|
22
|
-
"@rspack/plugin-minify": {
|
|
23
|
-
"version": "~0.1.12",
|
|
24
|
-
"alwaysAddToPackageJson": false
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
4
|
"18.1.0": {
|
|
29
5
|
"version": "18.1.0-beta.0",
|
|
30
6
|
"packages": {
|
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.0.0-beta.
|
|
4
|
+
"version": "20.0.0-beta.6",
|
|
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.0.0-beta.
|
|
28
|
-
"@nx/devkit": "20.0.0-beta.
|
|
29
|
-
"@nx/eslint": "20.0.0-beta.
|
|
27
|
+
"@nx/js": "20.0.0-beta.6",
|
|
28
|
+
"@nx/devkit": "20.0.0-beta.6",
|
|
29
|
+
"@nx/eslint": "20.0.0-beta.6",
|
|
30
30
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
31
31
|
"less-loader": "11.1.0",
|
|
32
32
|
"license-webpack-plugin": "^4.0.2",
|
|
@@ -36,8 +36,7 @@
|
|
|
36
36
|
"@rspack/core": "^1.0.4",
|
|
37
37
|
"@rspack/plugin-react-refresh": "^1.0.0",
|
|
38
38
|
"@rspack/plugin-minify": "^0.7.5",
|
|
39
|
-
"chalk": "~4.1.0"
|
|
40
|
-
"@nrwl/rspack": "20.0.0-beta.4"
|
|
39
|
+
"chalk": "~4.1.0"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
42
|
"@module-federation/enhanced": "~0.6.0",
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
7
|
const package_json_1 = require("nx/package.json");
|
|
7
8
|
const configuration_1 = tslib_1.__importDefault(require("../configuration/configuration"));
|
|
8
9
|
const init_1 = tslib_1.__importDefault(require("../init/init"));
|
|
9
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
10
11
|
async function default_1(tree, _options) {
|
|
12
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'rspack', 'application');
|
|
11
13
|
const tasks = [];
|
|
12
14
|
const initTask = await (0, init_1.default)(tree, {
|
|
13
15
|
..._options,
|
|
@@ -16,7 +18,7 @@ async function default_1(tree, _options) {
|
|
|
16
18
|
addPlugin: false,
|
|
17
19
|
});
|
|
18
20
|
tasks.push(initTask);
|
|
19
|
-
const options = (0, normalize_options_1.normalizeOptions)(tree, _options);
|
|
21
|
+
const options = await (0, normalize_options_1.normalizeOptions)(tree, _options);
|
|
20
22
|
options.style ??= 'css';
|
|
21
23
|
if (options.framework === 'nest') {
|
|
22
24
|
const { applicationGenerator: nestAppGenerator } = (0, devkit_1.ensurePackage)('@nx/nest', package_json_1.version);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { ApplicationGeneratorSchema, NormalizedSchema } from '../schema';
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function normalizeProjectName(options: ApplicationGeneratorSchema): string;
|
|
5
|
-
export declare function normalizeOptions(host: Tree, options: ApplicationGeneratorSchema): NormalizedSchema;
|
|
3
|
+
export declare function normalizeOptions(host: Tree, options: ApplicationGeneratorSchema): Promise<NormalizedSchema>;
|
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeDirectory = normalizeDirectory;
|
|
4
|
-
exports.normalizeProjectName = normalizeProjectName;
|
|
5
3
|
exports.normalizeOptions = normalizeOptions;
|
|
6
4
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return normalizeDirectory(options).replace(new RegExp('/', 'g'), '-');
|
|
15
|
-
}
|
|
16
|
-
function normalizeOptions(host, options) {
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
+
async function normalizeOptions(host, options) {
|
|
7
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
8
|
+
const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
9
|
+
...options,
|
|
10
|
+
projectType: 'application',
|
|
11
|
+
});
|
|
17
12
|
// --monorepo takes precedence over --rootProject
|
|
18
13
|
// This won't be needed once we add --bundler=rspack to the @nx/react:app preset
|
|
19
14
|
const rootProject = !options.monorepo && options.rootProject;
|
|
20
|
-
const appDirectory = normalizeDirectory(options);
|
|
21
|
-
const appProjectName = normalizeProjectName(options);
|
|
22
15
|
const e2eProjectName = options.rootProject
|
|
23
16
|
? 'e2e'
|
|
24
|
-
: `${(0, devkit_1.names)(
|
|
25
|
-
const { layoutDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
|
26
|
-
const appsDir = layoutDirectory ?? (0, devkit_1.getWorkspaceLayout)(host).appsDir;
|
|
27
|
-
const appProjectRoot = rootProject
|
|
28
|
-
? '.'
|
|
29
|
-
: (0, devkit_1.normalizePath)(`${appsDir}/${appDirectory}`);
|
|
17
|
+
: `${(0, devkit_1.names)(appProjectName).fileName}-e2e`;
|
|
30
18
|
const normalized = {
|
|
31
19
|
...options,
|
|
32
20
|
rootProject,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export interface ApplicationGeneratorSchema {
|
|
2
|
-
|
|
2
|
+
directory: string;
|
|
3
|
+
name?: string;
|
|
3
4
|
framework?: Framework;
|
|
4
5
|
style: 'css' | 'scss' | 'less' | 'styl';
|
|
5
6
|
unitTestRunner?: 'none' | 'jest';
|
|
6
7
|
e2eTestRunner?: 'none' | 'cypress';
|
|
7
|
-
directory?: string;
|
|
8
8
|
tags?: string;
|
|
9
9
|
rootProject?: boolean;
|
|
10
10
|
monorepo?: boolean;
|
|
@@ -6,21 +6,24 @@
|
|
|
6
6
|
"description": "React + Rspack application generator.",
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
|
-
"command": "nx g app myapp
|
|
9
|
+
"command": "nx g app myorg/myapp",
|
|
10
10
|
"description": "Generate `apps/myorg/myapp` and `apps/myorg/myapp-e2e`"
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
13
|
"properties": {
|
|
14
|
-
"
|
|
15
|
-
"description": "The name of the application.",
|
|
14
|
+
"directory": {
|
|
16
15
|
"type": "string",
|
|
16
|
+
"description": "The directory to nest the app under.",
|
|
17
17
|
"$default": {
|
|
18
18
|
"$source": "argv",
|
|
19
19
|
"index": 0
|
|
20
20
|
},
|
|
21
|
-
"x-prompt": "What
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
"x-prompt": "What directory would you like to use for the application?"
|
|
22
|
+
},
|
|
23
|
+
"name": {
|
|
24
|
+
"description": "The name of the application.",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"pattern": "^[a-zA-Z].*$"
|
|
24
27
|
},
|
|
25
28
|
"framework": {
|
|
26
29
|
"type": "string",
|
|
@@ -75,10 +78,6 @@
|
|
|
75
78
|
"enum": ["none", "cypress"],
|
|
76
79
|
"default": "cypress"
|
|
77
80
|
},
|
|
78
|
-
"directory": {
|
|
79
|
-
"type": "string",
|
|
80
|
-
"description": "The directory to nest the app under."
|
|
81
|
-
},
|
|
82
81
|
"tags": {
|
|
83
82
|
"type": "string",
|
|
84
83
|
"description": "Add tags to the application (used for linting).",
|
|
@@ -94,5 +93,5 @@
|
|
|
94
93
|
"x-priority": "internal"
|
|
95
94
|
}
|
|
96
95
|
},
|
|
97
|
-
"required": ["
|
|
96
|
+
"required": ["directory"]
|
|
98
97
|
}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.configurationGenerator = configurationGenerator;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
7
|
const generator_utils_1 = require("../../utils/generator-utils");
|
|
7
8
|
const create_ts_config_1 = require("../application/lib/create-ts-config");
|
|
8
9
|
const init_1 = tslib_1.__importDefault(require("../init/init"));
|
|
9
10
|
async function configurationGenerator(tree, options) {
|
|
11
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'rspack', 'configuration');
|
|
10
12
|
const task = await (0, init_1.default)(tree, {
|
|
11
13
|
...options,
|
|
12
14
|
// TODO: Crystalize the default rspack.config.js file.
|
|
@@ -5,9 +5,11 @@ exports.rspackInitGenerator = rspackInitGenerator;
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
8
9
|
const plugin_1 = require("../../../plugin");
|
|
9
10
|
const versions_1 = require("../../utils/versions");
|
|
10
11
|
async function rspackInitGenerator(tree, schema) {
|
|
12
|
+
(0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'rspack', 'init');
|
|
11
13
|
const tasks = [];
|
|
12
14
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
13
15
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
@@ -7,6 +7,7 @@ const application_1 = tslib_1.__importDefault(require("../application/applicatio
|
|
|
7
7
|
async function default_1(tree, options) {
|
|
8
8
|
const appTask = (0, application_1.default)(tree, {
|
|
9
9
|
...options,
|
|
10
|
+
directory: '.',
|
|
10
11
|
// Since `--style` is not passed down to custom preset, we're using individual flags for now.
|
|
11
12
|
style: options.sass
|
|
12
13
|
? 'scss'
|
|
@@ -15,7 +15,8 @@ function mapRemotes(remotes, remoteEntryExt, determineRemoteUrl) {
|
|
|
15
15
|
const mappedRemotes = {};
|
|
16
16
|
for (const remote of remotes) {
|
|
17
17
|
if (Array.isArray(remote)) {
|
|
18
|
-
|
|
18
|
+
const remoteName = normalizeRemoteName(remote[0]);
|
|
19
|
+
mappedRemotes[remoteName] = handleArrayRemote(remote, remoteEntryExt);
|
|
19
20
|
}
|
|
20
21
|
else if (typeof remote === 'string') {
|
|
21
22
|
mappedRemotes[remote] = handleStringRemote(remote, determineRemoteUrl);
|
|
@@ -25,7 +26,8 @@ function mapRemotes(remotes, remoteEntryExt, determineRemoteUrl) {
|
|
|
25
26
|
}
|
|
26
27
|
// Helper function to deal with remotes that are arrays
|
|
27
28
|
function handleArrayRemote(remote, remoteEntryExt) {
|
|
28
|
-
|
|
29
|
+
let [remoteName, remoteLocation] = remote;
|
|
30
|
+
remoteName = normalizeRemoteName(remoteName);
|
|
29
31
|
const remoteLocationExt = (0, path_1.extname)(remoteLocation);
|
|
30
32
|
// If remote location already has .js or .mjs extension
|
|
31
33
|
if (['.js', '.mjs'].includes(remoteLocationExt)) {
|
|
@@ -61,7 +63,8 @@ function mapRemotesForSSR(remotes, remoteEntryExt, determineRemoteUrl) {
|
|
|
61
63
|
const mappedRemotes = {};
|
|
62
64
|
for (const remote of remotes) {
|
|
63
65
|
if (Array.isArray(remote)) {
|
|
64
|
-
|
|
66
|
+
let [remoteName, remoteLocation] = remote;
|
|
67
|
+
remoteName = normalizeRemoteName(remoteName);
|
|
65
68
|
const remoteLocationExt = (0, path_1.extname)(remoteLocation);
|
|
66
69
|
mappedRemotes[remoteName] = `${remoteName}@${['.js', '.mjs'].includes(remoteLocationExt)
|
|
67
70
|
? remoteLocation
|
|
@@ -70,8 +73,12 @@ function mapRemotesForSSR(remotes, remoteEntryExt, determineRemoteUrl) {
|
|
|
70
73
|
: remoteLocation}/remoteEntry.${remoteEntryExt}`}`;
|
|
71
74
|
}
|
|
72
75
|
else if (typeof remote === 'string') {
|
|
73
|
-
|
|
76
|
+
const remoteName = normalizeRemoteName(remote);
|
|
77
|
+
mappedRemotes[remoteName] = `${remoteName}@${determineRemoteUrl(remote)}`;
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
return mappedRemotes;
|
|
77
81
|
}
|
|
82
|
+
function normalizeRemoteName(remote) {
|
|
83
|
+
return remote.replace(/-/g, '_');
|
|
84
|
+
}
|
|
@@ -20,7 +20,7 @@ async function withModuleFederationForSSR(options, configOverride) {
|
|
|
20
20
|
config.plugins.push(
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
22
22
|
new (require('@module-federation/enhanced/rspack').ModuleFederationPlugin)({
|
|
23
|
-
name: options.name,
|
|
23
|
+
name: options.name.replace(/-/g, '_'),
|
|
24
24
|
filename: 'remoteEntry.js',
|
|
25
25
|
exposes: options.exposes,
|
|
26
26
|
remotes: mappedRemotes,
|
|
@@ -33,7 +33,7 @@ async function withModuleFederation(options, configOverride) {
|
|
|
33
33
|
config.optimization.runtimeChunk = 'single';
|
|
34
34
|
}
|
|
35
35
|
config.plugins.push(new rspack_1.ModuleFederationPlugin({
|
|
36
|
-
name: options.name,
|
|
36
|
+
name: options.name.replace(/-/g, '_'),
|
|
37
37
|
filename: 'remoteEntry.js',
|
|
38
38
|
exposes: options.exposes,
|
|
39
39
|
remotes: mappedRemotes,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replacePackage;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
async function replacePackage(tree) {
|
|
7
|
-
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/rspack', '@nx/rspack');
|
|
8
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
9
|
-
}
|