@rsbuild/webpack 1.4.0 → 1.4.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.
@@ -822,24 +822,18 @@ export const __webpack_modules__ = {
822
822
  });
823
823
  let routes = route(fromModel);
824
824
  Object.keys(routes).forEach((toModel)=>{
825
- let fn = routes[toModel];
826
- convert[fromModel][toModel] = function(fn) {
827
- let wrappedFn = function(...args) {
828
- let arg0 = args[0];
829
- if (null == arg0) return arg0;
830
- arg0.length > 1 && (args = arg0);
831
- let result = fn(args);
832
- if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
833
- return result;
834
- };
835
- return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
836
- }(fn), convert[fromModel][toModel].raw = function(fn) {
837
- let wrappedFn = function(...args) {
838
- let arg0 = args[0];
839
- return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
840
- };
841
- return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
842
- }(fn);
825
+ let wrappedFn, wrappedFn1, fn = routes[toModel];
826
+ convert[fromModel][toModel] = (wrappedFn = function(...args) {
827
+ let arg0 = args[0];
828
+ if (null == arg0) return arg0;
829
+ arg0.length > 1 && (args = arg0);
830
+ let result = fn(args);
831
+ if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
832
+ return result;
833
+ }, 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn), convert[fromModel][toModel].raw = (wrappedFn1 = function(...args) {
834
+ let arg0 = args[0];
835
+ return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
836
+ }, 'conversion' in fn && (wrappedFn1.conversion = fn.conversion), wrappedFn1);
843
837
  });
844
838
  }), module.exports = convert;
845
839
  },
@@ -1,22 +1,26 @@
1
- export const __webpack_id__ = "560";
1
+ import picocolors from "picocolors";
2
+ import webpack from "webpack";
3
+ import { Console } from "node:console";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_stream__ from "stream";
5
+ export const __webpack_id__ = "502";
2
6
  export const __webpack_ids__ = [
3
- "560"
7
+ "502"
4
8
  ];
