@rspack/cli 0.3.8 → 0.3.9

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.
Files changed (2) hide show
  1. package/dist/rspack-cli.js +40 -4
  2. package/package.json +3 -3
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -15,6 +38,7 @@ const core_1 = require("@rspack/core");
15
38
  const options_1 = require("./utils/options");
16
39
  const loadConfig_1 = require("./utils/loadConfig");
17
40
  const findConfig_1 = __importDefault(require("./utils/findConfig"));
41
+ const rspackCore = __importStar(require("@rspack/core"));
18
42
  const path_1 = __importDefault(require("path"));
19
43
  const defaultEntry = "src/index";
20
44
  class RspackCLI {
@@ -92,7 +116,7 @@ class RspackCLI {
92
116
  let isBuild = command === "build";
93
117
  let isServe = command === "serve";
94
118
  const internalBuildConfig = async (item) => {
95
- var _a, _b;
119
+ var _a;
96
120
  if (options.entry) {
97
121
  item.entry = {
98
122
  main: options.entry.map(x => path_1.default.resolve(process.cwd(), x))[0] // Fix me when entry supports array
@@ -138,7 +162,18 @@ class RspackCLI {
138
162
  }
139
163
  item.builtins = item.builtins || {};
140
164
  if (isServe) {
141
- item.builtins.progress = (_b = item.builtins.progress) !== null && _b !== void 0 ? _b : true;
165
+ let installed = (item.plugins || (item.plugins = [])).find(item => item instanceof rspackCore.ProgressPlugin);
166
+ let o;
167
+ if (!installed &&
168
+ (o =
169
+ item.builtins.progress && typeof item.builtins.progress === "object"
170
+ ? item.builtins.progress
171
+ : item.builtins.progress === true
172
+ ? {}
173
+ : undefined)) {
174
+ (item.plugins || (item.plugins = [])).push(new rspackCore.ProgressPlugin(o));
175
+ }
176
+ delete item.builtins.progress;
142
177
  }
143
178
  // no emit assets when run dev server, it will use node_binding api get file content
144
179
  if (typeof item.builtins.noEmitAssets === "undefined") {
@@ -151,11 +186,12 @@ class RspackCLI {
151
186
  // See source: https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/WebpackOptionsApply.js#L563
152
187
  // When mode is set to 'none', optimization.nodeEnv defaults to false.
153
188
  if (item.mode !== "none") {
154
- item.builtins.define = {
189
+ (item.plugins || (item.plugins = [])).push(new rspackCore.DefinePlugin({
155
190
  // User defined `process.env.NODE_ENV` always has highest priority than default define
156
191
  "process.env.NODE_ENV": JSON.stringify(item.mode),
157
192
  ...item.builtins.define
158
- };
193
+ }));
194
+ delete item.builtins.define;
159
195
  }
160
196
  if (typeof item.stats === "undefined") {
161
197
  item.stats = { preset: "errors-warnings", timings: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/cli",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "license": "MIT",
5
5
  "description": "CLI for rspack",
6
6
  "bin": {
@@ -37,8 +37,8 @@
37
37
  "semver": "6.3.1",
38
38
  "webpack-bundle-analyzer": "4.6.1",
39
39
  "yargs": "17.6.2",
40
- "@rspack/core": "0.3.8",
41
- "@rspack/dev-server": "0.3.8"
40
+ "@rspack/core": "0.3.9",
41
+ "@rspack/dev-server": "0.3.9"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "rimraf dist/ && tsc -b ./tsconfig.build.json --force",