@rsbuild/webpack 0.4.15 → 0.5.1
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.
- package/dist/core/createCompiler.js +1 -2
- package/dist/core/webpackConfig.js +2 -2
- package/dist/plugins/less.js +2 -2
- package/dist/plugins/sass.js +2 -2
- package/dist/provider.js +6 -5
- package/dist/shared.js +0 -1
- package/package.json +4 -5
- package/dist/core/devMiddleware.d.ts +0 -3
- package/dist/core/devMiddleware.js +0 -73
- package/dist/plugins/minimize.d.ts +0 -2
- package/dist/plugins/minimize.js +0 -60
|
@@ -35,7 +35,6 @@ module.exports = __toCommonJS(createCompiler_exports);
|
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
36
|
var import_provider = require("@rsbuild/core/provider");
|
|
37
37
|
var import_initConfigs = require("./initConfigs");
|
|
38
|
-
var import_devMiddleware = require("./devMiddleware");
|
|
39
38
|
async function createCompiler({
|
|
40
39
|
context,
|
|
41
40
|
webpackConfigs
|
|
@@ -86,7 +85,7 @@ async function createDevMiddleware(options, customCompiler) {
|
|
|
86
85
|
});
|
|
87
86
|
}
|
|
88
87
|
return {
|
|
89
|
-
devMiddleware: (0,
|
|
88
|
+
devMiddleware: (0, import_provider.getDevMiddleware)(compiler),
|
|
90
89
|
compiler
|
|
91
90
|
};
|
|
92
91
|
}
|
|
@@ -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)
|
|
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;
|
package/dist/plugins/less.js
CHANGED
|
@@ -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
|
-
|
|
48
|
+
for (const item of excludes) {
|
|
49
49
|
rule.exclude.add(item);
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
await applyBaseCSSRule({
|
|
52
52
|
rule,
|
|
53
53
|
utils,
|
package/dist/plugins/sass.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
73
|
-
const {
|
|
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
|
|
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 {
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.5.1",
|
|
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.
|
|
39
|
-
"@rsbuild/shared": "0.
|
|
37
|
+
"@rsbuild/core": "0.5.1",
|
|
38
|
+
"@rsbuild/shared": "0.5.1"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@types/node": "16.x",
|
|
43
42
|
"typescript": "^5.4.2",
|
|
44
|
-
"@scripts/test-helper": "0.
|
|
43
|
+
"@scripts/test-helper": "0.5.1"
|
|
45
44
|
},
|
|
46
45
|
"publishConfig": {
|
|
47
46
|
"access": "public",
|
|
@@ -1,73 +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 devMiddleware_exports = {};
|
|
30
|
-
__export(devMiddleware_exports, {
|
|
31
|
-
getDevMiddleware: () => getDevMiddleware
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(devMiddleware_exports);
|
|
34
|
-
var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
|
|
35
|
-
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
const applyHMREntry = (compiler, clientPath) => {
|
|
37
|
-
const applyEntry = (clientEntry, compiler2) => {
|
|
38
|
-
if ((0, import_shared.isClientCompiler)(compiler2)) {
|
|
39
|
-
new compiler2.webpack.EntryPlugin(compiler2.context, clientEntry, {
|
|
40
|
-
name: void 0
|
|
41
|
-
}).apply(compiler2);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
if ((0, import_shared.isMultiCompiler)(compiler)) {
|
|
45
|
-
compiler.compilers.forEach((target) => {
|
|
46
|
-
applyEntry(clientPath, target);
|
|
47
|
-
});
|
|
48
|
-
} else {
|
|
49
|
-
applyEntry(clientPath, compiler);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const setupHooks = (compiler, hookCallbacks) => {
|
|
53
|
-
if ((0, import_shared.isMultiCompiler)(compiler)) {
|
|
54
|
-
compiler.compilers.forEach(
|
|
55
|
-
(compiler2) => (0, import_shared.setupServerHooks)(compiler2, hookCallbacks)
|
|
56
|
-
);
|
|
57
|
-
} else {
|
|
58
|
-
(0, import_shared.setupServerHooks)(compiler, hookCallbacks);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const getDevMiddleware = (compiler) => (options) => {
|
|
62
|
-
const { hmrClientPath, callbacks, ...restOptions } = options;
|
|
63
|
-
hmrClientPath && applyHMREntry(compiler, hmrClientPath);
|
|
64
|
-
setupHooks(compiler, callbacks);
|
|
65
|
-
return (0, import_webpack_dev_middleware.default)(
|
|
66
|
-
compiler,
|
|
67
|
-
restOptions
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
-
0 && (module.exports = {
|
|
72
|
-
getDevMiddleware
|
|
73
|
-
});
|
package/dist/plugins/minimize.js
DELETED
|
@@ -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
|
-
});
|