@modern-js/builder 3.0.0-alpha.0 → 3.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createBuilder.js +96 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/plugins/devtools.js +47 -0
- package/dist/cjs/plugins/emitRouteFile.js +75 -0
- package/dist/cjs/plugins/environmentDefaults.js +100 -0
- package/dist/cjs/plugins/globalVars.js +55 -0
- package/dist/cjs/plugins/htmlMinify.js +115 -0
- package/dist/cjs/plugins/manifest.js +52 -0
- package/dist/cjs/plugins/postcss.js +118 -0
- package/dist/cjs/plugins/runtimeChunk.js +54 -0
- package/dist/cjs/rsc/common.js +157 -0
- package/dist/cjs/rsc/plugins/rsbuild-rsc-plugin.js +169 -0
- package/dist/cjs/rsc/plugins/rspack-rsc-client-plugin.js +187 -0
- package/dist/cjs/rsc/plugins/rspack-rsc-server-plugin.js +245 -0
- package/dist/cjs/rsc/rsc-client-loader.js +71 -0
- package/dist/cjs/rsc/rsc-css-loader.js +42 -0
- package/dist/cjs/rsc/rsc-server-loader.js +102 -0
- package/dist/cjs/rsc/rsc-ssr-loader.js +60 -0
- package/dist/cjs/shared/devServer.js +87 -0
- package/dist/cjs/shared/getCssSupport.js +121 -0
- package/dist/cjs/shared/manifest.js +46 -0
- package/dist/cjs/shared/parseCommonConfig.js +209 -0
- package/dist/cjs/shared/rsc/rscClientBrowserFallback.js +64 -0
- package/dist/cjs/shared/rsc/rscEmptyModule.js +36 -0
- package/dist/cjs/shared/utils.js +115 -0
- package/dist/cjs/types.js +18 -0
- package/dist/compiled/postcss-load-config/index.d.ts +1 -0
- package/dist/compiled/postcss-load-config/index.js +608 -0
- package/dist/compiled/postcss-load-config/index.js.LICENSE.txt +13 -0
- package/dist/compiled/postcss-load-config/license +20 -0
- package/dist/compiled/postcss-load-config/package.json +1 -0
- package/dist/esm/createBuilder.mjs +59 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/plugins/devtools.mjs +13 -0
- package/dist/esm/plugins/emitRouteFile.mjs +28 -0
- package/dist/esm/plugins/environmentDefaults.mjs +66 -0
- package/dist/esm/plugins/globalVars.mjs +21 -0
- package/dist/esm/plugins/htmlMinify.mjs +81 -0
- package/dist/esm/plugins/manifest.mjs +18 -0
- package/dist/esm/plugins/postcss.mjs +81 -0
- package/dist/esm/plugins/runtimeChunk.mjs +20 -0
- package/dist/esm/rsc/common.mjs +87 -0
- package/dist/esm/rsc/plugins/rsbuild-rsc-plugin.mjs +124 -0
- package/dist/esm/rsc/plugins/rspack-rsc-client-plugin.mjs +143 -0
- package/dist/esm/rsc/plugins/rspack-rsc-server-plugin.mjs +211 -0
- package/dist/esm/rsc/rsc-client-loader.mjs +37 -0
- package/dist/esm/rsc/rsc-css-loader.mjs +8 -0
- package/dist/esm/rsc/rsc-server-loader.mjs +58 -0
- package/dist/esm/rsc/rsc-ssr-loader.mjs +26 -0
- package/dist/esm/shared/devServer.mjs +53 -0
- package/dist/esm/shared/getCssSupport.mjs +77 -0
- package/dist/esm/shared/manifest.mjs +12 -0
- package/dist/esm/shared/parseCommonConfig.mjs +172 -0
- package/dist/esm/shared/rsc/rscClientBrowserFallback.mjs +20 -0
- package/dist/esm/shared/rsc/rscEmptyModule.mjs +2 -0
- package/dist/esm/shared/utils.mjs +53 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm-node/createBuilder.mjs +61 -0
- package/dist/esm-node/index.mjs +6 -0
- package/dist/esm-node/plugins/devtools.mjs +15 -0
- package/dist/esm-node/plugins/emitRouteFile.mjs +30 -0
- package/dist/esm-node/plugins/environmentDefaults.mjs +68 -0
- package/dist/esm-node/plugins/globalVars.mjs +23 -0
- package/dist/esm-node/plugins/htmlMinify.mjs +83 -0
- package/dist/esm-node/plugins/manifest.mjs +20 -0
- package/dist/esm-node/plugins/postcss.mjs +83 -0
- package/dist/esm-node/plugins/runtimeChunk.mjs +22 -0
- package/dist/esm-node/rsc/common.mjs +89 -0
- package/dist/esm-node/rsc/plugins/rsbuild-rsc-plugin.mjs +126 -0
- package/dist/esm-node/rsc/plugins/rspack-rsc-client-plugin.mjs +145 -0
- package/dist/esm-node/rsc/plugins/rspack-rsc-server-plugin.mjs +213 -0
- package/dist/esm-node/rsc/rsc-client-loader.mjs +39 -0
- package/dist/esm-node/rsc/rsc-css-loader.mjs +10 -0
- package/dist/esm-node/rsc/rsc-server-loader.mjs +60 -0
- package/dist/esm-node/rsc/rsc-ssr-loader.mjs +28 -0
- package/dist/esm-node/shared/devServer.mjs +55 -0
- package/dist/esm-node/shared/getCssSupport.mjs +79 -0
- package/dist/esm-node/shared/manifest.mjs +14 -0
- package/dist/esm-node/shared/parseCommonConfig.mjs +174 -0
- package/dist/esm-node/shared/rsc/rscClientBrowserFallback.mjs +25 -0
- package/dist/esm-node/shared/rsc/rscEmptyModule.mjs +4 -0
- package/dist/esm-node/shared/utils.mjs +55 -0
- package/dist/esm-node/types.mjs +2 -0
- package/dist/types/shared/rsc/rscClientBrowserFallback.d.ts +2 -0
- package/dist/types/shared/rsc/rscEmptyModule.d.ts +2 -0
- package/dist/{types.d.ts → types/types.d.ts} +2 -16
- package/package.json +36 -31
- package/dist/createBuilder.js +0 -153
- package/dist/index.js +0 -45
- package/dist/plugins/babel-post.d.ts +0 -5
- package/dist/plugins/babel-post.js +0 -57
- package/dist/plugins/devtools.js +0 -42
- package/dist/plugins/emitRouteFile.js +0 -70
- package/dist/plugins/environmentDefaults.js +0 -99
- package/dist/plugins/globalVars.js +0 -50
- package/dist/plugins/htmlMinify.js +0 -126
- package/dist/plugins/manifest.js +0 -54
- package/dist/plugins/postcss.js +0 -133
- package/dist/plugins/runtimeChunk.js +0 -55
- package/dist/rsc/common.js +0 -174
- package/dist/rsc/plugins/rsbuild-rsc-plugin.js +0 -166
- package/dist/rsc/plugins/rspack-rsc-client-plugin.js +0 -233
- package/dist/rsc/plugins/rspack-rsc-server-plugin.js +0 -290
- package/dist/rsc/rsc-client-loader.js +0 -70
- package/dist/rsc/rsc-css-loader.js +0 -30
- package/dist/rsc/rsc-server-loader.js +0 -95
- package/dist/rsc/rsc-ssr-loader.js +0 -58
- package/dist/shared/devServer.js +0 -83
- package/dist/shared/getCssSupport.js +0 -113
- package/dist/shared/manifest.js +0 -38
- package/dist/shared/parseCommonConfig.js +0 -232
- package/dist/shared/utils.js +0 -109
- package/dist/types.js +0 -16
- /package/dist/{createBuilder.d.ts → types/createBuilder.d.ts} +0 -0
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
- /package/dist/{plugins → types/plugins}/devtools.d.ts +0 -0
- /package/dist/{plugins → types/plugins}/emitRouteFile.d.ts +0 -0
- /package/dist/{plugins → types/plugins}/environmentDefaults.d.ts +0 -0
- /package/dist/{plugins → types/plugins}/globalVars.d.ts +0 -0
- /package/dist/{plugins → types/plugins}/htmlMinify.d.ts +0 -0
- /package/dist/{plugins → types/plugins}/manifest.d.ts +0 -0
- /package/dist/{plugins → types/plugins}/postcss.d.ts +0 -0
- /package/dist/{plugins → types/plugins}/runtimeChunk.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/common.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/plugins/rsbuild-rsc-plugin.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/plugins/rspack-rsc-client-plugin.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/plugins/rspack-rsc-server-plugin.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/rsc-client-loader.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/rsc-css-loader.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/rsc-server-loader.d.ts +0 -0
- /package/dist/{rsc → types/rsc}/rsc-ssr-loader.d.ts +0 -0
- /package/dist/{shared → types/shared}/devServer.d.ts +0 -0
- /package/dist/{shared → types/shared}/getCssSupport.d.ts +0 -0
- /package/dist/{shared → types/shared}/manifest.d.ts +0 -0
- /package/dist/{shared → types/shared}/parseCommonConfig.d.ts +0 -0
- /package/dist/{shared → types/shared}/utils.d.ts +0 -0
package/dist/createBuilder.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var createBuilder_exports = {};
|
|
30
|
-
__export(createBuilder_exports, {
|
|
31
|
-
createRspackBuilder: () => createRspackBuilder,
|
|
32
|
-
parseConfig: () => parseConfig
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(createBuilder_exports);
|
|
35
|
-
var import_core = require("@rsbuild/core");
|
|
36
|
-
var import_rsbuild_rsc_plugin = require("./rsc/plugins/rsbuild-rsc-plugin");
|
|
37
|
-
var import_parseCommonConfig = require("./shared/parseCommonConfig");
|
|
38
|
-
var import_utils = require("./shared/utils");
|
|
39
|
-
async function parseConfig(builderConfig, options) {
|
|
40
|
-
var _builderConfig_tools, _builderConfig_server;
|
|
41
|
-
var _builderConfig, _builderConfig_performance;
|
|
42
|
-
var _performance;
|
|
43
|
-
(_performance = (_builderConfig = builderConfig).performance) !== null && _performance !== void 0 ? _performance : _builderConfig.performance = {};
|
|
44
|
-
var _buildCache;
|
|
45
|
-
(_buildCache = (_builderConfig_performance = builderConfig.performance).buildCache) !== null && _buildCache !== void 0 ? _buildCache : _builderConfig_performance.buildCache = true;
|
|
46
|
-
const { rsbuildConfig, rsbuildPlugins } = await (0, import_parseCommonConfig.parseCommonConfig)(builderConfig, options);
|
|
47
|
-
const { sri } = builderConfig.security || {};
|
|
48
|
-
if (sri) {
|
|
49
|
-
if (sri === true) {
|
|
50
|
-
rsbuildConfig.security.sri = {
|
|
51
|
-
enable: "auto"
|
|
52
|
-
};
|
|
53
|
-
} else {
|
|
54
|
-
const algorithm = Array.isArray(sri.hashFuncNames) ? sri.hashFuncNames[0] : void 0;
|
|
55
|
-
rsbuildConfig.security.sri = {
|
|
56
|
-
enable: sri.enabled,
|
|
57
|
-
algorithm
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (Boolean(rsbuildConfig.tools.lightningcssLoader) === false) {
|
|
62
|
-
var _builderConfig_tools1;
|
|
63
|
-
const { pluginPostcss } = await Promise.resolve().then(() => __toESM(require("./plugins/postcss")));
|
|
64
|
-
rsbuildPlugins.push(pluginPostcss({
|
|
65
|
-
autoprefixer: (_builderConfig_tools1 = builderConfig.tools) === null || _builderConfig_tools1 === void 0 ? void 0 : _builderConfig_tools1.autoprefixer
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
const hasEnvironmentBabelConfig = Object.values(builderConfig.environments || {}).some((c) => {
|
|
69
|
-
var _c_tools;
|
|
70
|
-
return ((_c_tools = c.tools) === null || _c_tools === void 0 ? void 0 : _c_tools.babel) !== void 0;
|
|
71
|
-
});
|
|
72
|
-
if (hasEnvironmentBabelConfig) {
|
|
73
|
-
const mergeSharedBabelConfig = (config) => {
|
|
74
|
-
var _builderConfig_tools3;
|
|
75
|
-
if ((_builderConfig_tools3 = builderConfig.tools) === null || _builderConfig_tools3 === void 0 ? void 0 : _builderConfig_tools3.babel) {
|
|
76
|
-
var _builderConfig_tools12;
|
|
77
|
-
return (0, import_utils.castArray)(config).concat(...(0, import_utils.castArray)((_builderConfig_tools12 = builderConfig.tools) === null || _builderConfig_tools12 === void 0 ? void 0 : _builderConfig_tools12.babel));
|
|
78
|
-
}
|
|
79
|
-
return config;
|
|
80
|
-
};
|
|
81
|
-
const { pluginBabel } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-babel")));
|
|
82
|
-
const { pluginBabelPost } = await Promise.resolve().then(() => __toESM(require("./plugins/babel-post")));
|
|
83
|
-
Object.entries(builderConfig.environments).forEach(([name, config]) => {
|
|
84
|
-
var _rsbuildConfig_environments, _config_tools, _builderConfig_tools3;
|
|
85
|
-
const environmentConfig = (_rsbuildConfig_environments = rsbuildConfig.environments) === null || _rsbuildConfig_environments === void 0 ? void 0 : _rsbuildConfig_environments[name];
|
|
86
|
-
if (!environmentConfig) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if ((_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : _config_tools.babel) {
|
|
90
|
-
var _config_tools1;
|
|
91
|
-
var _environmentConfig;
|
|
92
|
-
var _plugins;
|
|
93
|
-
(_plugins = (_environmentConfig = environmentConfig).plugins) !== null && _plugins !== void 0 ? _plugins : _environmentConfig.plugins = [];
|
|
94
|
-
environmentConfig.plugins.push(pluginBabel({
|
|
95
|
-
babelLoaderOptions: mergeSharedBabelConfig((_config_tools1 = config.tools) === null || _config_tools1 === void 0 ? void 0 : _config_tools1.babel)
|
|
96
|
-
}), pluginBabelPost());
|
|
97
|
-
} else if ((_builderConfig_tools3 = builderConfig.tools) === null || _builderConfig_tools3 === void 0 ? void 0 : _builderConfig_tools3.babel) {
|
|
98
|
-
var _builderConfig_tools12;
|
|
99
|
-
var _environmentConfig1;
|
|
100
|
-
var _plugins1;
|
|
101
|
-
(_plugins1 = (_environmentConfig1 = environmentConfig).plugins) !== null && _plugins1 !== void 0 ? _plugins1 : _environmentConfig1.plugins = [];
|
|
102
|
-
environmentConfig.plugins.push(pluginBabel({
|
|
103
|
-
babelLoaderOptions: (_builderConfig_tools12 = builderConfig.tools) === null || _builderConfig_tools12 === void 0 ? void 0 : _builderConfig_tools12.babel
|
|
104
|
-
}), pluginBabelPost());
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
} else if ((_builderConfig_tools = builderConfig.tools) === null || _builderConfig_tools === void 0 ? void 0 : _builderConfig_tools.babel) {
|
|
108
|
-
var _builderConfig_tools2;
|
|
109
|
-
const { pluginBabel } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-babel")));
|
|
110
|
-
const { pluginBabelPost } = await Promise.resolve().then(() => __toESM(require("./plugins/babel-post")));
|
|
111
|
-
rsbuildPlugins.push(pluginBabel({
|
|
112
|
-
babelLoaderOptions: (_builderConfig_tools2 = builderConfig.tools) === null || _builderConfig_tools2 === void 0 ? void 0 : _builderConfig_tools2.babel
|
|
113
|
-
}), pluginBabelPost());
|
|
114
|
-
}
|
|
115
|
-
var _builderConfig_server_rsc;
|
|
116
|
-
const enableRsc = (_builderConfig_server_rsc = (_builderConfig_server = builderConfig.server) === null || _builderConfig_server === void 0 ? void 0 : _builderConfig_server.rsc) !== null && _builderConfig_server_rsc !== void 0 ? _builderConfig_server_rsc : false;
|
|
117
|
-
if (enableRsc) {
|
|
118
|
-
const { rscClientRuntimePath, rscServerRuntimePath, internalDirectory } = options;
|
|
119
|
-
rsbuildPlugins.push((0, import_rsbuild_rsc_plugin.rsbuildRscPlugin)({
|
|
120
|
-
appDir: options.cwd,
|
|
121
|
-
rscClientRuntimePath,
|
|
122
|
-
rscServerRuntimePath,
|
|
123
|
-
internalDirectory
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
rsbuildConfig,
|
|
128
|
-
rsbuildPlugins
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
async function createRspackBuilder(options) {
|
|
132
|
-
const { cwd = process.cwd(), config, rscClientRuntimePath, rscServerRuntimePath, ...rest } = options;
|
|
133
|
-
const { rsbuildConfig, rsbuildPlugins } = await parseConfig(config, {
|
|
134
|
-
...rest,
|
|
135
|
-
cwd
|
|
136
|
-
});
|
|
137
|
-
rsbuildConfig.plugins = [
|
|
138
|
-
...rsbuildPlugins,
|
|
139
|
-
...rsbuildConfig.plugins || []
|
|
140
|
-
];
|
|
141
|
-
const rsbuild = await (0, import_core.createRsbuild)({
|
|
142
|
-
cwd,
|
|
143
|
-
rsbuildConfig
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
...rsbuild
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
-
0 && (module.exports = {
|
|
151
|
-
createRspackBuilder,
|
|
152
|
-
parseConfig
|
|
153
|
-
});
|
package/dist/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
RUNTIME_CHUNK_NAME: () => import_utils.RUNTIME_CHUNK_NAME,
|
|
22
|
-
RUNTIME_CHUNK_REGEX: () => import_utils.RUNTIME_CHUNK_REGEX,
|
|
23
|
-
SERVICE_WORKER_ENVIRONMENT_NAME: () => import_utils.SERVICE_WORKER_ENVIRONMENT_NAME,
|
|
24
|
-
castArray: () => import_utils.castArray,
|
|
25
|
-
createBuilder: () => import_createBuilder.createRspackBuilder,
|
|
26
|
-
isHtmlDisabled: () => import_utils.isHtmlDisabled,
|
|
27
|
-
logger: () => import_core.logger,
|
|
28
|
-
parseRspackConfig: () => import_createBuilder2.parseConfig
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(src_exports);
|
|
31
|
-
var import_createBuilder = require("./createBuilder");
|
|
32
|
-
var import_core = require("@rsbuild/core");
|
|
33
|
-
var import_utils = require("./shared/utils");
|
|
34
|
-
var import_createBuilder2 = require("./createBuilder");
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
RUNTIME_CHUNK_NAME,
|
|
38
|
-
RUNTIME_CHUNK_REGEX,
|
|
39
|
-
SERVICE_WORKER_ENVIRONMENT_NAME,
|
|
40
|
-
castArray,
|
|
41
|
-
createBuilder,
|
|
42
|
-
isHtmlDisabled,
|
|
43
|
-
logger,
|
|
44
|
-
parseRspackConfig
|
|
45
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var babel_post_exports = {};
|
|
30
|
-
__export(babel_post_exports, {
|
|
31
|
-
pluginBabelPost: () => pluginBabelPost
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(babel_post_exports);
|
|
34
|
-
var import_isEqual = __toESM(require("lodash/isEqual"));
|
|
35
|
-
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
36
|
-
const pluginBabelPost = () => ({
|
|
37
|
-
name: "builder:babel-post",
|
|
38
|
-
setup(api) {
|
|
39
|
-
api.modifyBundlerChain({
|
|
40
|
-
handler: async (chain, { CHAIN_ID, environment }) => {
|
|
41
|
-
if (chain.module.rules.get(CHAIN_ID.RULE.JS)) {
|
|
42
|
-
const { cacheIdentifier, ...babelLoaderOptions } = chain.module.rule(CHAIN_ID.RULE.JS).use(CHAIN_ID.USE.BABEL).get("options");
|
|
43
|
-
const { config } = environment;
|
|
44
|
-
if (babelLoaderOptions && (0, import_isEqual.default)((0, import_plugin_babel.getDefaultBabelOptions)(config, api.context), babelLoaderOptions)) {
|
|
45
|
-
chain.module.rule(CHAIN_ID.RULE.JS).uses.delete(CHAIN_ID.USE.BABEL);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
// other plugins can modify babel config in modifyBundlerChain 'default order'
|
|
50
|
-
order: "post"
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
pluginBabelPost
|
|
57
|
-
});
|
package/dist/plugins/devtools.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
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 devtools_exports = {};
|
|
20
|
-
__export(devtools_exports, {
|
|
21
|
-
pluginDevtool: () => pluginDevtool
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(devtools_exports);
|
|
24
|
-
const pluginDevtool = (options) => ({
|
|
25
|
-
name: "builder:devtool",
|
|
26
|
-
setup(api) {
|
|
27
|
-
var _options_sourceMap;
|
|
28
|
-
const devtoolJs = typeof options.sourceMap === "boolean" || ((_options_sourceMap = options.sourceMap) === null || _options_sourceMap === void 0 ? void 0 : _options_sourceMap.js) !== void 0;
|
|
29
|
-
if (devtoolJs) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
api.modifyBundlerChain((chain, { isProd, isServer }) => {
|
|
33
|
-
const prodDevTool = isServer ? "source-map" : "hidden-source-map";
|
|
34
|
-
const devtool = isProd ? prodDevTool : "cheap-module-source-map";
|
|
35
|
-
chain.devtool(devtool);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
pluginDevtool
|
|
42
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var emitRouteFile_exports = {};
|
|
30
|
-
__export(emitRouteFile_exports, {
|
|
31
|
-
isFileExists: () => isFileExists,
|
|
32
|
-
pluginEmitRouteFile: () => pluginEmitRouteFile
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(emitRouteFile_exports);
|
|
35
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
36
|
-
var import_node_path = require("node:path");
|
|
37
|
-
async function isFileExists(file) {
|
|
38
|
-
return import_node_fs.default.promises.access(file, import_node_fs.default.constants.F_OK).then(() => true).catch(() => false);
|
|
39
|
-
}
|
|
40
|
-
const pluginEmitRouteFile = () => ({
|
|
41
|
-
name: "builder:emit-route-file",
|
|
42
|
-
setup(api) {
|
|
43
|
-
api.onBeforeStartDevServer(async ({ environments }) => {
|
|
44
|
-
const { fs: fs2, ROUTE_SPEC_FILE } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
45
|
-
const routeFilePath = (0, import_node_path.join)(api.context.distPath, ROUTE_SPEC_FILE);
|
|
46
|
-
const htmlPaths = Object.values(environments).reduce((prev, curr) => {
|
|
47
|
-
return {
|
|
48
|
-
...prev,
|
|
49
|
-
...curr.htmlPaths
|
|
50
|
-
};
|
|
51
|
-
}, {});
|
|
52
|
-
const routesInfo = Object.entries(htmlPaths).map(([entryName, filename], index) => ({
|
|
53
|
-
urlPath: index === 0 ? "/" : `/${entryName}`,
|
|
54
|
-
entryName,
|
|
55
|
-
entryPath: filename,
|
|
56
|
-
isSPA: true
|
|
57
|
-
}));
|
|
58
|
-
if (!await isFileExists(routeFilePath) && routesInfo.length) {
|
|
59
|
-
await fs2.outputFile(routeFilePath, JSON.stringify({
|
|
60
|
-
routes: routesInfo
|
|
61
|
-
}, null, 2));
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
-
0 && (module.exports = {
|
|
68
|
-
isFileExists,
|
|
69
|
-
pluginEmitRouteFile
|
|
70
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
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 globalVars_exports = {};
|
|
20
|
-
__export(globalVars_exports, {
|
|
21
|
-
pluginGlobalVars: () => pluginGlobalVars
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(globalVars_exports);
|
|
24
|
-
var import_utils = require("@modern-js/utils");
|
|
25
|
-
const pluginGlobalVars = (options) => ({
|
|
26
|
-
name: "builder:global-vars",
|
|
27
|
-
setup(api) {
|
|
28
|
-
api.modifyBundlerChain((chain, { env, target, bundler }) => {
|
|
29
|
-
if (!options) {
|
|
30
|
-
return;
|
|
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
|
-
]);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
-
0 && (module.exports = {
|
|
49
|
-
pluginGlobalVars
|
|
50
|
-
});
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var 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
|
-
});
|