@modern-js/builder 2.46.0 → 3.0.0-alpha.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/LICENSE +1 -1
- package/README.md +14 -16
- package/compiled/postcss-load-config/index.d.ts +1 -0
- package/compiled/postcss-load-config/index.js +14 -0
- package/compiled/postcss-load-config/license +20 -0
- package/compiled/postcss-load-config/package.json +1 -0
- package/dist/createBuilder.d.ts +8 -2
- package/dist/createBuilder.js +124 -39
- package/dist/index.d.ts +8 -4
- package/dist/index.js +18 -7
- package/dist/plugins/babel-post.d.ts +5 -0
- package/dist/plugins/{asset.js → babel-post.js} +21 -22
- package/dist/plugins/devtools.d.ts +4 -0
- package/dist/plugins/{devtool.js → devtools.js} +15 -16
- package/dist/plugins/emitRouteFile.d.ts +6 -0
- package/dist/plugins/{cleanOutput.js → emitRouteFile.js} +34 -16
- package/dist/plugins/environmentDefaults.d.ts +3 -0
- package/dist/plugins/environmentDefaults.js +99 -0
- package/dist/plugins/globalVars.d.ts +3 -0
- package/dist/plugins/{moment.js → globalVars.js} +23 -16
- package/dist/plugins/htmlMinify.d.ts +2 -0
- package/dist/plugins/htmlMinify.js +126 -0
- package/dist/plugins/manifest.d.ts +2 -0
- package/dist/plugins/{entry.js → manifest.js} +18 -16
- package/dist/plugins/postcss.d.ts +6 -0
- package/dist/plugins/postcss.js +133 -0
- package/dist/plugins/runtimeChunk.d.ts +2 -0
- package/dist/plugins/runtimeChunk.js +55 -0
- package/dist/rsc/common.d.ts +22 -0
- package/dist/rsc/common.js +174 -0
- package/dist/rsc/plugins/rsbuild-rsc-plugin.d.ts +7 -0
- package/dist/rsc/plugins/rsbuild-rsc-plugin.js +166 -0
- package/dist/rsc/plugins/rspack-rsc-client-plugin.d.ts +14 -0
- package/dist/rsc/plugins/rspack-rsc-client-plugin.js +233 -0
- package/dist/rsc/plugins/rspack-rsc-server-plugin.d.ts +32 -0
- package/dist/rsc/plugins/rspack-rsc-server-plugin.js +290 -0
- package/dist/rsc/rsc-client-loader.d.ts +7 -0
- package/dist/rsc/rsc-client-loader.js +70 -0
- package/dist/rsc/rsc-css-loader.d.ts +2 -0
- package/dist/{plugins/yaml.js → rsc/rsc-css-loader.js} +11 -17
- package/dist/rsc/rsc-server-loader.d.ts +6 -0
- package/dist/rsc/rsc-server-loader.js +95 -0
- package/dist/rsc/rsc-ssr-loader.d.ts +6 -0
- package/dist/rsc/rsc-ssr-loader.js +58 -0
- package/dist/shared/devServer.d.ts +6 -0
- package/dist/shared/devServer.js +83 -0
- package/dist/shared/getCssSupport.d.ts +1 -0
- package/dist/shared/getCssSupport.js +113 -0
- package/dist/shared/manifest.d.ts +2 -0
- package/dist/{plugins/toml.js → shared/manifest.js} +16 -14
- package/dist/shared/parseCommonConfig.d.ts +8 -0
- package/dist/shared/parseCommonConfig.js +232 -0
- package/dist/shared/utils.d.ts +12 -0
- package/dist/shared/utils.js +109 -0
- package/dist/types.d.ts +283 -0
- package/dist/types.js +16 -0
- package/package.json +54 -59
- package/dist/cli/commands.d.ts +0 -2
- package/dist/cli/commands.js +0 -45
- package/dist/cli/config.d.ts +0 -14
- package/dist/cli/config.js +0 -72
- package/dist/cli/index.d.ts +0 -6
- package/dist/cli/index.js +0 -51
- package/dist/cli/provider.d.ts +0 -2
- package/dist/cli/provider.js +0 -73
- package/dist/plugins/antd.d.ts +0 -3
- package/dist/plugins/antd.js +0 -63
- package/dist/plugins/arco.d.ts +0 -2
- package/dist/plugins/arco.js +0 -61
- package/dist/plugins/asset.d.ts +0 -2
- package/dist/plugins/assetsRetry.d.ts +0 -2
- package/dist/plugins/assetsRetry.js +0 -64
- package/dist/plugins/bundleAnalyzer.d.ts +0 -2
- package/dist/plugins/bundleAnalyzer.js +0 -59
- package/dist/plugins/cache.d.ts +0 -2
- package/dist/plugins/cache.js +0 -129
- package/dist/plugins/checkSyntax.d.ts +0 -2
- package/dist/plugins/checkSyntax.js +0 -73
- package/dist/plugins/cleanOutput.d.ts +0 -2
- package/dist/plugins/define.d.ts +0 -2
- package/dist/plugins/define.js +0 -68
- package/dist/plugins/devtool.d.ts +0 -2
- package/dist/plugins/entry.d.ts +0 -2
- package/dist/plugins/externals.d.ts +0 -2
- package/dist/plugins/externals.js +0 -48
- package/dist/plugins/fileSize.d.ts +0 -4
- package/dist/plugins/fileSize.js +0 -164
- package/dist/plugins/html.d.ts +0 -3
- package/dist/plugins/html.js +0 -236
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/index.js +0 -74
- package/dist/plugins/inlineChunk.d.ts +0 -2
- package/dist/plugins/inlineChunk.js +0 -82
- package/dist/plugins/moment.d.ts +0 -2
- package/dist/plugins/networkPerformance.d.ts +0 -2
- package/dist/plugins/networkPerformance.js +0 -54
- package/dist/plugins/nodeAddons.d.ts +0 -2
- package/dist/plugins/nodeAddons.js +0 -73
- package/dist/plugins/performance.d.ts +0 -5
- package/dist/plugins/performance.js +0 -66
- package/dist/plugins/preloadOrPrefetch.d.ts +0 -2
- package/dist/plugins/preloadOrPrefetch.js +0 -57
- package/dist/plugins/rem.d.ts +0 -2
- package/dist/plugins/rem.js +0 -106
- package/dist/plugins/sourceBuild.d.ts +0 -15
- package/dist/plugins/sourceBuild.js +0 -121
- package/dist/plugins/splitChunks.d.ts +0 -4
- package/dist/plugins/splitChunks.js +0 -249
- package/dist/plugins/startUrl.d.ts +0 -3
- package/dist/plugins/startUrl.js +0 -86
- package/dist/plugins/svg.d.ts +0 -2
- package/dist/plugins/svg.js +0 -89
- package/dist/plugins/target.d.ts +0 -2
- package/dist/plugins/target.js +0 -73
- package/dist/plugins/toml.d.ts +0 -2
- package/dist/plugins/tsChecker.d.ts +0 -2
- package/dist/plugins/tsChecker.js +0 -109
- package/dist/plugins/wasm.d.ts +0 -2
- package/dist/plugins/wasm.js +0 -51
- package/dist/plugins/yaml.d.ts +0 -2
- package/vitest.config.ts +0 -19
|
@@ -0,0 +1,99 @@
|
|
|
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 environmentDefaults_exports = {};
|
|
20
|
+
__export(environmentDefaults_exports, {
|
|
21
|
+
pluginEnvironmentDefaults: () => pluginEnvironmentDefaults
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(environmentDefaults_exports);
|
|
24
|
+
var import_node_path = require("node:path");
|
|
25
|
+
var import_utils = require("../shared/utils");
|
|
26
|
+
const pluginEnvironmentDefaults = (distPath = {}) => ({
|
|
27
|
+
name: "builder:environment-defaults-plugin",
|
|
28
|
+
setup(api) {
|
|
29
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {
|
|
30
|
+
var _config_environments, _config_environments1;
|
|
31
|
+
const compatConfig = {};
|
|
32
|
+
if ((_config_environments = config.environments) === null || _config_environments === void 0 ? void 0 : _config_environments[import_utils.SERVICE_WORKER_ENVIRONMENT_NAME]) {
|
|
33
|
+
var _compatConfig;
|
|
34
|
+
var _environments;
|
|
35
|
+
(_environments = (_compatConfig = compatConfig).environments) !== null && _environments !== void 0 ? _environments : _compatConfig.environments = {};
|
|
36
|
+
compatConfig.environments[import_utils.SERVICE_WORKER_ENVIRONMENT_NAME] = {
|
|
37
|
+
output: {
|
|
38
|
+
polyfill: "off",
|
|
39
|
+
distPath: {
|
|
40
|
+
root: (0, import_node_path.join)(distPath.root || "dist", distPath.worker || "worker"),
|
|
41
|
+
js: "",
|
|
42
|
+
css: "",
|
|
43
|
+
jsAsync: "",
|
|
44
|
+
cssAsync: ""
|
|
45
|
+
},
|
|
46
|
+
filename: {
|
|
47
|
+
js: "[name].js"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if ((_config_environments1 = config.environments) === null || _config_environments1 === void 0 ? void 0 : _config_environments1.node) {
|
|
53
|
+
var _compatConfig1;
|
|
54
|
+
var _environments1;
|
|
55
|
+
(_environments1 = (_compatConfig1 = compatConfig).environments) !== null && _environments1 !== void 0 ? _environments1 : _compatConfig1.environments = {};
|
|
56
|
+
compatConfig.environments.node = {
|
|
57
|
+
output: {
|
|
58
|
+
// no need to emit assets for SSR bundles
|
|
59
|
+
emitAssets: false,
|
|
60
|
+
distPath: {
|
|
61
|
+
root: (0, import_node_path.join)(distPath.root || "dist", distPath.server || "bundles"),
|
|
62
|
+
js: "",
|
|
63
|
+
css: "",
|
|
64
|
+
jsAsync: "",
|
|
65
|
+
cssAsync: ""
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return compatConfig.environments ? mergeRsbuildConfig(compatConfig, config) : config;
|
|
71
|
+
});
|
|
72
|
+
api.modifyRsbuildConfig({
|
|
73
|
+
handler: (config) => {
|
|
74
|
+
const environmentNameOrder = [
|
|
75
|
+
"web",
|
|
76
|
+
"node",
|
|
77
|
+
"workerSSR"
|
|
78
|
+
];
|
|
79
|
+
config.environments = Object.fromEntries(Object.entries(config.environments).sort((a1, a2) => environmentNameOrder.includes(a1[0]) ? environmentNameOrder.indexOf(a1[0]) - environmentNameOrder.indexOf(a2[0]) : 1));
|
|
80
|
+
},
|
|
81
|
+
order: "post"
|
|
82
|
+
});
|
|
83
|
+
api.modifyEnvironmentConfig(async (config, { name }) => {
|
|
84
|
+
var _config_output;
|
|
85
|
+
var _overrideBrowserslist;
|
|
86
|
+
(_overrideBrowserslist = (_config_output = config.output).overrideBrowserslist) !== null && _overrideBrowserslist !== void 0 ? _overrideBrowserslist : _config_output.overrideBrowserslist = await (0, import_utils.getBrowserslistWithDefault)(api.context.rootPath, config, name === import_utils.SERVICE_WORKER_ENVIRONMENT_NAME ? "node" : config.output.target);
|
|
87
|
+
});
|
|
88
|
+
api.modifyBundlerChain(async (chain, { environment }) => {
|
|
89
|
+
const isServiceWorker = environment.name === import_utils.SERVICE_WORKER_ENVIRONMENT_NAME;
|
|
90
|
+
if (isServiceWorker) {
|
|
91
|
+
chain.output.libraryTarget("commonjs2");
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
97
|
+
0 && (module.exports = {
|
|
98
|
+
pluginEnvironmentDefaults
|
|
99
|
+
});
|
|
@@ -16,28 +16,35 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var globalVars_exports = {};
|
|
20
|
+
__export(globalVars_exports, {
|
|
21
|
+
pluginGlobalVars: () => pluginGlobalVars
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
module.exports = __toCommonJS(globalVars_exports);
|
|
24
|
+
var import_utils = require("@modern-js/utils");
|
|
25
|
+
const pluginGlobalVars = (options) => ({
|
|
26
|
+
name: "builder:global-vars",
|
|
26
27
|
setup(api) {
|
|
27
|
-
api.modifyBundlerChain(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
chain.plugin("remove-moment-locale").use(webpack.IgnorePlugin, [
|
|
31
|
-
{
|
|
32
|
-
resourceRegExp: /^\.\/locale$/,
|
|
33
|
-
contextRegExp: /moment$/
|
|
34
|
-
}
|
|
35
|
-
]);
|
|
28
|
+
api.modifyBundlerChain((chain, { env, target, bundler }) => {
|
|
29
|
+
if (!options) {
|
|
30
|
+
return;
|
|
36
31
|
}
|
|
32
|
+
const globalVars = (0, import_utils.applyOptionsChain)({}, options, {
|
|
33
|
+
env,
|
|
34
|
+
target
|
|
35
|
+
});
|
|
36
|
+
const serializedVars = {};
|
|
37
|
+
Object.entries(globalVars).forEach(([key, value]) => {
|
|
38
|
+
var _JSON_stringify;
|
|
39
|
+
serializedVars[key] = (_JSON_stringify = JSON.stringify(value)) !== null && _JSON_stringify !== void 0 ? _JSON_stringify : "undefined";
|
|
40
|
+
});
|
|
41
|
+
chain.plugin("globalVars").use(bundler.DefinePlugin, [
|
|
42
|
+
serializedVars
|
|
43
|
+
]);
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
});
|
|
40
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
48
|
0 && (module.exports = {
|
|
42
|
-
|
|
49
|
+
pluginGlobalVars
|
|
43
50
|
});
|
|
@@ -0,0 +1,126 @@
|
|
|
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 htmlMinify_exports = {};
|
|
30
|
+
__export(htmlMinify_exports, {
|
|
31
|
+
pluginHtmlMinifierTerser: () => pluginHtmlMinifierTerser
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(htmlMinify_exports);
|
|
34
|
+
var import_ts_deepmerge = require("ts-deepmerge");
|
|
35
|
+
function applyRemoveConsole(options, config) {
|
|
36
|
+
const { removeConsole } = config.performance;
|
|
37
|
+
const compressOptions = typeof options.compress === "boolean" ? {} : options.compress || {};
|
|
38
|
+
if (removeConsole === true) {
|
|
39
|
+
options.compress = {
|
|
40
|
+
...compressOptions,
|
|
41
|
+
drop_console: true
|
|
42
|
+
};
|
|
43
|
+
} else if (Array.isArray(removeConsole)) {
|
|
44
|
+
const pureFuncs = removeConsole.map((method) => `console.${method}`);
|
|
45
|
+
options.compress = {
|
|
46
|
+
...compressOptions,
|
|
47
|
+
pure_funcs: pureFuncs
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return options;
|
|
51
|
+
}
|
|
52
|
+
function getTerserMinifyOptions(config) {
|
|
53
|
+
const options = {
|
|
54
|
+
mangle: {
|
|
55
|
+
safari10: true
|
|
56
|
+
},
|
|
57
|
+
format: {
|
|
58
|
+
ascii_only: config.output.charset === "ascii"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
if (config.output.legalComments === "none") {
|
|
62
|
+
var _options;
|
|
63
|
+
(_options = options).format || (_options.format = {});
|
|
64
|
+
options.format.comments = false;
|
|
65
|
+
}
|
|
66
|
+
const finalOptions = applyRemoveConsole(options, config);
|
|
67
|
+
return finalOptions;
|
|
68
|
+
}
|
|
69
|
+
function getMinifyOptions(config) {
|
|
70
|
+
const minifyJS = getTerserMinifyOptions(config);
|
|
71
|
+
return {
|
|
72
|
+
removeComments: false,
|
|
73
|
+
useShortDoctype: true,
|
|
74
|
+
keepClosingSlash: true,
|
|
75
|
+
collapseWhitespace: true,
|
|
76
|
+
removeRedundantAttributes: true,
|
|
77
|
+
removeScriptTypeAttributes: true,
|
|
78
|
+
removeStyleLinkTypeAttributes: true,
|
|
79
|
+
removeEmptyAttributes: true,
|
|
80
|
+
minifyJS,
|
|
81
|
+
minifyCSS: true,
|
|
82
|
+
minifyURLs: true
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const pluginHtmlMinifierTerser = () => ({
|
|
86
|
+
name: "builder:plugin-html-minifier-terser",
|
|
87
|
+
setup(api) {
|
|
88
|
+
api.modifyBundlerChain(async (chain, { isProd, environment }) => {
|
|
89
|
+
const { output, tools: { htmlPlugin } } = environment.config;
|
|
90
|
+
const disableHtmlMinify = !isProd || output.minify === false || htmlPlugin === false;
|
|
91
|
+
const { minify } = await Promise.resolve().then(() => __toESM(require("html-minifier-terser")));
|
|
92
|
+
const pluginRecord = chain.plugins.entries();
|
|
93
|
+
const minifyOptions = getMinifyOptions(environment.config);
|
|
94
|
+
for (const id of Object.keys(pluginRecord)) {
|
|
95
|
+
if (!id.startsWith("html-")) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
const values = pluginRecord[id].values();
|
|
99
|
+
const isHtmlRspackPlugin = values.some((item) => {
|
|
100
|
+
var _item_constructor;
|
|
101
|
+
const name = (item === null || item === void 0 ? void 0 : item.name) || ((_item_constructor = item.constructor) === null || _item_constructor === void 0 ? void 0 : _item_constructor.name);
|
|
102
|
+
return name === "HtmlRspackPlugin";
|
|
103
|
+
});
|
|
104
|
+
if (isHtmlRspackPlugin && !disableHtmlMinify) {
|
|
105
|
+
chain.plugin(id).tap((options) => {
|
|
106
|
+
if (!options.length) {
|
|
107
|
+
return options;
|
|
108
|
+
}
|
|
109
|
+
const userMinifyOption = options[0].minify;
|
|
110
|
+
if (userMinifyOption === false) {
|
|
111
|
+
return options;
|
|
112
|
+
}
|
|
113
|
+
const minifyFn = (html) => minify(html, userMinifyOption ? (0, import_ts_deepmerge.merge)(minifyOptions, userMinifyOption) : minifyOptions);
|
|
114
|
+
options[0].minify = minifyFn;
|
|
115
|
+
return options;
|
|
116
|
+
});
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
pluginHtmlMinifierTerser
|
|
126
|
+
});
|
|
@@ -26,27 +26,29 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
29
|
+
var manifest_exports = {};
|
|
30
|
+
__export(manifest_exports, {
|
|
31
|
+
pluginManifest: () => pluginManifest
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
var
|
|
35
|
-
const
|
|
36
|
-
name: "builder
|
|
33
|
+
module.exports = __toCommonJS(manifest_exports);
|
|
34
|
+
var import_manifest = require("../shared/manifest");
|
|
35
|
+
const pluginManifest = () => ({
|
|
36
|
+
name: "builder:manifest",
|
|
37
37
|
setup(api) {
|
|
38
|
-
api.modifyBundlerChain(async (chain) => {
|
|
39
|
-
const {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
api.modifyBundlerChain(async (chain, { target, CHAIN_ID }) => {
|
|
39
|
+
const { RspackManifestPlugin } = await Promise.resolve().then(() => __toESM(require("rspack-manifest-plugin")));
|
|
40
|
+
const publicPath = chain.output.get("publicPath");
|
|
41
|
+
chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
|
|
42
|
+
{
|
|
43
|
+
fileName: target === "web" ? "asset-manifest.json" : `asset-manifest-${target}.json`,
|
|
44
|
+
publicPath,
|
|
45
|
+
generate: import_manifest.generateManifest
|
|
46
|
+
}
|
|
47
|
+
]);
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
50
|
});
|
|
49
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
52
|
0 && (module.exports = {
|
|
51
|
-
|
|
53
|
+
pluginManifest
|
|
52
54
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
import type { ToolsAutoprefixerConfig } from '../types';
|
|
3
|
+
export interface PluginPostcssOptions {
|
|
4
|
+
autoprefixer?: ToolsAutoprefixerConfig;
|
|
5
|
+
}
|
|
6
|
+
export declare const pluginPostcss: (options?: PluginPostcssOptions) => RsbuildPlugin;
|
|
@@ -0,0 +1,133 @@
|
|
|
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 postcss_exports = {};
|
|
30
|
+
__export(postcss_exports, {
|
|
31
|
+
pluginPostcss: () => pluginPostcss
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(postcss_exports);
|
|
34
|
+
var import_utils = require("@modern-js/utils");
|
|
35
|
+
var import_getCssSupport = require("../shared/getCssSupport");
|
|
36
|
+
const userPostcssrcCache = /* @__PURE__ */ new Map();
|
|
37
|
+
const clonePostCSSConfig = (config) => ({
|
|
38
|
+
...config,
|
|
39
|
+
plugins: config.plugins ? [
|
|
40
|
+
...config.plugins
|
|
41
|
+
] : void 0
|
|
42
|
+
});
|
|
43
|
+
async function loadUserPostcssrc(root) {
|
|
44
|
+
const cached = userPostcssrcCache.get(root);
|
|
45
|
+
if (cached) {
|
|
46
|
+
return clonePostCSSConfig(await cached);
|
|
47
|
+
}
|
|
48
|
+
const { default: postcssrc } = await Promise.resolve().then(() => __toESM(require("../../compiled/postcss-load-config")));
|
|
49
|
+
const promise = postcssrc({}, root).catch((err) => {
|
|
50
|
+
var _err_message;
|
|
51
|
+
if ((_err_message = err.message) === null || _err_message === void 0 ? void 0 : _err_message.includes("No PostCSS Config found")) {
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
throw err;
|
|
55
|
+
});
|
|
56
|
+
userPostcssrcCache.set(root, promise);
|
|
57
|
+
return promise.then((config) => {
|
|
58
|
+
userPostcssrcCache.set(root, config);
|
|
59
|
+
return clonePostCSSConfig(config);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const pluginPostcss = (options = {}) => ({
|
|
63
|
+
name: "builder:postcss-plugins",
|
|
64
|
+
pre: [
|
|
65
|
+
"builder:environment-defaults-plugin"
|
|
66
|
+
],
|
|
67
|
+
setup(api) {
|
|
68
|
+
const { autoprefixer } = options;
|
|
69
|
+
api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig }) => {
|
|
70
|
+
var _config_output;
|
|
71
|
+
if (config.output.target !== "web") {
|
|
72
|
+
return config;
|
|
73
|
+
}
|
|
74
|
+
const cssSupport = (0, import_getCssSupport.getCssSupport)(config.output.overrideBrowserslist);
|
|
75
|
+
const enableExtractCSS = !((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.injectStyles);
|
|
76
|
+
const enableCssMinify = !enableExtractCSS && (0, import_utils.isProd)();
|
|
77
|
+
const cssnanoOptions = {
|
|
78
|
+
preset: [
|
|
79
|
+
"default",
|
|
80
|
+
{
|
|
81
|
+
// merge longhand will break safe-area-inset-top, so disable it
|
|
82
|
+
// https://github.com/cssnano/cssnano/issues/803
|
|
83
|
+
// https://github.com/cssnano/cssnano/issues/967
|
|
84
|
+
mergeLonghand: false,
|
|
85
|
+
/**
|
|
86
|
+
* normalizeUrl will transform relative url from `./assets/img.svg` to `assets/img.svg`.
|
|
87
|
+
* It may break the behavior of webpack resolver while using style-loader.
|
|
88
|
+
* So disable it while `output.injectStyles = true`
|
|
89
|
+
*/
|
|
90
|
+
normalizeUrl: false
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
const plugins = [
|
|
95
|
+
require("postcss-flexbugs-fixes"),
|
|
96
|
+
!cssSupport.customProperties && require("postcss-custom-properties"),
|
|
97
|
+
!cssSupport.initial && require("postcss-initial"),
|
|
98
|
+
!cssSupport.pageBreak && require("postcss-page-break"),
|
|
99
|
+
!cssSupport.fontVariant && require("postcss-font-variant"),
|
|
100
|
+
!cssSupport.mediaMinmax && require("postcss-media-minmax"),
|
|
101
|
+
require("postcss-nesting"),
|
|
102
|
+
enableCssMinify ? require("cssnano")(cssnanoOptions) : false,
|
|
103
|
+
// The last insert autoprefixer
|
|
104
|
+
require("autoprefixer")((0, import_utils.applyOptionsChain)({
|
|
105
|
+
flexbox: "no-2009",
|
|
106
|
+
overrideBrowserslist: config.output.overrideBrowserslist
|
|
107
|
+
}, autoprefixer))
|
|
108
|
+
].filter(Boolean);
|
|
109
|
+
const userOptions = await loadUserPostcssrc(api.context.rootPath);
|
|
110
|
+
return mergeEnvironmentConfig(
|
|
111
|
+
{
|
|
112
|
+
tools: {
|
|
113
|
+
postcss: {
|
|
114
|
+
postcssOptions: {
|
|
115
|
+
...userOptions,
|
|
116
|
+
plugins: [
|
|
117
|
+
...userOptions.plugins || [],
|
|
118
|
+
...plugins
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
// user config has higher priority than builtin config
|
|
125
|
+
config
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
+
0 && (module.exports = {
|
|
132
|
+
pluginPostcss
|
|
133
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
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 runtimeChunk_exports = {};
|
|
20
|
+
__export(runtimeChunk_exports, {
|
|
21
|
+
pluginRuntimeChunk: () => pluginRuntimeChunk
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(runtimeChunk_exports);
|
|
24
|
+
var import_utils = require("../shared/utils");
|
|
25
|
+
const pluginRuntimeChunk = (disableInlineRuntimeChunk) => ({
|
|
26
|
+
name: "builder:runtime-chunk",
|
|
27
|
+
setup(api) {
|
|
28
|
+
api.modifyBundlerChain(async (chain, { target, environment }) => {
|
|
29
|
+
if (target !== "web") {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const { config } = environment;
|
|
33
|
+
const { chunkSplit } = config.performance;
|
|
34
|
+
if (chunkSplit.strategy !== "all-in-one") {
|
|
35
|
+
chain.optimization.runtimeChunk({
|
|
36
|
+
name: import_utils.RUNTIME_CHUNK_NAME
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
api.modifyRsbuildConfig((config) => {
|
|
41
|
+
var _config;
|
|
42
|
+
(_config = config).output || (_config.output = {});
|
|
43
|
+
if (disableInlineRuntimeChunk) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!config.output.inlineScripts) {
|
|
47
|
+
config.output.inlineScripts = import_utils.RUNTIME_CHUNK_REGEX;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
pluginRuntimeChunk
|
|
55
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { ClientReference, ImportManifestEntry, ModuleLoading, SSRManifest, SSRModuleMap, ClientReferencesMap, ServerReferencesMap, ServerManifest, ServerReferencesModuleInfo, ClientManifest, } from '@modern-js/types/server';
|
|
2
|
+
import type { Rspack } from '@rsbuild/core';
|
|
3
|
+
import { type Module } from '@swc/core';
|
|
4
|
+
export declare const rspackRscLayerName = "react-server";
|
|
5
|
+
export type SourceMap = Parameters<Rspack.LoaderDefinitionFunction>[1];
|
|
6
|
+
export declare const MODERN_RSC_INFO = "modernRscInfo";
|
|
7
|
+
export declare const sharedData: {
|
|
8
|
+
store: Map<string, any>;
|
|
9
|
+
get<T>(key: string): T | undefined;
|
|
10
|
+
set<T>(key: string, value: T): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
};
|
|
13
|
+
export declare function setBuildInfo(mod: Rspack.Module, property: Record<string, any>): void;
|
|
14
|
+
export declare function setRscBuildInfo(mod: Rspack.Module, property: Record<string, any>): void;
|
|
15
|
+
export declare function removeRscBuildInfo(mod: Rspack.Module): void;
|
|
16
|
+
export declare function getRscBuildInfo(mod: Rspack.Module): any;
|
|
17
|
+
export declare function isCssModule(mod: Rspack.Module): any;
|
|
18
|
+
export declare const parseSource: (source: string) => Promise<Module>;
|
|
19
|
+
export declare const getExportNames: (ast: Module, collectFuncOnly?: boolean) => Promise<string[]>;
|
|
20
|
+
export declare const isServerModule: (ast: Module) => Promise<boolean>;
|
|
21
|
+
export declare const isClientModule: (ast: Module) => Promise<boolean>;
|
|
22
|
+
export declare function findRootIssuer(modulegraph: Rspack.ModuleGraph, module: Rspack.NormalModule): Rspack.NormalModule;
|