5
9
  export const __webpack_modules__ = {
6
10
  "./src/progress/ProgressPlugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
7
11
  __webpack_require__.d(__webpack_exports__, {
8
12
  ProgressPlugin: ()=>ProgressPlugin
9
13
  });
10
- var core_ = __webpack_require__("@rsbuild/core"), external_picocolors_ = __webpack_require__("picocolors"), external_webpack_ = __webpack_require__("webpack"), cli_truncate = __webpack_require__("../../../node_modules/.pnpm/cli-truncate@2.1.0/node_modules/cli-truncate/index.js"), cli_truncate_default = __webpack_require__.n(cli_truncate);
14
+ var core_ = __webpack_require__("@rsbuild/core"), cli_truncate = __webpack_require__("../../../node_modules/.pnpm/cli-truncate@2.1.0/node_modules/cli-truncate/index.js"), cli_truncate_default = __webpack_require__.n(cli_truncate);
11
15
  let clamp = (x, min, max)=>Math.min(max, Math.max(min, x)), defaultOption = {
12
16
  total: 100,
13
17
  current: 0,
14
18
  color: 'green',
15
19
  bgColor: 'gray',
16
- char: "\u2501",
20
+ char: '━',
17
21
  width: 25,
18
- buildIcon: "\u25EF",
19
- errorIcon: "\u2716",
22
+ buildIcon: '◯',
23
+ errorIcon: '✖',
20
24
  errorInfo: 'compile failed',
21
25
  message: '',
22
26
  done: !1,
@@ -27,7 +31,7 @@ export const __webpack_modules__ = {
27
31
  maxIdLen: 16,
28
32
  hasErrors: !1
29
33
  };
30
- var external_node_console_ = __webpack_require__("node:console"), build = __webpack_require__("../../../node_modules/.pnpm/patch-console@1.0.0/node_modules/patch-console/build/index.js"), build_default = __webpack_require__.n(build), ansi_escapes = __webpack_require__("../../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js"), ansi_escapes_default = __webpack_require__.n(ansi_escapes);
34
+ var build = __webpack_require__("../../../node_modules/.pnpm/patch-console@1.0.0/node_modules/patch-console/build/index.js"), build_default = __webpack_require__.n(build), ansi_escapes = __webpack_require__("../../../node_modules/.pnpm/ansi-escapes@4.3.2/node_modules/ansi-escapes/index.js"), ansi_escapes_default = __webpack_require__.n(ansi_escapes);
31
35
  let colorList = [
32
36
  'green',
33
37
  'cyan',
@@ -41,24 +45,22 @@ export const __webpack_modules__ = {
41
45
  prevOutput;
42
46
  destroyed = !1;
43
47
  constructor(){
44
- this.prevOutput = '', this.log = ((stream)=>{
45
- let previousLineCount = 0, previousOutput = '', render = (str)=>{
46
- let output = `${str}\n`;
47
- output !== previousOutput && (previousOutput = output, stream.write(ansi_escapes_default().eraseLines(previousLineCount) + output), previousLineCount = output.split('\n').length);
48
- };
49
- return render.clear = ()=>{
50
- stream.write(ansi_escapes_default().eraseLines(previousLineCount)), previousOutput = '', previousLineCount = 0;
51
- }, render.done = ()=>{
52
- previousOutput = '', previousLineCount = 0;
53
- }, render;
54
- })(process.stdout), console.Console = external_node_console_.Console, this.restore = build_default()((type, data)=>{
48
+ var stream;
49
+ let previousLineCount, previousOutput, render;
50
+ this.prevOutput = '', this.log = (stream = process.stdout, previousLineCount = 0, previousOutput = '', (render = (str)=>{
51
+ let output = `${str}\n`;
52
+ output !== previousOutput && (previousOutput = output, stream.write(ansi_escapes_default().eraseLines(previousLineCount) + output), previousLineCount = output.split('\n').length);
53
+ }).clear = ()=>{
54
+ stream.write(ansi_escapes_default().eraseLines(previousLineCount)), previousOutput = '', previousLineCount = 0;
55
+ }, render.done = ()=>{
56
+ previousOutput = '', previousLineCount = 0;
57
+ }, render), console.Console = Console, this.restore = build_default()((type, data)=>{
55
58
  this.writeToStd(type, data);
56
59
  });
57
60
  }
58
61
  update(state) {
59
62
  let index = this.states.findIndex((i)=>i.id === state.id);
60
- if (-1 === index) return void this.states.push(state);
61
- this.states[index] = state;
63
+ -1 === index ? this.states.push(state) : this.states[index] = state;
62
64
  }
63
65
  writeToStd(type = 'stdout', data) {
64
66
  this.log.clear(), data && ('stdout' === type ? process.stdout.write(data) : 'stderr' === type && process.stderr.write(data)), this.log(this.prevOutput);
@@ -67,33 +69,31 @@ export const __webpack_modules__ = {
67
69
  let maxIdLen = Math.max(...this.states.map((i)=>i.id?.length ?? 0)) + 2, { columns = 70 } = process.stdout;
68
70
  this.prevOutput = this.states.map((i, k)=>{
69
71
  let bar = ((option)=>{
70
- let mergedOptions = {
72
+ var id;
73
+ let left, right, mergedOptions = {
71
74
  ...defaultOption,
72
75
  ...option
73
- }, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor = external_picocolors_.default[color], backgroundColor = external_picocolors_.default[bgColor], doneColor = hasErrors ? external_picocolors_.default.red : barColor, idColor = done ? doneColor : barColor, id = mergedOptions.id ? idColor(((id, maxLen)=>{
74
- let left = Math.floor((maxLen - id.length) / 2), right = maxLen - left - id.length;
75
- return ' '.repeat(left) + id + ' '.repeat(right);
76
- })(mergedOptions.id, maxIdLen)) : '', { columns: terminalWidth = 70 } = process.stdout;
76
+ }, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor = picocolors[color], backgroundColor = picocolors[bgColor], doneColor = hasErrors ? picocolors.red : barColor, idColor = done ? doneColor : barColor, id1 = mergedOptions.id ? idColor((left = Math.floor((maxIdLen - (id = mergedOptions.id).length) / 2), right = maxIdLen - left - id.length, ' '.repeat(left) + id + ' '.repeat(right))) : '', { columns: terminalWidth = 70 } = process.stdout;
77
77
  if (done) {
78
78
  if (hasErrors) {
79
- let message = external_picocolors_.default.bold(doneColor(errorInfo));
79
+ let message = picocolors.bold(doneColor(errorInfo));
80
80
  return terminalWidth >= 40 ? [
81
81
  idColor(errorIcon),
82
- id,
82
+ id1,
83
83
  doneColor(`${space}${message}`)
84
84
  ].join('') : [
85
- id,
85
+ id1,
86
86
  doneColor(`${message}`)
87
87
  ].join('');
88
88
  }
89
89
  return '';
90
90
  }
91
- let msgStr = external_picocolors_.default[messageColor](cli_truncate_default()(message, messageWidth, {
91
+ let msgStr = picocolors[messageColor](cli_truncate_default()(message, messageWidth, {
92
92
  position: 'start'
93
- })), left = clamp(Math.floor(percent * width / 100), 0, width), right = clamp(width - left, 0, width), barStr = `${barColor(char.repeat(left))}${backgroundColor(char.repeat(right))}`, percentStr = `${percent.toString().padStart(3)}%`;
93
+ })), left1 = clamp(Math.floor(percent * width / 100), 0, width), right1 = clamp(width - left1, 0, width), barStr = `${barColor(char.repeat(left1))}${backgroundColor(char.repeat(right1))}`, percentStr = `${percent.toString().padStart(3)}%`;
94
94
  return terminalWidth >= 70 ? [
95
95
  idColor(buildIcon),
96
- id,
96
+ id1,
97
97
  space,
98
98
  barStr,
99
99
  space,
@@ -102,14 +102,14 @@ export const __webpack_modules__ = {
102
102
  msgStr
103
103
  ].join('') : terminalWidth >= 40 ? [
104
104
  idColor(buildIcon),
105
- id,
105
+ id1,
106
106
  space,
107
107
  barStr,
108
108
  space,
109
109
  percentStr
110
110
  ].join('') : [
111
111
  idColor(buildIcon),
112
- id,
112
+ id1,
113
113
  space,
114
114
  percentStr
115
115
  ].join('');
@@ -130,7 +130,7 @@ export const __webpack_modules__ = {
130
130
  this.log.clear(), this.log.done();
131
131
  }
132
132
  }();
133
- class ProgressPlugin extends external_webpack_.default.ProgressPlugin {
133
+ class ProgressPlugin extends webpack.ProgressPlugin {
134
134
  name = 'ProgressPlugin';
135
135
  id;
136
136
  hasCompileErrors = !1;
@@ -139,7 +139,7 @@ export const __webpack_modules__ = {
139
139
  constructor(options){
140
140
  let prevPercentage, prevPercentage1, { id = 'Rsbuild' } = options, nonTTYLogger = (prevPercentage = 0, {
141
141
  log: ({ id, done, current, hasErrors, compileTime })=>{
142
- let suffix = external_picocolors_.default.gray(`(${id})`);
142
+ let suffix = picocolors.gray(`(${id})`);
143
143
  if (done) {
144
144
  if (100 === prevPercentage) return;
145
145
  prevPercentage = 100, hasErrors ? core_.logger.error(`built failed in ${compileTime} ${suffix}`) : core_.logger.ready(`built in ${compileTime} ${suffix}`);
@@ -190,12 +190,15 @@ export const __webpack_modules__ = {
190
190
  this.hasCompileErrors = stat.hasErrors();
191
191
  let hrtime = process.hrtime(startTime), seconds = hrtime[0] + hrtime[1] / 1e9;
192
192
  if (this.compileTime = this.prettyTime(seconds), startTime = null, !this.hasCompileErrors) {
193
- let suffix = this.id ? external_picocolors_.default.gray(` (${this.id})`) : '';
193
+ let suffix = this.id ? picocolors.gray(` (${this.id})`) : '';
194
194
  core_.logger.ready(`built in ${this.compileTime} ${suffix}`);
195
195
  }
196
196
  }
197
197
  });
198
198
  }
199
199
  }
200
+ },
201
+ stream: function(module) {
202
+ module.exports = __WEBPACK_EXTERNAL_MODULE_stream__;
200
203
  }
201
204
  };
@@ -825,24 +825,18 @@ exports.ids = [
825
825
  });
826
826
  let routes = route(fromModel);
827
827
  Object.keys(routes).forEach((toModel)=>{
828
- let fn = routes[toModel];
829
- convert[fromModel][toModel] = function(fn) {
830
- let wrappedFn = function(...args) {
831
- let arg0 = args[0];
832
- if (null == arg0) return arg0;
833
- arg0.length > 1 && (args = arg0);
834
- let result = fn(args);
835
- if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
836
- return result;
837
- };
838
- return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
839
- }(fn), convert[fromModel][toModel].raw = function(fn) {
840
- let wrappedFn = function(...args) {
841
- let arg0 = args[0];
842
- return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
843
- };
844
- return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
845
- }(fn);
828
+ let wrappedFn, wrappedFn1, fn = routes[toModel];
829
+ convert[fromModel][toModel] = (wrappedFn = function(...args) {
830
+ let arg0 = args[0];
831
+ if (null == arg0) return arg0;
832
+ arg0.length > 1 && (args = arg0);
833
+ let result = fn(args);
834
+ if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
835
+ return result;
836
+ }, 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn), convert[fromModel][toModel].raw = (wrappedFn1 = function(...args) {
837
+ let arg0 = args[0];
838
+ return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
839
+ }, 'conversion' in fn && (wrappedFn1.conversion = fn.conversion), wrappedFn1);
846
840
  });
847
841
  }), module.exports = convert;
848
842
  },
@@ -12,10 +12,10 @@ exports.ids = [
12
12
  current: 0,
13
13
  color: 'green',
14
14
  bgColor: 'gray',
15
- char: "\u2501",
15
+ char: '━',
16
16
  width: 25,
17
- buildIcon: "\u25EF",
18
- errorIcon: "\u2716",
17
+ buildIcon: '◯',
18
+ errorIcon: '✖',
19
19
  errorInfo: 'compile failed',
20
20
  message: '',
21
21
  done: !1,
@@ -56,8 +56,7 @@ exports.ids = [
56
56
  }
57
57
  update(state) {
58
58
  let index = this.states.findIndex((i)=>i.id === state.id);
59
- if (-1 === index) return void this.states.push(state);
60
- this.states[index] = state;
59
+ -1 === index ? this.states.push(state) : this.states[index] = state;
61
60
  }
62
61
  writeToStd(type = 'stdout', data) {
63
62
  this.log.clear(), data && ('stdout' === type ? process.stdout.write(data) : 'stderr' === type && process.stderr.write(data)), this.log(this.prevOutput);
@@ -66,22 +65,20 @@ exports.ids = [
66
65
  let maxIdLen = Math.max(...this.states.map((i)=>i.id?.length ?? 0)) + 2, { columns = 70 } = process.stdout;
67
66
  this.prevOutput = this.states.map((i, k)=>{
68
67
  let bar = ((option)=>{
69
- let mergedOptions = {
68
+ var id;
69
+ let left, right, mergedOptions = {
70
70
  ...defaultOption,
71
71
  ...option
72
- }, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor = external_picocolors_default()[color], backgroundColor = external_picocolors_default()[bgColor], doneColor = hasErrors ? external_picocolors_default().red : barColor, idColor = done ? doneColor : barColor, id = mergedOptions.id ? idColor(((id, maxLen)=>{
73
- let left = Math.floor((maxLen - id.length) / 2), right = maxLen - left - id.length;
74
- return ' '.repeat(left) + id + ' '.repeat(right);
75
- })(mergedOptions.id, maxIdLen)) : '', { columns: terminalWidth = 70 } = process.stdout;
72
+ }, { total, done, buildIcon, errorIcon, errorInfo, width, current, color, bgColor, char, message, messageWidth, spaceWidth, messageColor, maxIdLen, hasErrors } = mergedOptions, space = ' '.repeat(spaceWidth), percent = clamp(Math.floor(current / total * 100), 0, 100), barColor = external_picocolors_default()[color], backgroundColor = external_picocolors_default()[bgColor], doneColor = hasErrors ? external_picocolors_default().red : barColor, idColor = done ? doneColor : barColor, id1 = mergedOptions.id ? idColor((left = Math.floor((maxIdLen - (id = mergedOptions.id).length) / 2), right = maxIdLen - left - id.length, ' '.repeat(left) + id + ' '.repeat(right))) : '', { columns: terminalWidth = 70 } = process.stdout;
76
73
  if (done) {
77
74
  if (hasErrors) {
78
75
  let message = external_picocolors_default().bold(doneColor(errorInfo));
79
76
  return terminalWidth >= 40 ? [
80
77
  idColor(errorIcon),
81
- id,
78
+ id1,
82
79
  doneColor(`${space}${message}`)
83
80
  ].join('') : [
84
- id,
81
+ id1,
85
82
  doneColor(`${message}`)
86
83
  ].join('');
87
84
  }
@@ -89,10 +86,10 @@ exports.ids = [
89
86
  }
90
87
  let msgStr = external_picocolors_default()[messageColor](cli_truncate_default()(message, messageWidth, {
91
88
  position: 'start'
92
- })), left = clamp(Math.floor(percent * width / 100), 0, width), right = clamp(width - left, 0, width), barStr = `${barColor(char.repeat(left))}${backgroundColor(char.repeat(right))}`, percentStr = `${percent.toString().padStart(3)}%`;
89
+ })), left1 = clamp(Math.floor(percent * width / 100), 0, width), right1 = clamp(width - left1, 0, width), barStr = `${barColor(char.repeat(left1))}${backgroundColor(char.repeat(right1))}`, percentStr = `${percent.toString().padStart(3)}%`;
93
90
  return terminalWidth >= 70 ? [
94
91
  idColor(buildIcon),
95
- id,
92
+ id1,
96
93
  space,
97
94
  barStr,
98
95
  space,
@@ -101,14 +98,14 @@ exports.ids = [
101
98
  msgStr
102
99
  ].join('') : terminalWidth >= 40 ? [
103
100
  idColor(buildIcon),
104
- id,
101
+ id1,
105
102
  space,
106
103
  barStr,
107
104
  space,
108
105
  percentStr
109
106
  ].join('') : [
110
107
  idColor(buildIcon),
111
- id,
108
+ id1,
112
109
  space,
113
110
  percentStr
114
111
  ].join('');
@@ -136,7 +133,7 @@ exports.ids = [
136
133
  compileTime = null;
137
134
  prettyTime;
138
135
  constructor(options){
139
- let { id = 'Rsbuild' } = options, nonTTYLogger = function() {
136
+ const { id = 'Rsbuild' } = options, nonTTYLogger = function() {
140
137
  let prevPercentage = 0;
141
138
  return {
142
139
  log: ({ id, done, current, hasErrors, compileTime })=>{
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- let __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
2
+ const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
3
  var __webpack_modules__ = {
4
4
  "@rsbuild/core": function(module) {
5
5
  module.exports = require("@rsbuild/core");
@@ -62,7 +62,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
62
62
  enumerable: !0,
63
63
  get: definition[key]
64
64
  });
65
- }, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"" + chunkId + ".cjs", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
65
+ }, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"1~" + chunkId + ".cjs", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
66
66
  'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
67
67
  value: 'Module'
68
68
  }), Object.defineProperty(exports1, '__esModule', {
@@ -181,20 +181,22 @@ for(var __webpack_i__ in (()=>{
181
181
  }
182
182
  async function createCompiler_createCompiler(options) {
183
183
  core_.logger.debug('creating compiler');
184
- let { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
184
+ let HOOK_NAME = 'rsbuild:compiler', { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
185
185
  await context.hooks.onBeforeCreateCompiler.callBatch({
186
186
  bundlerConfigs: webpackConfigs,
187
187
  environments: context.environments
188
188
  });
189
189
  let { default: webpack } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "webpack?5a4d")), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs);
190
- return compiler.hooks.done.tap('rsbuild:done', (stats)=>{
191
- var stats1 = stats;
192
- let statsOptions = helpers.getStatsOptions(compiler), statsJson = stats1.toJson({
193
- moduleTrace: !0,
194
- children: !0,
195
- preset: 'errors-warnings',
196
- ...statsOptions
197
- }), { message, level } = helpers.formatStats(statsJson, stats1.hasErrors());
190
+ return compiler.hooks.run.tap(HOOK_NAME, ()=>{
191
+ context.buildState.status = 'building';
192
+ }), compiler.hooks.watchRun.tap(HOOK_NAME, ()=>{
193
+ context.buildState.status = 'building';
194
+ }), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
195
+ context.buildState.stats = null, context.buildState.status = 'idle', context.buildState.hasErrors = !1;
196
+ }), compiler.hooks.done.tap(HOOK_NAME, (statsInstance)=>{
197
+ let stats = helpers.getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
198
+ context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors;
199
+ let { message, level } = helpers.formatStats(stats, hasErrors);
198
200
  'error' === level ? core_.logger.error(message) : 'warning' === level && core_.logger.warn(message);
199
201
  }), 'dev' === context.action && helpers.registerDevHook({
200
202
  compiler,
@@ -233,7 +235,7 @@ for(var __webpack_i__ in (()=>{
233
235
  };
234
236
  let { stats } = await new Promise((resolve, reject)=>{
235
237
  compiler.run((err, stats)=>{
236
- err ? reject(err) : stats?.hasErrors() ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
238
+ err ? reject(err) : context.buildState.hasErrors ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
237
239
  closeErr && core_.logger.error(closeErr), resolve({
238
240
  stats
239
241
  });
@@ -273,27 +275,24 @@ for(var __webpack_i__ in (()=>{
273
275
  name: 'rsbuild-webpack:adaptor',
274
276
  setup (api) {
275
277
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, target })=>{
276
- let { config, tsconfigPath } = environment, aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
278
+ var chain1, target1, target2;
279
+ let mainFields, { config, tsconfigPath } = environment, aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
277
280
  tsconfigPath && 'prefer-tsconfig' === aliasStrategy && await applyTsConfigPathsPlugin({
278
281
  chain,
279
282
  CHAIN_ID,
280
283
  configFile: tsconfigPath,
281
- mainFields: ((chain, target)=>{
282
- var target1;
283
- let mainFields = chain.resolve.mainFields.values();
284
- return mainFields.length ? mainFields : castArray(target1 = target).includes('web') || target1.includes('web-worker') ? [
285
- 'browser',
286
- 'module',
287
- 'main'
288
- ] : [
289
- 'module',
290
- 'main'
291
- ];
292
- })(chain, target),
284
+ mainFields: (chain1 = chain, target1 = target, (mainFields = chain1.resolve.mainFields.values()).length ? mainFields : castArray(target2 = target1).includes('web') || target2.includes('web-worker') ? [
285
+ 'browser',
286
+ 'module',
287
+ 'main'
288
+ ] : [
289
+ 'module',
290
+ 'main'
291
+ ]),
293
292
  extensions: chain.resolve.extensions.values()
294
293
  });
295
- let progress = config.dev.progressBar ?? !0;
296
- if (progress) {
294
+ let { progressBar } = config.dev;
295
+ if (progressBar) {
297
296
  let { ProgressPlugin } = await Promise.all([
298
297
  __webpack_require__.e("0"),
299
298
  __webpack_require__.e("363")
@@ -302,7 +301,7 @@ for(var __webpack_i__ in (()=>{
302
301
  {
303
302
  id: environment.name,
304
303
  prettyTime: helpers1.prettyTime,
305
- ...!0 === progress ? {} : progress
304
+ ...!0 === progressBar ? {} : progressBar
306
305
  }
307
306
  ]);
308
307
  }
package/dist/index.js CHANGED
@@ -1,26 +1,10 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
2
- import * as __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__ from "node:console";
3
- import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
4
- import * as __WEBPACK_EXTERNAL_MODULE_stream__ from "stream";
5
- import * as __WEBPACK_EXTERNAL_MODULE_webpack__ from "webpack";
6
2
  import MultiStats from "webpack/lib/MultiStats.js";
7
3
  import { reduceConfigsWithContext } from "reduce-configs";
8
4
  import node_fs from "node:fs";
9
5
  var installedChunks, installChunk, __webpack_modules__ = {
10
6
  "@rsbuild/core": function(module) {
11
7
  module.exports = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__;
12
- },
13
- "node:console": function(module) {
14
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_console_8631dfae__;
15
- },
16
- picocolors: function(module) {
17
- module.exports = __WEBPACK_EXTERNAL_MODULE_picocolors__;
18
- },
19
- stream: function(module) {
20
- module.exports = __WEBPACK_EXTERNAL_MODULE_stream__;
21
- },
22
- webpack: function(module) {
23
- module.exports = __WEBPACK_EXTERNAL_MODULE_webpack__;
24
8
  }
25
9
  }, __webpack_module_cache__ = {};
26
10
  function __webpack_require__(moduleId) {
@@ -43,7 +27,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
43
27
  enumerable: !0,
44
28
  get: definition[key]
45
29
  });
46
- }, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"" + chunkId + ".js", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.nmd = (module)=>(module.paths = [], module.children || (module.children = []), module), installedChunks = {
30
+ }, __webpack_require__.f = {}, __webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>(__webpack_require__.f[key](chunkId, promises), promises), [])), __webpack_require__.u = (chunkId)=>"0~" + chunkId + ".js", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.nmd = (module)=>(module.paths = [], module.children || (module.children = []), module), installedChunks = {
47
31
  410: 0
48
32
  }, installChunk = (data)=>{
49
33
  var moduleId, chunkId, __webpack_ids__ = data.__webpack_ids__, __webpack_modules__ = data.__webpack_modules__, __webpack_runtime__ = data.__webpack_runtime__, i = 0;
@@ -159,19 +143,22 @@ async function initConfigs({ context, pluginManager, rsbuildOptions, helpers })
159
143
  }
160
144
  async function createCompiler_createCompiler(options) {
161
145
  core_.logger.debug('creating compiler');
162
- let { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
146
+ let HOOK_NAME = 'rsbuild:compiler', { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
163
147
  await context.hooks.onBeforeCreateCompiler.callBatch({
164
148
  bundlerConfigs: webpackConfigs,
165
149
  environments: context.environments
166
150
  });
167
151
  let { default: webpack } = await import("webpack"), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs);
168
- return compiler.hooks.done.tap('rsbuild:done', (stats)=>{
169
- let statsOptions = helpers.getStatsOptions(compiler), statsJson = stats.toJson({
170
- moduleTrace: !0,
171
- children: !0,
172
- preset: 'errors-warnings',
173
- ...statsOptions
174
- }), { message, level } = helpers.formatStats(statsJson, stats.hasErrors());
152
+ return compiler.hooks.run.tap(HOOK_NAME, ()=>{
153
+ context.buildState.status = 'building';
154
+ }), compiler.hooks.watchRun.tap(HOOK_NAME, ()=>{
155
+ context.buildState.status = 'building';
156
+ }), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
157
+ context.buildState.stats = null, context.buildState.status = 'idle', context.buildState.hasErrors = !1;
158
+ }), compiler.hooks.done.tap(HOOK_NAME, (statsInstance)=>{
159
+ let stats = helpers.getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
160
+ context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors;
161
+ let { message, level } = helpers.formatStats(stats, hasErrors);
175
162
  'error' === level ? core_.logger.error(message) : 'warning' === level && core_.logger.warn(message);
176
163
  }), 'dev' === context.action && helpers.registerDevHook({
177
164
  compiler,
@@ -210,7 +197,7 @@ let build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
210
197
  };
211
198
  let { stats } = await new Promise((resolve, reject)=>{
212
199
  compiler.run((err, stats)=>{
213
- err ? reject(err) : stats?.hasErrors() ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
200
+ err ? reject(err) : context.buildState.hasErrors ? reject(Error('webpack build failed.')) : compiler.close((closeErr)=>{
214
201
  closeErr && core_.logger.error(closeErr), resolve({
215
202
  stats
216
203
  });
@@ -267,17 +254,17 @@ let webpackProvider = async ({ context, pluginManager, rsbuildOptions, helpers }
267
254
  })(chain, target),
268
255
  extensions: chain.resolve.extensions.values()
269
256
  });
270
- let progress = config.dev.progressBar ?? !0;
271
- if (progress) {
257
+ let { progressBar } = config.dev;
258
+ if (progressBar) {
272
259
  let { ProgressPlugin } = await Promise.all([
273
260
  __webpack_require__.e("0"),
274
- __webpack_require__.e("560")
261
+ __webpack_require__.e("502")
275
262
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/progress/ProgressPlugin.ts"));
276
263
  chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
277
264
  {
278
265
  id: environment.name,
279
266
  prettyTime: helpers.prettyTime,
280
- ...!0 === progress ? {} : progress
267
+ ...!0 === progressBar ? {} : progressBar
281
268
  }
282
269
  ]);
283
270
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "homepage": "https://rsbuild.rs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,13 +32,13 @@
32
32
  "webpack": "^5.101.3"
33
33
  },
34
34
  "devDependencies": {
35
- "@rslib/core": "0.12.2",
36
- "@types/node": "^22.17.2",
35
+ "@rslib/core": "0.15.0",
36
+ "@types/node": "^22.18.8",
37
37
  "ansi-escapes": "4.3.2",
38
38
  "cli-truncate": "2.1.0",
39
39
  "patch-console": "1.0.0",
40
- "typescript": "^5.9.2",
41
- "@rsbuild/core": "1.5.0",
40
+ "typescript": "^5.9.3",
41
+ "@rsbuild/core": "1.5.14",
42
42
  "@scripts/test-helper": "1.0.1"
43
43
  },
44
44
  "peerDependencies": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "scripts": {
52
52
  "build": "rslib build",
53
- "dev": "rslib build --watch",
53
+ "dev": "rslib build -w",
54
54
  "bump": "pnpx bumpp --no-tag"
55
55
  }
56
56
  }