@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,123 @@
|
|
|
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 css_exports = {};
|
|
30
|
+
__export(css_exports, {
|
|
31
|
+
applyBaseCSSRule: () => applyBaseCSSRule,
|
|
32
|
+
pluginCss: () => pluginCss
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(css_exports);
|
|
35
|
+
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
async function applyBaseCSSRule({
|
|
37
|
+
rule,
|
|
38
|
+
config,
|
|
39
|
+
context,
|
|
40
|
+
utils: { target, isProd, isServer, CHAIN_ID, isWebWorker, getCompiledPath },
|
|
41
|
+
importLoaders = 1
|
|
42
|
+
}) {
|
|
43
|
+
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
|
|
44
|
+
context.rootPath,
|
|
45
|
+
config,
|
|
46
|
+
target
|
|
47
|
+
);
|
|
48
|
+
const enableExtractCSS = (0, import_shared.isUseCssExtract)(config, target);
|
|
49
|
+
const enableCssMinify = !enableExtractCSS && isProd;
|
|
50
|
+
const enableSourceMap = (0, import_shared.isUseCssSourceMap)(config);
|
|
51
|
+
const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);
|
|
52
|
+
const extraCSSOptions = typeof config.tools.cssExtract === "object" ? config.tools.cssExtract : {
|
|
53
|
+
loaderOptions: {},
|
|
54
|
+
pluginOptions: {}
|
|
55
|
+
};
|
|
56
|
+
const styleLoaderOptions = (0, import_shared.mergeChainedOptions)(
|
|
57
|
+
{},
|
|
58
|
+
config.tools.styleLoader
|
|
59
|
+
);
|
|
60
|
+
const localIdentName = (0, import_shared.getCssModuleLocalIdentName)(config, isProd);
|
|
61
|
+
const cssLoaderOptions = await (0, import_shared.getCssLoaderOptions)({
|
|
62
|
+
config,
|
|
63
|
+
enableSourceMap,
|
|
64
|
+
importLoaders,
|
|
65
|
+
isServer,
|
|
66
|
+
isWebWorker,
|
|
67
|
+
localIdentName
|
|
68
|
+
});
|
|
69
|
+
if (!isServer && !isWebWorker) {
|
|
70
|
+
if (enableExtractCSS) {
|
|
71
|
+
rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(require("mini-css-extract-plugin").loader).options(extraCSSOptions.loaderOptions).end();
|
|
72
|
+
} else {
|
|
73
|
+
rule.use(CHAIN_ID.USE.STYLE).loader(require.resolve("style-loader")).options(styleLoaderOptions).end();
|
|
74
|
+
}
|
|
75
|
+
if (enableCSSModuleTS && cssLoaderOptions.modules) {
|
|
76
|
+
rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(
|
|
77
|
+
(0, import_shared.resolvePackage)(
|
|
78
|
+
"@rsbuild/shared/css-modules-typescript-loader",
|
|
79
|
+
__dirname
|
|
80
|
+
)
|
|
81
|
+
).options({
|
|
82
|
+
modules: cssLoaderOptions.modules
|
|
83
|
+
}).end();
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
rule.use(CHAIN_ID.USE.IGNORE_CSS).loader((0, import_shared.resolvePackage)("@rsbuild/shared/ignore-css-loader", __dirname)).end();
|
|
87
|
+
}
|
|
88
|
+
rule.use(CHAIN_ID.USE.CSS).loader(getCompiledPath("css-loader")).options(cssLoaderOptions).end();
|
|
89
|
+
if (!isServer && !isWebWorker) {
|
|
90
|
+
const postcssLoaderOptions = await (0, import_shared.getPostcssConfig)({
|
|
91
|
+
enableSourceMap,
|
|
92
|
+
browserslist,
|
|
93
|
+
config,
|
|
94
|
+
enableCssMinify
|
|
95
|
+
});
|
|
96
|
+
rule.use(CHAIN_ID.USE.POSTCSS).loader(getCompiledPath("postcss-loader")).options(postcssLoaderOptions).end();
|
|
97
|
+
}
|
|
98
|
+
rule.merge({ sideEffects: true });
|
|
99
|
+
rule.resolve.preferRelative(true);
|
|
100
|
+
}
|
|
101
|
+
const pluginCss = () => {
|
|
102
|
+
return {
|
|
103
|
+
name: "plugin-css",
|
|
104
|
+
setup(api) {
|
|
105
|
+
api.modifyBundlerChain(async (chain, utils) => {
|
|
106
|
+
const rule = chain.module.rule(utils.CHAIN_ID.RULE.CSS);
|
|
107
|
+
const config = api.getNormalizedConfig();
|
|
108
|
+
rule.test(import_shared.CSS_REGEX);
|
|
109
|
+
await applyBaseCSSRule({
|
|
110
|
+
rule,
|
|
111
|
+
utils,
|
|
112
|
+
config,
|
|
113
|
+
context: api.context
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
+
0 && (module.exports = {
|
|
121
|
+
applyBaseCSSRule,
|
|
122
|
+
pluginCss
|
|
123
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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 fallback_exports = {};
|
|
20
|
+
__export(fallback_exports, {
|
|
21
|
+
pluginFallback: () => pluginFallback
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(fallback_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_shared = require("@rsbuild/shared");
|
|
26
|
+
const pluginFallback = () => ({
|
|
27
|
+
name: "plugin-fallback",
|
|
28
|
+
setup(api) {
|
|
29
|
+
api.modifyWebpackChain((chain, { isProd }) => {
|
|
30
|
+
const rsbuildConfig = api.getNormalizedConfig();
|
|
31
|
+
if (rsbuildConfig.output.enableAssetFallback) {
|
|
32
|
+
const distDir = (0, import_shared.getDistPath)(rsbuildConfig.output, "media");
|
|
33
|
+
const filename = (0, import_shared.getFilename)(rsbuildConfig.output, "media", isProd);
|
|
34
|
+
chain.output.merge({
|
|
35
|
+
assetModuleFilename: (0, import_path.join)(distDir, filename)
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
api.modifyWebpackConfig((config) => {
|
|
40
|
+
const rsbuildConfig = api.getNormalizedConfig();
|
|
41
|
+
if (!rsbuildConfig.output.enableAssetFallback || !config.module) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
config.module.rules = (0, import_shared.resourceRuleFallback)(config.module.rules);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
pluginFallback
|
|
51
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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 hmr_exports = {};
|
|
20
|
+
__export(hmr_exports, {
|
|
21
|
+
pluginHMR: () => pluginHMR
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(hmr_exports);
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
const pluginHMR = () => ({
|
|
26
|
+
name: "plugin-hmr",
|
|
27
|
+
setup(api) {
|
|
28
|
+
api.modifyWebpackChain((chain, utils) => {
|
|
29
|
+
const config = api.getNormalizedConfig();
|
|
30
|
+
if (!(0, import_shared.isUsingHMR)(config, utils)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const { webpack, CHAIN_ID } = utils;
|
|
34
|
+
chain.plugin(CHAIN_ID.PLUGIN.HMR).use(webpack.HotModuleReplacementPlugin);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
pluginHMR
|
|
41
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
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 lazyCompilation_exports = {};
|
|
20
|
+
__export(lazyCompilation_exports, {
|
|
21
|
+
pluginLazyCompilation: () => pluginLazyCompilation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(lazyCompilation_exports);
|
|
24
|
+
const pluginLazyCompilation = () => ({
|
|
25
|
+
name: "plugin-lazy-compilation",
|
|
26
|
+
setup(api) {
|
|
27
|
+
api.modifyWebpackChain((chain, { isProd, isServer, isWebWorker }) => {
|
|
28
|
+
const config = api.getNormalizedConfig();
|
|
29
|
+
if (isProd || isServer || isWebWorker || !config.experiments.lazyCompilation) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
chain.optimization.splitChunks(false);
|
|
33
|
+
chain.experiments({
|
|
34
|
+
...chain.get("experiments"),
|
|
35
|
+
lazyCompilation: config.experiments.lazyCompilation
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
pluginLazyCompilation
|
|
43
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
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 less_exports = {};
|
|
30
|
+
__export(less_exports, {
|
|
31
|
+
pluginLess: () => pluginLess
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(less_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
function pluginLess() {
|
|
36
|
+
return {
|
|
37
|
+
name: "plugin-less",
|
|
38
|
+
setup(api) {
|
|
39
|
+
api.modifyBundlerChain(async (chain, utils) => {
|
|
40
|
+
const config = api.getNormalizedConfig();
|
|
41
|
+
const { applyBaseCSSRule } = await Promise.resolve().then(() => __toESM(require("./css")));
|
|
42
|
+
const { options, excludes } = await (0, import_shared.getLessLoaderOptions)(
|
|
43
|
+
config.tools.less,
|
|
44
|
+
(0, import_shared.isUseCssSourceMap)(config)
|
|
45
|
+
);
|
|
46
|
+
const rule = chain.module.rule(utils.CHAIN_ID.RULE.LESS).test(import_shared.LESS_REGEX);
|
|
47
|
+
excludes.forEach((item) => {
|
|
48
|
+
rule.exclude.add(item);
|
|
49
|
+
});
|
|
50
|
+
await applyBaseCSSRule({
|
|
51
|
+
rule,
|
|
52
|
+
utils,
|
|
53
|
+
config,
|
|
54
|
+
context: api.context,
|
|
55
|
+
importLoaders: 2
|
|
56
|
+
});
|
|
57
|
+
rule.use(utils.CHAIN_ID.USE.LESS).loader(utils.getCompiledPath("less-loader")).options(options);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
pluginLess
|
|
65
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
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 manifest_exports = {};
|
|
30
|
+
__export(manifest_exports, {
|
|
31
|
+
pluginManifest: () => pluginManifest
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(manifest_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
const pluginManifest = () => ({
|
|
36
|
+
name: "plugin-manifest",
|
|
37
|
+
setup(api) {
|
|
38
|
+
api.modifyWebpackChain(async (chain, { CHAIN_ID }) => {
|
|
39
|
+
const config = api.getNormalizedConfig();
|
|
40
|
+
if (!config.output.enableAssetManifest) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { WebpackManifestPlugin } = await Promise.resolve().then(() => __toESM(require("../../compiled/webpack-manifest-plugin")));
|
|
44
|
+
const publicPath = chain.output.get("publicPath");
|
|
45
|
+
chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(WebpackManifestPlugin, [
|
|
46
|
+
{
|
|
47
|
+
fileName: "asset-manifest.json",
|
|
48
|
+
publicPath,
|
|
49
|
+
generate: import_shared.generateManifest
|
|
50
|
+
}
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
pluginManifest
|
|
58
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
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: "plugin-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
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ChainedConfig } from '@rsbuild/shared';
|
|
2
|
+
import type { RsbuildPlugin, ModuleScopes } from '../types';
|
|
3
|
+
export declare const isPrimitiveScope: (items: unknown[]) => items is (string | RegExp)[];
|
|
4
|
+
export declare const applyScopeChain: (defaults: ModuleScopes, options: ChainedConfig<ModuleScopes>) => ModuleScopes;
|
|
5
|
+
export declare const pluginModuleScopes: () => RsbuildPlugin;
|
|
@@ -0,0 +1,85 @@
|
|
|
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 moduleScopes_exports = {};
|
|
30
|
+
__export(moduleScopes_exports, {
|
|
31
|
+
applyScopeChain: () => applyScopeChain,
|
|
32
|
+
isPrimitiveScope: () => isPrimitiveScope,
|
|
33
|
+
pluginModuleScopes: () => pluginModuleScopes
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(moduleScopes_exports);
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_shared = require("@rsbuild/shared");
|
|
38
|
+
const isPrimitiveScope = (items) => items.every(
|
|
39
|
+
(item) => typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]"
|
|
40
|
+
);
|
|
41
|
+
const applyScopeChain = (defaults, options) => {
|
|
42
|
+
if (Array.isArray(options)) {
|
|
43
|
+
if (isPrimitiveScope(options)) {
|
|
44
|
+
return defaults.concat(options);
|
|
45
|
+
}
|
|
46
|
+
return options.reduce(applyScopeChain, defaults);
|
|
47
|
+
}
|
|
48
|
+
return options(defaults) || defaults;
|
|
49
|
+
};
|
|
50
|
+
const pluginModuleScopes = () => ({
|
|
51
|
+
name: "plugin-module-scopes",
|
|
52
|
+
setup(api) {
|
|
53
|
+
api.modifyWebpackChain(async (chain, { CHAIN_ID }) => {
|
|
54
|
+
const config = api.getNormalizedConfig();
|
|
55
|
+
const scopeOptions = config.source.moduleScopes;
|
|
56
|
+
if (!scopeOptions) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const { ModuleScopePlugin } = await Promise.resolve().then(() => __toESM(require("../webpackPlugins/ModuleScopePlugin")));
|
|
60
|
+
const scopes = applyScopeChain([], scopeOptions);
|
|
61
|
+
const rootPackageJson = import_path.default.resolve(
|
|
62
|
+
api.context.rootPath,
|
|
63
|
+
"./package.json"
|
|
64
|
+
);
|
|
65
|
+
const formattedScopes = scopes.map((scope) => {
|
|
66
|
+
if (typeof scope === "string") {
|
|
67
|
+
return (0, import_shared.ensureAbsolutePath)(api.context.rootPath, scope);
|
|
68
|
+
}
|
|
69
|
+
return scope;
|
|
70
|
+
});
|
|
71
|
+
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.MODULE_SCOPE).use(ModuleScopePlugin, [
|
|
72
|
+
{
|
|
73
|
+
scopes: formattedScopes,
|
|
74
|
+
allowedFiles: [rootPackageJson]
|
|
75
|
+
}
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
applyScopeChain,
|
|
83
|
+
isPrimitiveScope,
|
|
84
|
+
pluginModuleScopes
|
|
85
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
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: "plugin-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
|
+
{},
|
|
48
|
+
((_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
|
+
});
|