@rsbuild/webpack 0.4.13 → 0.4.15

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.
@@ -50,10 +50,10 @@ const build = async (initOptions, { mode = "production", watch, compiler: custom
50
50
  isFirstCompile = false;
51
51
  await p;
52
52
  };
53
- try {
54
- compiler.hooks.done.tapPromise("rsbuild:done", onDone);
55
- } catch {
53
+ if ((0, import_shared.isMultiCompiler)(compiler)) {
56
54
  compiler.hooks.done.tap("rsbuild:done", onDone);
55
+ } else {
56
+ compiler.hooks.done.tapPromise("rsbuild:done", onDone);
57
57
  }
58
58
  if (watch) {
59
59
  compiler.watch({}, (err) => {
@@ -46,8 +46,7 @@ async function createCompiler({
46
46
  });
47
47
  const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
48
48
  const compiler = webpackConfigs.length === 1 ? webpack(webpackConfigs[0]) : webpack(webpackConfigs);
49
- let isFirstCompile = true;
50
- compiler.hooks.done.tap("rsbuild:done", async (stats) => {
49
+ const done = async (stats) => {
51
50
  const { message, level } = (0, import_provider.formatStats)(stats);
52
51
  if (level === "error") {
53
52
  import_shared.logger.error(message);
@@ -62,7 +61,13 @@ async function createCompiler({
62
61
  });
63
62
  }
64
63
  isFirstCompile = false;
65
- });
64
+ };
65
+ let isFirstCompile = true;
66
+ if ((0, import_shared.isMultiCompiler)(compiler)) {
67
+ compiler.hooks.done.tap("rsbuild:done", done);
68
+ } else {
69
+ compiler.hooks.done.tapPromise("rsbuild:done", done);
70
+ }
66
71
  await context.hooks.onAfterCreateCompiler.call({
67
72
  compiler
68
73
  });
@@ -41,7 +41,7 @@ const applyHMREntry = (compiler, clientPath) => {
41
41
  }).apply(compiler2);
42
42
  }
43
43
  };
44
- if (compiler.compilers) {
44
+ if ((0, import_shared.isMultiCompiler)(compiler)) {
45
45
  compiler.compilers.forEach((target) => {
46
46
  applyEntry(clientPath, target);
47
47
  });
@@ -50,7 +50,7 @@ const applyHMREntry = (compiler, clientPath) => {
50
50
  }
51
51
  };
52
52
  const setupHooks = (compiler, hookCallbacks) => {
53
- if (compiler.compilers) {
53
+ if ((0, import_shared.isMultiCompiler)(compiler)) {
54
54
  compiler.compilers.forEach(
55
55
  (compiler2) => (0, import_shared.setupServerHooks)(compiler2, hookCallbacks)
56
56
  );
package/dist/shared.js CHANGED
@@ -35,8 +35,7 @@ module.exports = __toCommonJS(shared_exports);
35
35
  var import_node_fs = __toESM(require("node:fs"));
36
36
  var import_node_path = require("node:path");
37
37
  var import_shared = require("@rsbuild/shared");
38
- var import_shared2 = require("@rsbuild/shared");
39
- const applyDefaultPlugins = (plugins) => (0, import_shared2.awaitableGetter)([
38
+ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
40
39
  plugins.basic?.(),
41
40
  plugins.entry?.(),
42
41
  plugins.cache?.(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
4
4
  "homepage": "https://rsbuild.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,13 +35,13 @@
35
35
  "terser-webpack-plugin": "5.3.10",
36
36
  "tsconfig-paths-webpack-plugin": "4.1.0",
37
37
  "webpack": "^5.89.0",
38
- "@rsbuild/core": "0.4.13",
39
- "@rsbuild/shared": "0.4.13"
38
+ "@rsbuild/core": "0.4.15",
39
+ "@rsbuild/shared": "0.4.15"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "16.x",
43
43
  "typescript": "^5.4.2",
44
- "@scripts/test-helper": "0.4.13"
44
+ "@scripts/test-helper": "0.4.15"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public",
@@ -1,2 +0,0 @@
1
- import webpack from 'webpack';
2
- export default webpack;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var webpack_exports = {};
30
- __export(webpack_exports, {
31
- default: () => webpack_default
32
- });
33
- module.exports = __toCommonJS(webpack_exports);
34
- var import_webpack = __toESM(require("webpack"));
35
- var webpack_default = import_webpack.default;
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginServer: () => RsbuildPlugin;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var server_exports = {};
30
- __export(server_exports, {
31
- pluginServer: () => pluginServer
32
- });
33
- module.exports = __toCommonJS(server_exports);
34
- var import_node_fs = __toESM(require("node:fs"));
35
- var import_node_path = require("node:path");
36
- const pluginServer = () => ({
37
- name: "rsbuild:server",
38
- setup(api) {
39
- api.modifyBundlerChain(async (chain, { isProd }) => {
40
- const config = api.getNormalizedConfig();
41
- if (isProd && config.server?.publicDir) {
42
- const { name, copyOnBuild } = config.server.publicDir;
43
- if (!copyOnBuild || !name) {
44
- return;
45
- }
46
- const publicDir = (0, import_node_path.isAbsolute)(name) ? name : (0, import_node_path.join)(api.context.rootPath, name);
47
- const publicPattern = [
48
- {
49
- from: publicDir,
50
- to: "",
51
- noErrorOnMissing: true
52
- }
53
- ];
54
- if (!import_node_fs.default.existsSync(publicDir)) {
55
- return;
56
- }
57
- const { default: CopyPlugin } = await Promise.resolve().then(() => __toESM(require("../../compiled/copy-webpack-plugin")));
58
- chain.plugin("public-dir").use(CopyPlugin, [
59
- {
60
- patterns: publicPattern
61
- }
62
- ]);
63
- }
64
- });
65
- }
66
- });
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- pluginServer
70
- });