@rsbuild/webpack 0.4.15 → 0.5.0

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.
@@ -42,18 +42,18 @@ const applyHMREntry = (compiler, clientPath) => {
42
42
  }
43
43
  };
44
44
  if ((0, import_shared.isMultiCompiler)(compiler)) {
45
- compiler.compilers.forEach((target) => {
45
+ for (const target of compiler.compilers) {
46
46
  applyEntry(clientPath, target);
47
- });
47
+ }
48
48
  } else {
49
49
  applyEntry(clientPath, compiler);
50
50
  }
51
51
  };
52
52
  const setupHooks = (compiler, hookCallbacks) => {
53
53
  if ((0, import_shared.isMultiCompiler)(compiler)) {
54
- compiler.compilers.forEach(
55
- (compiler2) => (0, import_shared.setupServerHooks)(compiler2, hookCallbacks)
56
- );
54
+ for (const target of compiler.compilers) {
55
+ (0, import_shared.setupServerHooks)(target, hookCallbacks);
56
+ }
57
57
  } else {
58
58
  (0, import_shared.setupServerHooks)(compiler, hookCallbacks);
59
59
  }
@@ -41,9 +41,9 @@ async function modifyWebpackChain(context, utils, chain) {
41
41
  utils
42
42
  );
43
43
  if (context.config.tools?.webpackChain) {
44
- (0, import_shared.castArray)(context.config.tools.webpackChain).forEach((item) => {
44
+ for (const item of (0, import_shared.castArray)(context.config.tools.webpackChain)) {
45
45
  item(modifiedChain, utils);
46
- });
46
+ }
47
47
  }
48
48
  (0, import_shared.debug)("modify webpack chain done");
49
49
  return modifiedChain;
@@ -45,9 +45,9 @@ function pluginLess() {
45
45
  api.context.rootPath
46
46
  );
47
47
  const rule = chain.module.rule(utils.CHAIN_ID.RULE.LESS).test(import_shared.LESS_REGEX);
48
- excludes.forEach((item) => {
48
+ for (const item of excludes) {
49
49
  rule.exclude.add(item);
50
- });
50
+ }
51
51
  await applyBaseCSSRule({
52
52
  rule,
53
53
  utils,
@@ -48,9 +48,9 @@ function pluginSass() {
48
48
  true
49
49
  );
50
50
  const rule = chain.module.rule(utils.CHAIN_ID.RULE.SASS).test(import_shared.SASS_REGEX);
51
- excludes.forEach((item) => {
51
+ for (const item of excludes) {
52
52
  rule.exclude.add(item);
53
- });
53
+ }
54
54
  await applyBaseCSSRule({
55
55
  rule,
56
56
  utils,
package/dist/provider.js CHANGED
@@ -69,24 +69,24 @@ const webpackProvider = async ({
69
69
  });
70
70
  return webpackConfigs;
71
71
  },
72
- async getServerAPIs(options) {
73
- const { getServerAPIs } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
72
+ async createDevServer(options) {
73
+ const { createDevServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
74
74
  const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
75
75
  await (0, import_provider.initRsbuildConfig)({ context, pluginManager });
76
- return getServerAPIs(
76
+ return createDevServer(
77
77
  { context, pluginManager, rsbuildOptions },
78
78
  createDevMiddleware,
79
79
  options
80
80
  );
81
81
  },
82
82
  async startDevServer(options) {
83
- const { startDevServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
83
+ const { createDevServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
84
84
  const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
85
85
  await (0, import_provider.initRsbuildConfig)({
86
86
  context,
87
87
  pluginManager
88
88
  });
89
- return startDevServer(
89
+ const server = await createDevServer(
90
90
  {
91
91
  context,
92
92
  pluginManager,
@@ -95,6 +95,7 @@ const webpackProvider = async ({
95
95
  createDevMiddleware,
96
96
  options
97
97
  );
98
+ return server.listen();
98
99
  },
99
100
  async preview(options) {
100
101
  const { startProdServer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/core/server")));
package/dist/shared.js CHANGED
@@ -52,7 +52,6 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
52
52
  plugins.nodeAddons(),
53
53
  plugins.define(),
54
54
  Promise.resolve().then(() => __toESM(require("./plugins/progress"))).then((m) => m.pluginProgress()),
55
- Promise.resolve().then(() => __toESM(require("./plugins/minimize"))).then((m) => m.pluginMinimize()),
56
55
  Promise.resolve().then(() => __toESM(require("./plugins/css"))).then((m) => m.pluginCss()),
57
56
  Promise.resolve().then(() => __toESM(require("./plugins/sass"))).then((m) => m.pluginSass()),
58
57
  Promise.resolve().then(() => __toESM(require("./plugins/less"))).then((m) => m.pluginLess()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "0.4.15",
3
+ "version": "0.5.0",
4
4
  "homepage": "https://rsbuild.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,16 +32,15 @@
32
32
  "html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
33
33
  "mini-css-extract-plugin": "2.8.1",
34
34
  "postcss": "^8.4.33",
35
- "terser-webpack-plugin": "5.3.10",
36
35
  "tsconfig-paths-webpack-plugin": "4.1.0",
37
36
  "webpack": "^5.89.0",
38
- "@rsbuild/core": "0.4.15",
39
- "@rsbuild/shared": "0.4.15"
37
+ "@rsbuild/core": "0.5.0",
38
+ "@rsbuild/shared": "0.5.0"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@types/node": "16.x",
43
42
  "typescript": "^5.4.2",
44
- "@scripts/test-helper": "0.4.15"
43
+ "@scripts/test-helper": "0.5.0"
45
44
  },
46
45
  "publishConfig": {
47
46
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { type RsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginMinimize: () => RsbuildPlugin;
@@ -1,60 +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 minimize_exports = {};
30
- __export(minimize_exports, {
31
- pluginMinimize: () => pluginMinimize
32
- });
33
- module.exports = __toCommonJS(minimize_exports);
34
- var import_shared = require("@rsbuild/shared");
35
- async function applyJSMinimizer(chain, config) {
36
- const { default: TerserPlugin } = await Promise.resolve().then(() => __toESM(require("terser-webpack-plugin")));
37
- const finalOptions = await (0, import_shared.getTerserMinifyOptions)(config);
38
- chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(TerserPlugin, [
39
- // Due to terser-webpack-plugin has changed the type of class, which using a generic type in
40
- // constructor, leading auto inference of parameters of plugin constructor is not possible, using any instead
41
- finalOptions
42
- ]).end();
43
- }
44
- const pluginMinimize = () => ({
45
- name: "rsbuild-webpack:minimize",
46
- setup(api) {
47
- api.modifyBundlerChain(async (chain, { isProd }) => {
48
- const config = api.getNormalizedConfig();
49
- const doesMinimize = isProd && !config.output.disableMinimize && config.output.minify !== false;
50
- chain.optimization.minimize(doesMinimize);
51
- if ((0, import_shared.parseMinifyOptions)(config, isProd).minifyJs) {
52
- await applyJSMinimizer(chain, config);
53
- }
54
- });
55
- }
56
- });
57
- // Annotate the CommonJS export names for ESM import in node:
58
- 0 && (module.exports = {
59
- pluginMinimize
60
- });