@rsbuild/webpack 0.0.0-next-20231103091827
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/LICENSE +21 -0
- package/README.md +19 -0
- package/compiled/ansi-escapes/index.d.ts +248 -0
- package/compiled/ansi-escapes/index.js +1 -0
- package/compiled/ansi-escapes/license +9 -0
- package/compiled/ansi-escapes/package.json +1 -0
- package/compiled/ansi-escapes/type-fest/index.d.ts +2 -0
- package/compiled/babel-plugin-lodash/index.d.ts +1 -0
- package/compiled/babel-plugin-lodash/index.js +1 -0
- package/compiled/babel-plugin-lodash/license +44 -0
- package/compiled/babel-plugin-lodash/package.json +1 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/index.d.ts +1 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/index.js +1 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/license +22 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/package.json +1 -0
- package/compiled/cli-truncate/index.d.ts +96 -0
- package/compiled/cli-truncate/index.js +1 -0
- package/compiled/cli-truncate/license +9 -0
- package/compiled/cli-truncate/package.json +1 -0
- package/compiled/copy-webpack-plugin/index.d.ts +1 -0
- package/compiled/copy-webpack-plugin/index.js +22 -0
- package/compiled/copy-webpack-plugin/license +20 -0
- package/compiled/copy-webpack-plugin/package.json +1 -0
- package/compiled/patch-console/build/index.d.ts +4 -0
- package/compiled/patch-console/index.js +1 -0
- package/compiled/patch-console/package.json +1 -0
- package/compiled/schema-utils3/index.d.ts +1 -0
- package/compiled/schema-utils3/index.js +3 -0
- package/compiled/schema-utils3/license +20 -0
- package/compiled/schema-utils3/package.json +1 -0
- package/compiled/tapable/index.js +1 -0
- package/compiled/tapable/license +21 -0
- package/compiled/tapable/package.json +1 -0
- package/compiled/tapable/tapable.d.ts +116 -0
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/license +21 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- package/compiled/webpack-manifest-plugin/types/helpers.d.ts +23 -0
- package/compiled/webpack-manifest-plugin/types/hooks.d.ts +24 -0
- package/compiled/webpack-manifest-plugin/types/index.d.ts +30 -0
- package/compiled/webpack-sources/index.d.ts +1 -0
- package/compiled/webpack-sources/index.js +1 -0
- package/compiled/webpack-sources/license +21 -0
- package/compiled/webpack-sources/package.json +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +52 -0
- package/dist/config/normalize.d.ts +7 -0
- package/dist/config/normalize.js +33 -0
- package/dist/core/build.d.ts +20 -0
- package/dist/core/build.js +80 -0
- package/dist/core/createCompiler.d.ts +8 -0
- package/dist/core/createCompiler.js +68 -0
- package/dist/core/createContext.d.ts +13 -0
- package/dist/core/createContext.js +56 -0
- package/dist/core/devMiddleware.d.ts +5 -0
- package/dist/core/devMiddleware.js +73 -0
- package/dist/core/initConfigs.d.ts +14 -0
- package/dist/core/initConfigs.js +76 -0
- package/dist/core/initHooks.d.ts +19 -0
- package/dist/core/initHooks.js +44 -0
- package/dist/core/initPlugins.d.ts +9 -0
- package/dist/core/initPlugins.js +83 -0
- package/dist/core/inspectConfig.d.ts +20 -0
- package/dist/core/inspectConfig.js +81 -0
- package/dist/core/startDevServer.d.ts +5 -0
- package/dist/core/startDevServer.js +75 -0
- package/dist/core/webpackConfig.d.ts +9 -0
- package/dist/core/webpackConfig.js +164 -0
- package/dist/exports/webpack.d.ts +2 -0
- package/dist/exports/webpack.js +35 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +34 -0
- package/dist/plugins/babel.d.ts +3 -0
- package/dist/plugins/babel.js +171 -0
- package/dist/plugins/basic.d.ts +5 -0
- package/dist/plugins/basic.js +60 -0
- package/dist/plugins/copy.d.ts +2 -0
- package/dist/plugins/copy.js +69 -0
- package/dist/plugins/css.d.ts +23 -0
- package/dist/plugins/css.js +123 -0
- package/dist/plugins/fallback.d.ts +2 -0
- package/dist/plugins/fallback.js +51 -0
- package/dist/plugins/hmr.d.ts +2 -0
- package/dist/plugins/hmr.js +41 -0
- package/dist/plugins/lazyCompilation.d.ts +2 -0
- package/dist/plugins/lazyCompilation.js +43 -0
- package/dist/plugins/less.d.ts +6 -0
- package/dist/plugins/less.js +65 -0
- package/dist/plugins/manifest.d.ts +2 -0
- package/dist/plugins/manifest.js +58 -0
- package/dist/plugins/minimize.d.ts +2 -0
- package/dist/plugins/minimize.js +64 -0
- package/dist/plugins/moduleScopes.d.ts +5 -0
- package/dist/plugins/moduleScopes.js +85 -0
- package/dist/plugins/output.d.ts +2 -0
- package/dist/plugins/output.js +66 -0
- package/dist/plugins/progress.d.ts +2 -0
- package/dist/plugins/progress.js +57 -0
- package/dist/plugins/react.d.ts +2 -0
- package/dist/plugins/react.js +96 -0
- package/dist/plugins/resolve.d.ts +2 -0
- package/dist/plugins/resolve.js +88 -0
- package/dist/plugins/sass.d.ts +2 -0
- package/dist/plugins/sass.js +76 -0
- package/dist/plugins/sri.d.ts +2 -0
- package/dist/plugins/sri.js +43 -0
- package/dist/plugins/tsLoader.d.ts +2 -0
- package/dist/plugins/tsLoader.js +103 -0
- package/dist/provider.d.ts +9 -0
- package/dist/provider.js +104 -0
- package/dist/shared/fs.d.ts +1 -0
- package/dist/shared/fs.js +38 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +22 -0
- package/dist/shared/plugin.d.ts +5 -0
- package/dist/shared/plugin.js +111 -0
- package/dist/types/config/index.d.ts +30 -0
- package/dist/types/config/index.js +26 -0
- package/dist/types/config/security.d.ts +9 -0
- package/dist/types/config/security.js +16 -0
- package/dist/types/config/source.d.ts +26 -0
- package/dist/types/config/source.js +16 -0
- package/dist/types/config/tools.d.ts +52 -0
- package/dist/types/config/tools.js +16 -0
- package/dist/types/context.d.ts +17 -0
- package/dist/types/context.js +16 -0
- package/dist/types/hooks.d.ts +24 -0
- package/dist/types/hooks.js +16 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +30 -0
- package/dist/types/plugin.d.ts +10 -0
- package/dist/types/plugin.js +16 -0
- package/dist/types/thirdParty/css.d.ts +7 -0
- package/dist/types/thirdParty/css.js +16 -0
- package/dist/types/thirdParty/index.d.ts +9 -0
- package/dist/types/thirdParty/index.js +16 -0
- package/dist/webpackPlugins/ModuleScopePlugin.d.ts +16 -0
- package/dist/webpackPlugins/ModuleScopePlugin.js +111 -0
- package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.d.ts +13 -0
- package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.js +102 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bar.d.ts +5 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bar.js +143 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bus.d.ts +17 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bus.js +105 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/index.d.ts +4 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/index.js +28 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/log.d.ts +8 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/log.js +62 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.d.ts +15 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.js +56 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.d.ts +7 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.js +52 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/type.d.ts +25 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/type.js +16 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/utils.d.ts +1 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/utils.js +30 -0
- package/package.json +88 -0
- package/static/ModuleFilenameHelpers.js +2 -0
|
@@ -0,0 +1,164 @@
|
|
|
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 webpackConfig_exports = {};
|
|
30
|
+
__export(webpackConfig_exports, {
|
|
31
|
+
generateWebpackConfig: () => generateWebpackConfig
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(webpackConfig_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
var import_shared2 = require("../shared");
|
|
36
|
+
async function modifyWebpackChain(context, utils, chain) {
|
|
37
|
+
var _a;
|
|
38
|
+
(0, import_shared.debug)("modify webpack chain");
|
|
39
|
+
const [modifiedChain] = await context.hooks.modifyWebpackChainHook.call(
|
|
40
|
+
chain,
|
|
41
|
+
utils
|
|
42
|
+
);
|
|
43
|
+
if ((_a = context.config.tools) == null ? void 0 : _a.webpackChain) {
|
|
44
|
+
(0, import_shared.castArray)(context.config.tools.webpackChain).forEach((item) => {
|
|
45
|
+
item(modifiedChain, utils);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
(0, import_shared.debug)("modify webpack chain done");
|
|
49
|
+
return modifiedChain;
|
|
50
|
+
}
|
|
51
|
+
async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
52
|
+
var _a;
|
|
53
|
+
(0, import_shared.debug)("modify webpack config");
|
|
54
|
+
let [modifiedConfig] = await context.hooks.modifyWebpackConfigHook.call(
|
|
55
|
+
webpackConfig,
|
|
56
|
+
utils
|
|
57
|
+
);
|
|
58
|
+
if ((_a = context.config.tools) == null ? void 0 : _a.webpack) {
|
|
59
|
+
modifiedConfig = (0, import_shared.mergeChainedOptions)(
|
|
60
|
+
modifiedConfig,
|
|
61
|
+
context.config.tools.webpack,
|
|
62
|
+
utils,
|
|
63
|
+
utils.mergeConfig
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
(0, import_shared.debug)("modify webpack config done");
|
|
67
|
+
return modifiedConfig;
|
|
68
|
+
}
|
|
69
|
+
async function getChainUtils(target) {
|
|
70
|
+
const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
|
|
71
|
+
const { default: HtmlPlugin } = await Promise.resolve().then(() => __toESM(require("html-webpack-plugin")));
|
|
72
|
+
const nodeEnv = process.env.NODE_ENV;
|
|
73
|
+
const nameMap = {
|
|
74
|
+
web: "client",
|
|
75
|
+
node: "server",
|
|
76
|
+
"web-worker": "web-worker",
|
|
77
|
+
"service-worker": "service-worker"
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
env: nodeEnv,
|
|
81
|
+
name: nameMap[target] || "",
|
|
82
|
+
target,
|
|
83
|
+
webpack,
|
|
84
|
+
isProd: nodeEnv === "production",
|
|
85
|
+
isServer: target === "node",
|
|
86
|
+
isServiceWorker: target === "service-worker",
|
|
87
|
+
isWebWorker: target === "web-worker",
|
|
88
|
+
CHAIN_ID: import_shared.CHAIN_ID,
|
|
89
|
+
getCompiledPath: import_shared2.getCompiledPath,
|
|
90
|
+
HtmlPlugin,
|
|
91
|
+
HtmlWebpackPlugin: HtmlPlugin
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async function getConfigUtils(config, chainUtils) {
|
|
95
|
+
const { merge } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/webpack-merge")));
|
|
96
|
+
return {
|
|
97
|
+
...chainUtils,
|
|
98
|
+
mergeConfig: merge,
|
|
99
|
+
addRules(rules) {
|
|
100
|
+
const ruleArr = (0, import_shared.castArray)(rules);
|
|
101
|
+
if (!config.module) {
|
|
102
|
+
config.module = {};
|
|
103
|
+
}
|
|
104
|
+
if (!config.module.rules) {
|
|
105
|
+
config.module.rules = [];
|
|
106
|
+
}
|
|
107
|
+
config.module.rules.unshift(...ruleArr);
|
|
108
|
+
},
|
|
109
|
+
prependPlugins(plugins) {
|
|
110
|
+
const pluginArr = (0, import_shared.castArray)(plugins);
|
|
111
|
+
if (!config.plugins) {
|
|
112
|
+
config.plugins = [];
|
|
113
|
+
}
|
|
114
|
+
config.plugins.unshift(...pluginArr);
|
|
115
|
+
},
|
|
116
|
+
appendPlugins(plugins) {
|
|
117
|
+
const pluginArr = (0, import_shared.castArray)(plugins);
|
|
118
|
+
if (!config.plugins) {
|
|
119
|
+
config.plugins = [];
|
|
120
|
+
}
|
|
121
|
+
config.plugins.push(...pluginArr);
|
|
122
|
+
},
|
|
123
|
+
removePlugin(pluginName) {
|
|
124
|
+
if (config.plugins) {
|
|
125
|
+
config.plugins = config.plugins.filter(
|
|
126
|
+
(item) => (item == null ? void 0 : item.constructor.name) !== pluginName
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async function generateWebpackConfig({
|
|
133
|
+
target,
|
|
134
|
+
context
|
|
135
|
+
}) {
|
|
136
|
+
const chainUtils = await getChainUtils(target);
|
|
137
|
+
const { BannerPlugin, DefinePlugin, ProvidePlugin } = await Promise.resolve().then(() => __toESM(require("webpack")));
|
|
138
|
+
const bundlerChain = await (0, import_shared.modifyBundlerChain)(context, {
|
|
139
|
+
...chainUtils,
|
|
140
|
+
bundler: {
|
|
141
|
+
BannerPlugin,
|
|
142
|
+
DefinePlugin,
|
|
143
|
+
ProvidePlugin
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const chain = await modifyWebpackChain(
|
|
147
|
+
context,
|
|
148
|
+
chainUtils,
|
|
149
|
+
// module rules not support merge
|
|
150
|
+
// need a special rule merge or use bundlerChain as WebpackChain
|
|
151
|
+
bundlerChain
|
|
152
|
+
);
|
|
153
|
+
let webpackConfig = chain.toConfig();
|
|
154
|
+
webpackConfig = await modifyWebpackConfig(
|
|
155
|
+
context,
|
|
156
|
+
webpackConfig,
|
|
157
|
+
await getConfigUtils(webpackConfig, chainUtils)
|
|
158
|
+
);
|
|
159
|
+
return webpackConfig;
|
|
160
|
+
}
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
generateWebpackConfig
|
|
164
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
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;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { webpackProvider } from './provider';
|
|
2
|
+
export type { WebpackProvider } from './provider';
|
|
3
|
+
export { webpackBuild } from './core/build';
|
|
4
|
+
export { createDefaultConfig } from './config/defaults';
|
|
5
|
+
export type { LessLoaderOptions, SassLoaderOptions, PostCSSLoaderOptions, CSSLoaderOptions, StyleLoaderOptions } from '@rsbuild/shared';
|
|
6
|
+
export type { RsbuildPlugin, RsbuildPluginAPI, DevConfig, HtmlConfig, ToolsConfig, OutputConfig, SourceConfig, RsbuildConfig, SecurityConfig, NormalizedConfig, PerformanceConfig, ExperimentsConfig, ModifyWebpackChainFn, ModifyWebpackConfigFn, ModifyWebpackChainUtils, ModifyWebpackConfigUtils, webpack, WebpackChain, WebpackConfig, CSSExtractOptions, HTMLPluginOptions } from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
createDefaultConfig: () => import_defaults.createDefaultConfig,
|
|
22
|
+
webpackBuild: () => import_build.webpackBuild,
|
|
23
|
+
webpackProvider: () => import_provider.webpackProvider
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var import_provider = require("./provider");
|
|
27
|
+
var import_build = require("./core/build");
|
|
28
|
+
var import_defaults = require("./config/defaults");
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
createDefaultConfig,
|
|
32
|
+
webpackBuild,
|
|
33
|
+
webpackProvider
|
|
34
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
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 babel_exports = {};
|
|
30
|
+
__export(babel_exports, {
|
|
31
|
+
getUseBuiltIns: () => getUseBuiltIns,
|
|
32
|
+
pluginBabel: () => pluginBabel
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(babel_exports);
|
|
35
|
+
var import_lodash = __toESM(require("lodash"));
|
|
36
|
+
var import_web = require("@rsbuild/babel-preset/web");
|
|
37
|
+
var import_node = require("@rsbuild/babel-preset/node");
|
|
38
|
+
var import_shared = require("@rsbuild/shared");
|
|
39
|
+
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
40
|
+
var import_shared2 = require("../shared");
|
|
41
|
+
const getUseBuiltIns = (config) => {
|
|
42
|
+
const { polyfill } = config.output;
|
|
43
|
+
if (polyfill === "ua" || polyfill === "off") {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return polyfill;
|
|
47
|
+
};
|
|
48
|
+
const pluginBabel = () => ({
|
|
49
|
+
name: "plugin-babel",
|
|
50
|
+
setup(api) {
|
|
51
|
+
api.modifyBundlerChain(
|
|
52
|
+
async (chain, { CHAIN_ID, target, isProd, isServer, isServiceWorker }) => {
|
|
53
|
+
const config = api.getNormalizedConfig();
|
|
54
|
+
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
|
|
55
|
+
api.context.rootPath,
|
|
56
|
+
config,
|
|
57
|
+
target
|
|
58
|
+
);
|
|
59
|
+
const getBabelOptions = (config2) => {
|
|
60
|
+
const includes2 = [];
|
|
61
|
+
const excludes2 = [];
|
|
62
|
+
const babelUtils = {
|
|
63
|
+
addIncludes(items) {
|
|
64
|
+
if (Array.isArray(items)) {
|
|
65
|
+
includes2.push(...items);
|
|
66
|
+
} else {
|
|
67
|
+
includes2.push(items);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
addExcludes(items) {
|
|
71
|
+
if (Array.isArray(items)) {
|
|
72
|
+
excludes2.push(...items);
|
|
73
|
+
} else {
|
|
74
|
+
excludes2.push(items);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const decoratorConfig = {
|
|
79
|
+
version: config2.output.enableLatestDecorators ? "2018-09" : "legacy"
|
|
80
|
+
};
|
|
81
|
+
const baseBabelConfig = isServer || isServiceWorker ? (0, import_node.getBabelConfigForNode)({
|
|
82
|
+
pluginDecorators: decoratorConfig
|
|
83
|
+
}) : (0, import_web.getBabelConfigForWeb)({
|
|
84
|
+
presetEnv: {
|
|
85
|
+
targets: browserslist,
|
|
86
|
+
useBuiltIns: getUseBuiltIns(config2)
|
|
87
|
+
},
|
|
88
|
+
pluginDecorators: decoratorConfig
|
|
89
|
+
});
|
|
90
|
+
applyPluginImport(baseBabelConfig, config2.source.transformImport);
|
|
91
|
+
applyPluginLodash(
|
|
92
|
+
baseBabelConfig,
|
|
93
|
+
config2.performance.transformLodash
|
|
94
|
+
);
|
|
95
|
+
const babelConfig = (0, import_shared.mergeChainedOptions)(
|
|
96
|
+
baseBabelConfig,
|
|
97
|
+
config2.tools.babel,
|
|
98
|
+
{
|
|
99
|
+
...(0, import_plugin_babel.getBabelUtils)(baseBabelConfig),
|
|
100
|
+
...babelUtils
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
const finalOptions = {
|
|
104
|
+
babelrc: false,
|
|
105
|
+
configFile: false,
|
|
106
|
+
compact: isProd,
|
|
107
|
+
...babelConfig
|
|
108
|
+
};
|
|
109
|
+
if (config2.output.charset === "utf8") {
|
|
110
|
+
finalOptions.generatorOpts = {
|
|
111
|
+
jsescOption: { minimal: true }
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
babelOptions: finalOptions,
|
|
116
|
+
includes: includes2,
|
|
117
|
+
excludes: excludes2
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const { babelOptions, includes, excludes } = getBabelOptions(config);
|
|
121
|
+
const useTsLoader = Boolean(config.tools.tsLoader);
|
|
122
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
123
|
+
(0, import_shared.applyScriptCondition)({
|
|
124
|
+
rule,
|
|
125
|
+
config,
|
|
126
|
+
context: api.context,
|
|
127
|
+
includes,
|
|
128
|
+
excludes
|
|
129
|
+
});
|
|
130
|
+
rule.test(useTsLoader ? import_shared.JS_REGEX : (0, import_shared.mergeRegex)(import_shared.JS_REGEX, import_shared.TS_REGEX)).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelOptions);
|
|
131
|
+
if (config.source.compileJsDataURI) {
|
|
132
|
+
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
133
|
+
or: ["text/javascript", "application/javascript"]
|
|
134
|
+
}).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(import_lodash.default.cloneDeep(babelOptions));
|
|
135
|
+
}
|
|
136
|
+
(0, import_shared.addCoreJsEntry)({ chain, config, isServer, isServiceWorker });
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
function applyPluginLodash(config, transformLodash) {
|
|
142
|
+
var _a;
|
|
143
|
+
if (transformLodash) {
|
|
144
|
+
(_a = config.plugins) == null ? void 0 : _a.push([(0, import_shared2.getCompiledPath)("babel-plugin-lodash"), {}]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function applyPluginImport(config, pluginImport) {
|
|
148
|
+
var _a, _b;
|
|
149
|
+
if (pluginImport !== false && pluginImport) {
|
|
150
|
+
for (const item of pluginImport) {
|
|
151
|
+
const name = item.libraryName;
|
|
152
|
+
const option = {
|
|
153
|
+
...item
|
|
154
|
+
};
|
|
155
|
+
if (option.camelToDashComponentName !== void 0 || option.camel2DashComponentName !== void 0) {
|
|
156
|
+
option.camel2DashComponentName = (_a = option.camel2DashComponentName) != null ? _a : option.camelToDashComponentName;
|
|
157
|
+
delete option.camelToDashComponentName;
|
|
158
|
+
}
|
|
159
|
+
(_b = config.plugins) == null ? void 0 : _b.push([
|
|
160
|
+
require.resolve("babel-plugin-import"),
|
|
161
|
+
option,
|
|
162
|
+
name
|
|
163
|
+
]);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
getUseBuiltIns,
|
|
170
|
+
pluginBabel
|
|
171
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
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 basic_exports = {};
|
|
30
|
+
__export(basic_exports, {
|
|
31
|
+
pluginBasic: () => pluginBasic
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(basic_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
const pluginBasic = () => ({
|
|
37
|
+
name: "plugin-basic",
|
|
38
|
+
setup(api) {
|
|
39
|
+
(0, import_shared.applyBasicPlugin)(api);
|
|
40
|
+
api.modifyWebpackChain(async (chain, { env, isServer, isWebWorker }) => {
|
|
41
|
+
const maxAssetSize = isServer || isWebWorker ? 30 * 1e3 * 1e3 : 3 * 1e3 * 1e3;
|
|
42
|
+
chain.performance.maxAssetSize(maxAssetSize);
|
|
43
|
+
chain.performance.maxEntrypointSize(maxAssetSize);
|
|
44
|
+
chain.module.parser.merge({
|
|
45
|
+
javascript: {
|
|
46
|
+
exportsPresence: "error"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (env === "development") {
|
|
50
|
+
chain.output.devtoolModuleFilenameTemplate(
|
|
51
|
+
(info) => import_path.default.resolve(info.absoluteResourcePath).replace(/\\/g, "/")
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
pluginBasic
|
|
60
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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 copy_exports = {};
|
|
30
|
+
__export(copy_exports, {
|
|
31
|
+
pluginCopy: () => pluginCopy
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(copy_exports);
|
|
34
|
+
var import_fs_extra = require("@rsbuild/shared/fs-extra");
|
|
35
|
+
const pluginCopy = () => ({
|
|
36
|
+
name: "plugin-copy",
|
|
37
|
+
setup(api) {
|
|
38
|
+
api.modifyWebpackChain(async (chain, { CHAIN_ID }) => {
|
|
39
|
+
const config = api.getNormalizedConfig();
|
|
40
|
+
const { copy } = config.output;
|
|
41
|
+
if (!copy) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const { default: CopyPlugin } = await Promise.resolve().then(() => __toESM(require("../../compiled/copy-webpack-plugin")));
|
|
45
|
+
const options = Array.isArray(copy) ? { patterns: copy } : copy;
|
|
46
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [options]);
|
|
47
|
+
});
|
|
48
|
+
api.modifyWebpackConfig(async (config) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
const copyPlugin = (_a = config.plugins) == null ? void 0 : _a.find(
|
|
51
|
+
(item) => (item == null ? void 0 : item.constructor.name) === "CopyPlugin"
|
|
52
|
+
);
|
|
53
|
+
if (copyPlugin) {
|
|
54
|
+
const isContextNotExists = copyPlugin.patterns.every(
|
|
55
|
+
(pattern) => typeof pattern !== "string" && pattern.context && !import_fs_extra.fs.existsSync(pattern.context)
|
|
56
|
+
);
|
|
57
|
+
if (isContextNotExists) {
|
|
58
|
+
config.plugins = (_b = config.plugins) == null ? void 0 : _b.filter(
|
|
59
|
+
(item) => (item == null ? void 0 : item.constructor.name) !== "CopyPlugin"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
pluginCopy
|
|
69
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ModifyChainUtils, type Context, type BundlerChainRule } from '@rsbuild/shared';
|
|
2
|
+
import type { RsbuildPlugin, NormalizedConfig } from '../types';
|
|
3
|
+
export declare function applyBaseCSSRule({
|
|
4
|
+
rule,
|
|
5
|
+
config,
|
|
6
|
+
context,
|
|
7
|
+
utils: {
|
|
8
|
+
target,
|
|
9
|
+
isProd,
|
|
10
|
+
isServer,
|
|
11
|
+
CHAIN_ID,
|
|
12
|
+
isWebWorker,
|
|
13
|
+
getCompiledPath
|
|
14
|
+
},
|
|
15
|
+
importLoaders
|
|
16
|
+
}: {
|
|
17
|
+
rule: BundlerChainRule;
|
|
18
|
+
config: NormalizedConfig;
|
|
19
|
+
context: Context;
|
|
20
|
+
utils: ModifyChainUtils;
|
|
21
|
+
importLoaders?: number;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
export declare const pluginCss: () => RsbuildPlugin;
|