@nx/rspack 20.0.0 → 20.0.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/README.md
CHANGED
|
@@ -66,52 +66,3 @@ npx nx@latest init
|
|
|
66
66
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
67
67
|
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
|
|
71
|
-
|
|
72
|
-
<hr>
|
|
73
|
-
|
|
74
|
-
# Nx: Smart, Fast and Extensible Build System
|
|
75
|
-
|
|
76
|
-
Nx is a next generation build system with first class monorepo support and powerful integrations.
|
|
77
|
-
|
|
78
|
-
This package is a Rspack plugin for Nx.
|
|
79
|
-
|
|
80
|
-
## Getting Started
|
|
81
|
-
|
|
82
|
-
Use `--preset=@nx/rspack` when creating new workspace.
|
|
83
|
-
|
|
84
|
-
e.g.
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npx create-nx-workspace@latest rspack-demo --preset=@nx/rspack
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
Now, you can go into the `rspack-demo` folder and start development.
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
cd rspack-demo
|
|
94
|
-
npm start
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
You can also run lint, test, and e2e scripts for the project.
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
npm run lint
|
|
101
|
-
npm run test
|
|
102
|
-
npm run e2e
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Existing workspaces
|
|
106
|
-
|
|
107
|
-
You can add Rspack to any existing Nx workspace.
|
|
108
|
-
|
|
109
|
-
First, install the plugin:
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
npm install --save-dev @nx/rspack
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Then, r
|
|
116
|
-
|
|
117
|
-
**Note:** You must restart the server if you make any changes to your library.
|
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.
|
|
4
|
+
"version": "20.0.2",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -24,19 +24,25 @@
|
|
|
24
24
|
"generators": "./generators.json",
|
|
25
25
|
"executors": "./executors.json",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nx/js": "20.0.
|
|
28
|
-
"@nx/devkit": "20.0.
|
|
29
|
-
"@nx/
|
|
27
|
+
"@nx/js": "20.0.2",
|
|
28
|
+
"@nx/devkit": "20.0.2",
|
|
29
|
+
"@nx/web": "20.0.2",
|
|
30
30
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
31
|
+
"enquirer": "~2.3.6",
|
|
32
|
+
"express": "^4.19.2",
|
|
33
|
+
"http-proxy-middleware": "^3.0.0",
|
|
31
34
|
"less-loader": "11.1.0",
|
|
32
35
|
"license-webpack-plugin": "^4.0.2",
|
|
33
36
|
"sass-loader": "^12.2.0",
|
|
34
37
|
"stylus-loader": "^7.1.0",
|
|
35
38
|
"postcss-loader": "^8.1.1",
|
|
36
39
|
"@rspack/core": "^1.0.4",
|
|
40
|
+
"@rspack/dev-server": "^1.0.4",
|
|
37
41
|
"@rspack/plugin-react-refresh": "^1.0.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
42
|
+
"chalk": "~4.1.0",
|
|
43
|
+
"tsconfig-paths": "^4.1.2",
|
|
44
|
+
"tslib": "^2.3.0",
|
|
45
|
+
"webpack-sources": "^3.2.3"
|
|
40
46
|
},
|
|
41
47
|
"peerDependencies": {
|
|
42
48
|
"@module-federation/enhanced": "~0.6.0",
|
|
@@ -24,9 +24,8 @@ async function* runExecutor(options, context) {
|
|
|
24
24
|
devServerConfig = {
|
|
25
25
|
...devServerConfig,
|
|
26
26
|
...firstCompiler.options.devServer,
|
|
27
|
-
port: devServerConfig.port,
|
|
28
27
|
};
|
|
29
|
-
const baseUrl = `http://localhost:${
|
|
28
|
+
const baseUrl = `http://localhost:${devServerConfig.port ?? 4200}`;
|
|
30
29
|
return yield* (0, async_iterable_1.createAsyncIterable)(({ next }) => {
|
|
31
30
|
const server = new dev_server_1.RspackDevServer({
|
|
32
31
|
...devServerConfig,
|
|
@@ -13,30 +13,31 @@ const path_1 = require("path");
|
|
|
13
13
|
*/
|
|
14
14
|
function mapRemotes(remotes, remoteEntryExt, determineRemoteUrl) {
|
|
15
15
|
const mappedRemotes = {};
|
|
16
|
-
for (const
|
|
17
|
-
if (Array.isArray(
|
|
18
|
-
const
|
|
19
|
-
mappedRemotes[
|
|
16
|
+
for (const nxRemoteProjectName of remotes) {
|
|
17
|
+
if (Array.isArray(nxRemoteProjectName)) {
|
|
18
|
+
const mfRemoteName = normalizeRemoteName(nxRemoteProjectName[0]);
|
|
19
|
+
mappedRemotes[mfRemoteName] = handleArrayRemote(nxRemoteProjectName, remoteEntryExt);
|
|
20
20
|
}
|
|
21
|
-
else if (typeof
|
|
22
|
-
|
|
21
|
+
else if (typeof nxRemoteProjectName === 'string') {
|
|
22
|
+
const mfRemoteName = normalizeRemoteName(nxRemoteProjectName);
|
|
23
|
+
mappedRemotes[mfRemoteName] = handleStringRemote(nxRemoteProjectName, determineRemoteUrl);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
return mappedRemotes;
|
|
26
27
|
}
|
|
27
28
|
// Helper function to deal with remotes that are arrays
|
|
28
29
|
function handleArrayRemote(remote, remoteEntryExt) {
|
|
29
|
-
let [
|
|
30
|
-
|
|
30
|
+
let [nxRemoteProjectName, remoteLocation] = remote;
|
|
31
|
+
const mfRemoteName = normalizeRemoteName(nxRemoteProjectName);
|
|
31
32
|
const remoteLocationExt = (0, path_1.extname)(remoteLocation);
|
|
32
33
|
// If remote location already has .js or .mjs extension
|
|
33
|
-
if (['.js', '.mjs'].includes(remoteLocationExt)) {
|
|
34
|
+
if (['.js', '.mjs', '.json'].includes(remoteLocationExt)) {
|
|
34
35
|
return remoteLocation;
|
|
35
36
|
}
|
|
36
37
|
const baseRemote = remoteLocation.endsWith('/')
|
|
37
38
|
? remoteLocation.slice(0, -1)
|
|
38
39
|
: remoteLocation;
|
|
39
|
-
const globalPrefix = `${
|
|
40
|
+
const globalPrefix = `${normalizeRemoteName(mfRemoteName)}@`;
|
|
40
41
|
// if the remote is defined with anything other than http then we assume it's a promise based remote
|
|
41
42
|
// In that case we should use what the user provides as the remote location
|
|
42
43
|
if (!remoteLocation.startsWith('promise new Promise')) {
|
|
@@ -47,9 +48,9 @@ function handleArrayRemote(remote, remoteEntryExt) {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
// Helper function to deal with remotes that are strings
|
|
50
|
-
function handleStringRemote(
|
|
51
|
-
const globalPrefix = `${
|
|
52
|
-
return `${globalPrefix}${determineRemoteUrl(
|
|
51
|
+
function handleStringRemote(nxRemoteProjectName, determineRemoteUrl) {
|
|
52
|
+
const globalPrefix = `${normalizeRemoteName(nxRemoteProjectName)}@`;
|
|
53
|
+
return `${globalPrefix}${determineRemoteUrl(nxRemoteProjectName)}`;
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
56
|
* Map remote names to a format that can be understood and used by Module
|
|
@@ -63,22 +64,22 @@ function mapRemotesForSSR(remotes, remoteEntryExt, determineRemoteUrl) {
|
|
|
63
64
|
const mappedRemotes = {};
|
|
64
65
|
for (const remote of remotes) {
|
|
65
66
|
if (Array.isArray(remote)) {
|
|
66
|
-
let [
|
|
67
|
-
|
|
67
|
+
let [nxRemoteProjectName, remoteLocation] = remote;
|
|
68
|
+
const mfRemoteName = normalizeRemoteName(nxRemoteProjectName);
|
|
68
69
|
const remoteLocationExt = (0, path_1.extname)(remoteLocation);
|
|
69
|
-
mappedRemotes[
|
|
70
|
+
mappedRemotes[mfRemoteName] = `${mfRemoteName}@${['.js', '.mjs'].includes(remoteLocationExt)
|
|
70
71
|
? remoteLocation
|
|
71
72
|
: `${remoteLocation.endsWith('/')
|
|
72
73
|
? remoteLocation.slice(0, -1)
|
|
73
74
|
: remoteLocation}/remoteEntry.${remoteEntryExt}`}`;
|
|
74
75
|
}
|
|
75
76
|
else if (typeof remote === 'string') {
|
|
76
|
-
const
|
|
77
|
-
mappedRemotes[
|
|
77
|
+
const mfRemoteName = normalizeRemoteName(remote);
|
|
78
|
+
mappedRemotes[mfRemoteName] = `${mfRemoteName}@${determineRemoteUrl(remote)}`;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
return mappedRemotes;
|
|
81
82
|
}
|
|
82
|
-
function normalizeRemoteName(
|
|
83
|
-
return
|
|
83
|
+
function normalizeRemoteName(nxRemoteProjectName) {
|
|
84
|
+
return nxRemoteProjectName.replace(/-/g, '_');
|
|
84
85
|
}
|
|
@@ -23,7 +23,7 @@ reload = false) {
|
|
|
23
23
|
const maybeCustomRspackConfig = require(path);
|
|
24
24
|
cleanupTranspiler();
|
|
25
25
|
// If the user provides a configuration in TS file
|
|
26
|
-
// then there are 3 cases for
|
|
26
|
+
// then there are 3 cases for exploring an object. The first one is:
|
|
27
27
|
// `module.exports = { ... }`. And the second one is:
|
|
28
28
|
// `export default { ... }`. The ESM format is compiled into:
|
|
29
29
|
// `{ default: { ... } }`
|
package/src/utils/with-nx.js
CHANGED
|
@@ -118,6 +118,10 @@ function withNx(_opts = {}) {
|
|
|
118
118
|
...(config.devServer ?? {}),
|
|
119
119
|
port: config.devServer?.port ?? 4200,
|
|
120
120
|
hot: config.devServer?.hot ?? true,
|
|
121
|
+
devMiddleware: {
|
|
122
|
+
...(config.devServer?.devMiddleware ?? {}),
|
|
123
|
+
stats: true,
|
|
124
|
+
},
|
|
121
125
|
},
|
|
122
126
|
module: {
|
|
123
127
|
rules: [
|
package/src/utils/with-web.js
CHANGED
|
@@ -97,8 +97,8 @@ function withWeb(opts = {}) {
|
|
|
97
97
|
? path.join(context.root, options.indexHtml)
|
|
98
98
|
: path.join(projectRoot, 'src/index.html'),
|
|
99
99
|
}),
|
|
100
|
-
new core_1.rspack.
|
|
101
|
-
|
|
100
|
+
new core_1.rspack.EnvironmentPlugin({
|
|
101
|
+
NODE_ENV: 'development',
|
|
102
102
|
}),
|
|
103
103
|
],
|
|
104
104
|
};
|