@rsbuild/webpack 1.0.0 → 1.0.1-beta.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.
- package/README.md +23 -2
- package/dist/index.cjs +2582 -0
- package/dist/index.js +2609 -17
- package/dist-types/build.d.ts +3 -0
- package/dist-types/createCompiler.d.ts +12 -0
- package/dist-types/index.d.ts +2 -0
- package/dist-types/initConfigs.d.ts +11 -0
- package/dist-types/inspectConfig.d.ts +7 -0
- package/dist-types/package.json +1 -0
- package/dist-types/plugin.d.ts +5 -0
- package/dist-types/progress/ProgressPlugin.d.ts +13 -0
- package/{dist/webpackPlugins/ProgressPlugin → dist-types/progress}/helpers/bar.d.ts +2 -2
- package/dist-types/progress/helpers/bus.d.ts +18 -0
- package/dist-types/progress/helpers/index.d.ts +4 -0
- package/dist-types/progress/helpers/log.d.ts +8 -0
- package/dist-types/progress/helpers/nonTty.d.ts +9 -0
- package/{dist/webpackPlugins/ProgressPlugin → dist-types/progress}/helpers/percentage.d.ts +1 -1
- package/dist-types/progress/helpers/types.d.ts +24 -0
- package/{dist/webpackPlugins/ProgressPlugin → dist-types/progress}/helpers/utils.d.ts +1 -1
- package/dist-types/provider.d.ts +2 -0
- package/dist-types/shared.d.ts +17 -0
- package/dist-types/types.d.ts +3 -0
- package/dist-types/webpackConfig.d.ts +8 -0
- package/package.json +21 -50
- package/static/ModuleFilenameHelpers.js +1 -1
- package/compiled/ansi-escapes/index.d.ts +0 -248
- package/compiled/ansi-escapes/index.js +0 -1
- package/compiled/ansi-escapes/license +0 -9
- package/compiled/ansi-escapes/package.json +0 -1
- package/compiled/ansi-escapes/type-fest/index.d.ts +0 -2
- package/compiled/babel-plugin-lodash/index.d.ts +0 -1
- package/compiled/babel-plugin-lodash/index.js +0 -1
- package/compiled/babel-plugin-lodash/license +0 -44
- package/compiled/babel-plugin-lodash/package.json +0 -1
- package/compiled/babel-plugin-transform-react-remove-prop-types/index.d.ts +0 -1
- package/compiled/babel-plugin-transform-react-remove-prop-types/index.js +0 -1
- package/compiled/babel-plugin-transform-react-remove-prop-types/license +0 -22
- package/compiled/babel-plugin-transform-react-remove-prop-types/package.json +0 -1
- package/compiled/cli-truncate/index.d.ts +0 -96
- package/compiled/cli-truncate/index.js +0 -1
- package/compiled/cli-truncate/license +0 -9
- package/compiled/cli-truncate/package.json +0 -1
- package/compiled/copy-webpack-plugin/index.d.ts +0 -1
- package/compiled/copy-webpack-plugin/index.js +0 -22
- package/compiled/copy-webpack-plugin/license +0 -20
- package/compiled/copy-webpack-plugin/package.json +0 -1
- package/compiled/patch-console/build/index.d.ts +0 -4
- package/compiled/patch-console/index.js +0 -1
- package/compiled/patch-console/package.json +0 -1
- package/compiled/schema-utils3/index.d.ts +0 -1
- package/compiled/schema-utils3/index.js +0 -3
- package/compiled/schema-utils3/license +0 -20
- package/compiled/schema-utils3/package.json +0 -1
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/license +0 -21
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/compiled/webpack-sources/index.d.ts +0 -1
- package/compiled/webpack-sources/index.js +0 -1
- package/compiled/webpack-sources/license +0 -21
- package/compiled/webpack-sources/package.json +0 -1
- package/dist/config/defaults.d.ts +0 -3
- package/dist/config/defaults.js +0 -47
- package/dist/config/normalize.d.ts +0 -7
- package/dist/config/normalize.js +0 -33
- package/dist/core/build.d.ts +0 -20
- package/dist/core/build.js +0 -80
- package/dist/core/createCompiler.d.ts +0 -14
- package/dist/core/createCompiler.js +0 -88
- package/dist/core/createContext.d.ts +0 -13
- package/dist/core/createContext.js +0 -58
- package/dist/core/devMiddleware.d.ts +0 -3
- package/dist/core/devMiddleware.js +0 -73
- package/dist/core/initConfigs.d.ts +0 -14
- package/dist/core/initConfigs.js +0 -79
- package/dist/core/initHooks.d.ts +0 -19
- package/dist/core/initHooks.js +0 -44
- package/dist/core/initPlugins.d.ts +0 -9
- package/dist/core/initPlugins.js +0 -86
- package/dist/core/inspectConfig.d.ts +0 -20
- package/dist/core/inspectConfig.js +0 -81
- package/dist/core/webpackConfig.d.ts +0 -9
- package/dist/core/webpackConfig.js +0 -164
- package/dist/exports/webpack.d.ts +0 -2
- package/dist/exports/webpack.js +0 -35
- package/dist/index.d.ts +0 -6
- package/dist/plugins/babel.d.ts +0 -3
- package/dist/plugins/babel.js +0 -169
- package/dist/plugins/basic.d.ts +0 -5
- package/dist/plugins/basic.js +0 -58
- package/dist/plugins/copy.d.ts +0 -2
- package/dist/plugins/copy.js +0 -69
- package/dist/plugins/css.d.ts +0 -23
- package/dist/plugins/css.js +0 -121
- package/dist/plugins/hmr.d.ts +0 -2
- package/dist/plugins/hmr.js +0 -41
- package/dist/plugins/less.d.ts +0 -6
- package/dist/plugins/less.js +0 -65
- package/dist/plugins/minimize.d.ts +0 -2
- package/dist/plugins/minimize.js +0 -64
- package/dist/plugins/output.d.ts +0 -2
- package/dist/plugins/output.js +0 -66
- package/dist/plugins/progress.d.ts +0 -2
- package/dist/plugins/progress.js +0 -58
- package/dist/plugins/react.d.ts +0 -2
- package/dist/plugins/react.js +0 -97
- package/dist/plugins/resolve.d.ts +0 -2
- package/dist/plugins/resolve.js +0 -86
- package/dist/plugins/sass.d.ts +0 -2
- package/dist/plugins/sass.js +0 -76
- package/dist/plugins/tsLoader.d.ts +0 -2
- package/dist/plugins/tsLoader.js +0 -105
- package/dist/provider.d.ts +0 -9
- package/dist/provider.js +0 -108
- package/dist/shared/fs.d.ts +0 -1
- package/dist/shared/fs.js +0 -48
- package/dist/shared/index.d.ts +0 -1
- package/dist/shared/index.js +0 -22
- package/dist/shared/plugin.d.ts +0 -3
- package/dist/shared/plugin.js +0 -78
- package/dist/types/config/index.d.ts +0 -26
- package/dist/types/config/index.js +0 -22
- package/dist/types/config/tools.d.ts +0 -51
- package/dist/types/config/tools.js +0 -16
- package/dist/types/context.d.ts +0 -17
- package/dist/types/context.js +0 -16
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -28
- package/dist/types/plugin.d.ts +0 -6
- package/dist/types/plugin.js +0 -16
- package/dist/types/thirdParty/css.d.ts +0 -7
- package/dist/types/thirdParty/css.js +0 -16
- package/dist/types/thirdParty/index.d.ts +0 -8
- package/dist/types/thirdParty/index.js +0 -16
- package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.d.ts +0 -13
- package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.js +0 -104
- package/dist/webpackPlugins/ProgressPlugin/helpers/bar.js +0 -142
- package/dist/webpackPlugins/ProgressPlugin/helpers/bus.d.ts +0 -17
- package/dist/webpackPlugins/ProgressPlugin/helpers/bus.js +0 -105
- package/dist/webpackPlugins/ProgressPlugin/helpers/index.d.ts +0 -4
- package/dist/webpackPlugins/ProgressPlugin/helpers/index.js +0 -28
- package/dist/webpackPlugins/ProgressPlugin/helpers/log.d.ts +0 -9
- package/dist/webpackPlugins/ProgressPlugin/helpers/log.js +0 -62
- package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.d.ts +0 -15
- package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.js +0 -56
- package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.js +0 -52
- package/dist/webpackPlugins/ProgressPlugin/helpers/type.d.ts +0 -23
- package/dist/webpackPlugins/ProgressPlugin/helpers/type.js +0 -16
- package/dist/webpackPlugins/ProgressPlugin/helpers/utils.js +0 -30
package/dist/plugins/minimize.js
DELETED
|
@@ -1,64 +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
|
-
var import_plugin_css_minimizer = require("@rsbuild/plugin-css-minimizer");
|
|
36
|
-
async function applyJSMinimizer(chain, config) {
|
|
37
|
-
const { default: TerserPlugin } = await Promise.resolve().then(() => __toESM(require("terser-webpack-plugin")));
|
|
38
|
-
const finalOptions = await (0, import_shared.getJSMinifyOptions)(config);
|
|
39
|
-
chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(TerserPlugin, [
|
|
40
|
-
// Due to terser-webpack-plugin has changed the type of class, which using a generic type in
|
|
41
|
-
// constructor, leading auto inference of parameters of plugin constructor is not possible, using any instead
|
|
42
|
-
finalOptions
|
|
43
|
-
]).end();
|
|
44
|
-
}
|
|
45
|
-
const pluginMinimize = () => ({
|
|
46
|
-
name: "rsbuild-webpack:minimize",
|
|
47
|
-
setup(api) {
|
|
48
|
-
api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID: CHAIN_ID2 }) => {
|
|
49
|
-
const config = api.getNormalizedConfig();
|
|
50
|
-
const isMinimize = isProd && !config.output.disableMinimize;
|
|
51
|
-
chain.optimization.minimize(isMinimize);
|
|
52
|
-
if (isMinimize) {
|
|
53
|
-
await applyJSMinimizer(chain, config);
|
|
54
|
-
await (0, import_plugin_css_minimizer.applyCSSMinimizer)(chain, CHAIN_ID2, {
|
|
55
|
-
pluginOptions: config.tools.minifyCss
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
pluginMinimize
|
|
64
|
-
});
|
package/dist/plugins/output.d.ts
DELETED
package/dist/plugins/output.js
DELETED
|
@@ -1,66 +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 output_exports = {};
|
|
30
|
-
__export(output_exports, {
|
|
31
|
-
pluginOutput: () => pluginOutput
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(output_exports);
|
|
34
|
-
var import_path = require("path");
|
|
35
|
-
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
const pluginOutput = () => ({
|
|
37
|
-
name: "rsbuild-webpack:output",
|
|
38
|
-
setup(api) {
|
|
39
|
-
(0, import_shared.applyOutputPlugin)(api);
|
|
40
|
-
api.modifyWebpackChain(async (chain, { isProd, target, CHAIN_ID }) => {
|
|
41
|
-
var _a;
|
|
42
|
-
const config = api.getNormalizedConfig();
|
|
43
|
-
const cssPath = (0, import_shared.getDistPath)(config.output, "css");
|
|
44
|
-
if ((0, import_shared.isUseCssExtract)(config, target)) {
|
|
45
|
-
const { default: MiniCssExtractPlugin } = await Promise.resolve().then(() => __toESM(require("mini-css-extract-plugin")));
|
|
46
|
-
const extractPluginOptions = (0, import_shared.mergeChainedOptions)({
|
|
47
|
-
defaults: {},
|
|
48
|
-
options: (_a = config.tools.cssExtract) == null ? void 0 : _a.pluginOptions
|
|
49
|
-
});
|
|
50
|
-
const cssFilename = (0, import_shared.getFilename)(config.output, "css", isProd);
|
|
51
|
-
chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(MiniCssExtractPlugin, [
|
|
52
|
-
{
|
|
53
|
-
filename: import_path.posix.join(cssPath, cssFilename),
|
|
54
|
-
chunkFilename: import_path.posix.join(cssPath, `async/${cssFilename}`),
|
|
55
|
-
ignoreOrder: true,
|
|
56
|
-
...extractPluginOptions
|
|
57
|
-
}
|
|
58
|
-
]);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
pluginOutput
|
|
66
|
-
});
|
package/dist/plugins/progress.js
DELETED
|
@@ -1,58 +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 progress_exports = {};
|
|
30
|
-
__export(progress_exports, {
|
|
31
|
-
pluginProgress: () => pluginProgress
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(progress_exports);
|
|
34
|
-
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
const pluginProgress = () => ({
|
|
36
|
-
name: "rsbuild-webpack:progress",
|
|
37
|
-
setup(api) {
|
|
38
|
-
api.modifyWebpackChain(async (chain, { target, CHAIN_ID }) => {
|
|
39
|
-
var _a;
|
|
40
|
-
const config = api.getNormalizedConfig();
|
|
41
|
-
const options = (_a = config.dev.progressBar) != null ? _a : true;
|
|
42
|
-
if (!options) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const { ProgressPlugin } = await Promise.resolve().then(() => __toESM(require("../webpackPlugins/ProgressPlugin/ProgressPlugin")));
|
|
46
|
-
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
|
|
47
|
-
{
|
|
48
|
-
id: import_shared.TARGET_ID_MAP[target],
|
|
49
|
-
...options === true ? {} : options
|
|
50
|
-
}
|
|
51
|
-
]);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
pluginProgress
|
|
58
|
-
});
|
package/dist/plugins/react.d.ts
DELETED
package/dist/plugins/react.js
DELETED
|
@@ -1,97 +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 react_exports = {};
|
|
30
|
-
__export(react_exports, {
|
|
31
|
-
pluginReactWebpack: () => pluginReactWebpack
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(react_exports);
|
|
34
|
-
var import_plugin_react = require("@rsbuild/plugin-react");
|
|
35
|
-
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
const pluginReactWebpack = () => ({
|
|
37
|
-
name: "rsbuild-webpack:react",
|
|
38
|
-
setup(api) {
|
|
39
|
-
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {
|
|
40
|
-
const isNewJsx = await (0, import_plugin_react.isBeyondReact17)(api.context.rootPath);
|
|
41
|
-
const babelConfig = {
|
|
42
|
-
tools: {
|
|
43
|
-
babel(_, { addPresets, addPlugins }) {
|
|
44
|
-
const presetReactOptions = {
|
|
45
|
-
development: !(0, import_shared.isProd)(),
|
|
46
|
-
// Will use the native built-in instead of trying to polyfill
|
|
47
|
-
useBuiltIns: true,
|
|
48
|
-
useSpread: false,
|
|
49
|
-
runtime: isNewJsx ? "automatic" : "classic"
|
|
50
|
-
};
|
|
51
|
-
addPresets([
|
|
52
|
-
[require.resolve("@babel/preset-react"), presetReactOptions]
|
|
53
|
-
]);
|
|
54
|
-
if ((0, import_shared.isProd)()) {
|
|
55
|
-
addPlugins([
|
|
56
|
-
[
|
|
57
|
-
require.resolve("babel-plugin-transform-react-remove-prop-types"),
|
|
58
|
-
{ removeImport: true }
|
|
59
|
-
]
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
return mergeRsbuildConfig(babelConfig, config);
|
|
66
|
-
});
|
|
67
|
-
api.modifyWebpackChain(async (chain, utils) => {
|
|
68
|
-
const config = api.getNormalizedConfig();
|
|
69
|
-
if (!(0, import_shared.isUsingHMR)(config, utils)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const { CHAIN_ID } = utils;
|
|
73
|
-
const { default: ReactFastRefreshPlugin } = await Promise.resolve().then(() => __toESM(require("@pmmmwh/react-refresh-webpack-plugin")));
|
|
74
|
-
const useTsLoader = Boolean(config.tools.tsLoader);
|
|
75
|
-
const rule = useTsLoader ? chain.module.rule(CHAIN_ID.RULE.TS) : chain.module.rule(CHAIN_ID.RULE.JS);
|
|
76
|
-
if (rule.uses.get(CHAIN_ID.USE.BABEL)) {
|
|
77
|
-
rule.use(CHAIN_ID.USE.BABEL).tap((options) => ({
|
|
78
|
-
...options,
|
|
79
|
-
plugins: [
|
|
80
|
-
...options.plugins || [],
|
|
81
|
-
[require.resolve("react-refresh/babel"), { skipEnvCheck: true }]
|
|
82
|
-
]
|
|
83
|
-
}));
|
|
84
|
-
}
|
|
85
|
-
chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactFastRefreshPlugin, [
|
|
86
|
-
{
|
|
87
|
-
overlay: false,
|
|
88
|
-
exclude: [/node_modules/]
|
|
89
|
-
}
|
|
90
|
-
]);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
-
0 && (module.exports = {
|
|
96
|
-
pluginReactWebpack
|
|
97
|
-
});
|
package/dist/plugins/resolve.js
DELETED
|
@@ -1,86 +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 resolve_exports = {};
|
|
30
|
-
__export(resolve_exports, {
|
|
31
|
-
pluginResolve: () => pluginResolve
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(resolve_exports);
|
|
34
|
-
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_path = __toESM(require("path"));
|
|
36
|
-
async function applyTsConfigPathsPlugin({
|
|
37
|
-
chain,
|
|
38
|
-
CHAIN_ID,
|
|
39
|
-
cwd,
|
|
40
|
-
mainFields,
|
|
41
|
-
extensions
|
|
42
|
-
}) {
|
|
43
|
-
const { TsconfigPathsPlugin } = await Promise.resolve().then(() => __toESM(require("tsconfig-paths-webpack-plugin")));
|
|
44
|
-
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
|
|
45
|
-
{
|
|
46
|
-
configFile: import_path.default.resolve(cwd, import_shared.TS_CONFIG_FILE),
|
|
47
|
-
extensions,
|
|
48
|
-
// https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
|
|
49
|
-
mainFields
|
|
50
|
-
}
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
const getMainFields = (chain, target) => {
|
|
54
|
-
const mainFields = chain.resolve.mainFields.values();
|
|
55
|
-
if (mainFields.length) {
|
|
56
|
-
return mainFields;
|
|
57
|
-
}
|
|
58
|
-
if ((0, import_shared.isWebTarget)(target)) {
|
|
59
|
-
return ["browser", "module", "main"];
|
|
60
|
-
}
|
|
61
|
-
return ["module", "main"];
|
|
62
|
-
};
|
|
63
|
-
const pluginResolve = () => ({
|
|
64
|
-
name: "rsbuild-webpack:resolve",
|
|
65
|
-
setup(api) {
|
|
66
|
-
(0, import_shared.applyResolvePlugin)(api);
|
|
67
|
-
api.modifyWebpackChain(async (chain, { CHAIN_ID, target }) => {
|
|
68
|
-
const config = api.getNormalizedConfig();
|
|
69
|
-
const isTsProject = Boolean(api.context.tsconfigPath);
|
|
70
|
-
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).resolve.set("fullySpecified", false);
|
|
71
|
-
if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
|
|
72
|
-
await applyTsConfigPathsPlugin({
|
|
73
|
-
chain,
|
|
74
|
-
CHAIN_ID,
|
|
75
|
-
cwd: api.context.rootPath,
|
|
76
|
-
mainFields: getMainFields(chain, target),
|
|
77
|
-
extensions: chain.resolve.extensions.values()
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
-
0 && (module.exports = {
|
|
85
|
-
pluginResolve
|
|
86
|
-
});
|
package/dist/plugins/sass.d.ts
DELETED
package/dist/plugins/sass.js
DELETED
|
@@ -1,76 +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 sass_exports = {};
|
|
30
|
-
__export(sass_exports, {
|
|
31
|
-
pluginSass: () => pluginSass
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(sass_exports);
|
|
34
|
-
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
function pluginSass() {
|
|
36
|
-
return {
|
|
37
|
-
name: "rsbuild-webpack:sass",
|
|
38
|
-
setup(api) {
|
|
39
|
-
api.onAfterCreateCompiler(({ compiler }) => {
|
|
40
|
-
(0, import_shared.patchCompilerGlobalLocation)(compiler);
|
|
41
|
-
});
|
|
42
|
-
api.modifyBundlerChain(async (chain, utils) => {
|
|
43
|
-
const config = api.getNormalizedConfig();
|
|
44
|
-
const { applyBaseCSSRule } = await Promise.resolve().then(() => __toESM(require("./css")));
|
|
45
|
-
const { options, excludes } = (0, import_shared.getSassLoaderOptions)(
|
|
46
|
-
config.tools.sass,
|
|
47
|
-
// source-maps required for loaders preceding resolve-url-loader
|
|
48
|
-
true
|
|
49
|
-
);
|
|
50
|
-
const rule = chain.module.rule(utils.CHAIN_ID.RULE.SASS).test(import_shared.SASS_REGEX);
|
|
51
|
-
excludes.forEach((item) => {
|
|
52
|
-
rule.exclude.add(item);
|
|
53
|
-
});
|
|
54
|
-
await applyBaseCSSRule({
|
|
55
|
-
rule,
|
|
56
|
-
utils,
|
|
57
|
-
config,
|
|
58
|
-
context: api.context,
|
|
59
|
-
// postcss-loader, resolve-url-loader, sass-loader
|
|
60
|
-
importLoaders: 3
|
|
61
|
-
});
|
|
62
|
-
rule.use(utils.CHAIN_ID.USE.RESOLVE_URL_LOADER_FOR_SASS).loader(utils.getCompiledPath("resolve-url-loader")).options({
|
|
63
|
-
join: await (0, import_shared.getResolveUrlJoinFn)(),
|
|
64
|
-
// 'resolve-url-loader' relies on 'adjust-sourcemap-loader',
|
|
65
|
-
// it has performance regression issues in some scenarios,
|
|
66
|
-
// so we need to disable the sourceMap option.
|
|
67
|
-
sourceMap: false
|
|
68
|
-
}).end().use(utils.CHAIN_ID.USE.SASS).loader(utils.getCompiledPath("sass-loader")).options(options);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
pluginSass
|
|
76
|
-
});
|
package/dist/plugins/tsLoader.js
DELETED
|
@@ -1,105 +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 tsLoader_exports = {};
|
|
30
|
-
__export(tsLoader_exports, {
|
|
31
|
-
pluginTsLoader: () => pluginTsLoader
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(tsLoader_exports);
|
|
34
|
-
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
36
|
-
var import_web = require("@rsbuild/babel-preset/web");
|
|
37
|
-
var import_babel = require("./babel");
|
|
38
|
-
const pluginTsLoader = () => {
|
|
39
|
-
return {
|
|
40
|
-
name: "rsbuild-webpack:ts-loader",
|
|
41
|
-
setup(api) {
|
|
42
|
-
api.modifyWebpackChain(async (chain, { target, CHAIN_ID }) => {
|
|
43
|
-
const config = api.getNormalizedConfig();
|
|
44
|
-
if (!config.tools.tsLoader) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const { rootPath } = api.context;
|
|
48
|
-
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
|
|
49
|
-
rootPath,
|
|
50
|
-
config,
|
|
51
|
-
target
|
|
52
|
-
);
|
|
53
|
-
const baseBabelConfig = (0, import_web.getBabelConfigForWeb)({
|
|
54
|
-
presetEnv: {
|
|
55
|
-
targets: browserslist,
|
|
56
|
-
useBuiltIns: (0, import_babel.getUseBuiltIns)(config)
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
const babelUtils = (0, import_plugin_babel.getBabelUtils)(baseBabelConfig);
|
|
60
|
-
const babelLoaderOptions = (0, import_shared.mergeChainedOptions)({
|
|
61
|
-
defaults: baseBabelConfig,
|
|
62
|
-
options: config.tools.babel,
|
|
63
|
-
utils: babelUtils
|
|
64
|
-
});
|
|
65
|
-
const includes = [];
|
|
66
|
-
const excludes = [];
|
|
67
|
-
const tsLoaderUtils = {
|
|
68
|
-
addIncludes(items) {
|
|
69
|
-
includes.push(...(0, import_shared.castArray)(items));
|
|
70
|
-
},
|
|
71
|
-
addExcludes(items) {
|
|
72
|
-
excludes.push(...(0, import_shared.castArray)(items));
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const tsLoaderDefaultOptions = {
|
|
76
|
-
compilerOptions: {
|
|
77
|
-
target: "esnext",
|
|
78
|
-
module: "esnext"
|
|
79
|
-
},
|
|
80
|
-
transpileOnly: true,
|
|
81
|
-
allowTsInNodeModules: true
|
|
82
|
-
};
|
|
83
|
-
const tsLoaderOptions = (0, import_shared.mergeChainedOptions)({
|
|
84
|
-
defaults: tsLoaderDefaultOptions,
|
|
85
|
-
// @ts-expect-error ts-loader has incorrect types for compilerOptions
|
|
86
|
-
options: config.tools.tsLoader,
|
|
87
|
-
utils: tsLoaderUtils
|
|
88
|
-
});
|
|
89
|
-
const rule = chain.module.rule(CHAIN_ID.RULE.TS);
|
|
90
|
-
(0, import_shared.applyScriptCondition)({
|
|
91
|
-
rule,
|
|
92
|
-
config,
|
|
93
|
-
context: api.context,
|
|
94
|
-
includes,
|
|
95
|
-
excludes
|
|
96
|
-
});
|
|
97
|
-
rule.test(import_shared.TS_REGEX).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelLoaderOptions).end().use(CHAIN_ID.USE.TS).loader(require.resolve("ts-loader")).options(tsLoaderOptions);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
-
0 && (module.exports = {
|
|
104
|
-
pluginTsLoader
|
|
105
|
-
});
|
package/dist/provider.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type RsbuildProvider } from '@rsbuild/shared';
|
|
2
|
-
import { RsbuildConfig, NormalizedConfig, WebpackConfig } from './types';
|
|
3
|
-
import type { Compiler, MultiCompiler } from 'webpack';
|
|
4
|
-
export type WebpackProvider = RsbuildProvider<RsbuildConfig, WebpackConfig, NormalizedConfig, Compiler | MultiCompiler>;
|
|
5
|
-
export declare function webpackProvider({
|
|
6
|
-
rsbuildConfig: originalRsbuildConfig
|
|
7
|
-
}: {
|
|
8
|
-
rsbuildConfig: RsbuildConfig;
|
|
9
|
-
}): WebpackProvider;
|