@rspack/cli 1.0.0-rc.2 → 1.0.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/commands/serve.js +32 -6
- package/package.json +6 -6
package/dist/commands/serve.js
CHANGED
|
@@ -4,7 +4,29 @@ exports.ServeCommand = void 0;
|
|
|
4
4
|
const options_1 = require("../utils/options");
|
|
5
5
|
class ServeCommand {
|
|
6
6
|
async apply(cli) {
|
|
7
|
-
cli.program.command(["serve", "server", "s", "dev"], "run the rspack dev server.", options_1.commonOptions
|
|
7
|
+
cli.program.command(["serve", "server", "s", "dev"], "run the rspack dev server.", yargs => (0, options_1.commonOptions)(yargs).options({
|
|
8
|
+
hot: {
|
|
9
|
+
coerce: arg => {
|
|
10
|
+
if (typeof arg === "boolean" || arg === "only") {
|
|
11
|
+
return arg;
|
|
12
|
+
}
|
|
13
|
+
if (arg === "false") {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
},
|
|
18
|
+
describe: "enables hot module replacement"
|
|
19
|
+
},
|
|
20
|
+
port: {
|
|
21
|
+
type: "number",
|
|
22
|
+
coerce: arg => (Number.isInteger(arg) ? arg : undefined),
|
|
23
|
+
describe: "allows to specify a port to use"
|
|
24
|
+
},
|
|
25
|
+
host: {
|
|
26
|
+
type: "string",
|
|
27
|
+
describe: "allows to specify a hostname to use"
|
|
28
|
+
}
|
|
29
|
+
}), async (options) => {
|
|
8
30
|
(0, options_1.setBuiltinEnvArg)((0, options_1.ensureEnvObject)(options), "SERVE", true);
|
|
9
31
|
const rspackOptions = {
|
|
10
32
|
...options,
|
|
@@ -44,7 +66,7 @@ class ServeCommand {
|
|
|
44
66
|
*/
|
|
45
67
|
for (const compiler of compilers) {
|
|
46
68
|
const devServer = (compiler.options.devServer ??= {});
|
|
47
|
-
devServer.hot
|
|
69
|
+
devServer.hot = options.hot ?? devServer.hot ?? true;
|
|
48
70
|
if (devServer.client !== false) {
|
|
49
71
|
if (devServer.client === true || devServer.client == null) {
|
|
50
72
|
devServer.client = {};
|
|
@@ -62,7 +84,9 @@ class ServeCommand {
|
|
|
62
84
|
/**
|
|
63
85
|
* Enable this to tell Rspack that we need to enable React Refresh by default
|
|
64
86
|
*/
|
|
65
|
-
result.hot
|
|
87
|
+
result.hot = options.hot ?? result.hot ?? true;
|
|
88
|
+
result.host = options.host || result.host;
|
|
89
|
+
result.port = options.port || result.port;
|
|
66
90
|
if (result.client !== false) {
|
|
67
91
|
if (result.client === true || result.client == null) {
|
|
68
92
|
result.client = {};
|
|
@@ -78,10 +102,12 @@ class ServeCommand {
|
|
|
78
102
|
const devServerOptions = result;
|
|
79
103
|
if (devServerOptions.port) {
|
|
80
104
|
const portNumber = Number(devServerOptions.port);
|
|
81
|
-
if (
|
|
82
|
-
|
|
105
|
+
if (!Number.isNaN(portNumber)) {
|
|
106
|
+
if (usedPorts.find(port => portNumber === port)) {
|
|
107
|
+
throw new Error("Unique ports must be specified for each devServer option in your rspack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config.");
|
|
108
|
+
}
|
|
109
|
+
usedPorts.push(portNumber);
|
|
83
110
|
}
|
|
84
|
-
usedPorts.push(portNumber);
|
|
85
111
|
}
|
|
86
112
|
try {
|
|
87
113
|
const server = new RspackDevServer(devServerOptions, compiler);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "CLI for rspack",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"@rspack/core": "^1.0.0-alpha || ^1.x"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/rechoir": "^0.6.1",
|
|
31
30
|
"@types/interpret": "^1.1.3",
|
|
31
|
+
"@types/rechoir": "^0.6.1",
|
|
32
32
|
"@types/semver": "^7.5.6",
|
|
33
33
|
"@types/webpack-bundle-analyzer": "^4.6.0",
|
|
34
34
|
"@types/yargs": "17.0.32",
|
|
35
|
-
"typescript": "5.0.2",
|
|
36
|
-
"ts-node": "^10.9.2",
|
|
37
35
|
"concat-stream": "^2.0.0",
|
|
38
36
|
"cross-env": "^7.0.3",
|
|
39
37
|
"execa": "^5.0.0",
|
|
40
38
|
"internal-ip": "6.2.0",
|
|
41
|
-
"
|
|
39
|
+
"ts-node": "^10.9.2",
|
|
40
|
+
"typescript": "5.0.2",
|
|
41
|
+
"@rspack/core": "1.0.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@discoveryjs/json-ext": "^0.5.7",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"semver": "^7.6.2",
|
|
50
50
|
"webpack-bundle-analyzer": "4.6.1",
|
|
51
51
|
"yargs": "17.6.2",
|
|
52
|
-
"@rspack/dev-server": "1.0.
|
|
52
|
+
"@rspack/dev-server": "1.0.1"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsc -b ./tsconfig.build.json",
|