@rspack/cli 0.6.4 → 0.6.5

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.
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PreviewCommand = void 0;
7
- const dev_server_1 = require("@rspack/dev-server");
8
7
  const options_1 = require("../utils/options");
9
8
  const core_1 = require("@rspack/core");
10
9
  const path_1 = __importDefault(require("path"));
@@ -20,6 +19,7 @@ class PreviewCommand {
20
19
  ...options
21
20
  }
22
21
  };
22
+ const { RspackDevServer } = await import("@rspack/dev-server");
23
23
  let config = await cli.loadConfig(rspackOptions);
24
24
  config = await getPreviewConfig(config, options);
25
25
  if (!Array.isArray(config)) {
@@ -33,7 +33,7 @@ class PreviewCommand {
33
33
  if (!compiler)
34
34
  return;
35
35
  try {
36
- const server = new dev_server_1.RspackDevServer(devServerOptions, compiler);
36
+ const server = new RspackDevServer(devServerOptions, compiler);
37
37
  await server.start();
38
38
  }
39
39
  catch (error) {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ServeCommand = void 0;
4
- const dev_server_1 = require("@rspack/dev-server");
5
4
  const options_1 = require("../utils/options");
6
5
  class ServeCommand {
7
6
  async apply(cli) {
@@ -15,6 +14,16 @@ class ServeCommand {
15
14
  ...options
16
15
  }
17
16
  };
17
+ /**
18
+ * webpack-dev-server will set `process.env.WEBPACK_SERVE` to true
19
+ * when its module is imported, so we have to lazy load the package
20
+ * to make sure the envvar is not set on build mode.
21
+ * when run in serve mode, we have to load the package before config
22
+ * module is imported so that the envvar `process.env.WEBPACK_SERVE`
23
+ * got in config module could be `true`.
24
+ * related issue: https://github.com/web-infra-dev/rspack/issues/6359
25
+ */
26
+ const { RspackDevServer } = await import("@rspack/dev-server");
18
27
  const compiler = await cli.createCompiler(rspackOptions, "serve");
19
28
  if (!compiler)
20
29
  return;
@@ -77,7 +86,7 @@ class ServeCommand {
77
86
  usedPorts.push(portNumber);
78
87
  }
79
88
  try {
80
- const server = new dev_server_1.RspackDevServer(devServerOptions, compiler);
89
+ const server = new RspackDevServer(devServerOptions, compiler);
81
90
  await server.start();
82
91
  servers.push(server);
83
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/cli",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "license": "MIT",
5
5
  "description": "CLI for rspack",
6
6
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "cross-env": "^7.0.3",
31
31
  "execa": "^5.0.0",
32
32
  "internal-ip": "6.2.0",
33
- "@rspack/core": "0.6.4"
33
+ "@rspack/core": "0.6.5"
34
34
  },
35
35
  "dependencies": {
36
36
  "@discoveryjs/json-ext": "^0.5.7",
@@ -41,7 +41,7 @@
41
41
  "semver": "6.3.1",
42
42
  "webpack-bundle-analyzer": "4.6.1",
43
43
  "yargs": "17.6.2",
44
- "@rspack/dev-server": "0.6.4"
44
+ "@rspack/dev-server": "0.6.5"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsc -b ./tsconfig.build.json",