@lynx-js/rspeedy 0.11.2 → 0.11.4
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/CHANGELOG.md +22 -0
- package/dist/{src_config_validate_ts.js → 0~src_config_validate_ts.js} +1825 -1558
- package/dist/0~src_plugins_api_plugin_ts.js +32 -0
- package/dist/0~src_plugins_chunkLoading_plugin_ts.js +23 -0
- package/dist/{src_plugins_dev_plugin_ts.js → 0~src_plugins_dev_plugin_ts.js} +13 -8
- package/dist/{src_plugins_emitOnErrors_plugin_ts.js → 0~src_plugins_emitOnErrors_plugin_ts.js} +0 -1
- package/dist/{src_plugins_inspect_plugin_ts.js → 0~src_plugins_inspect_plugin_ts.js} +0 -1
- package/dist/{src_plugins_minify_plugin_ts.js → 0~src_plugins_minify_plugin_ts.js} +0 -1
- package/dist/{src_plugins_optimization_plugin_ts.js → 0~src_plugins_optimization_plugin_ts.js} +0 -1
- package/dist/{src_plugins_output_plugin_ts.js → 0~src_plugins_output_plugin_ts.js} +0 -1
- package/dist/{src_plugins_resolve_plugin_ts.js → 0~src_plugins_resolve_plugin_ts.js} +0 -1
- package/dist/0~src_plugins_rsdoctor_plugin_ts.js +53 -0
- package/dist/{src_plugins_sourcemap_plugin_ts.js → 0~src_plugins_sourcemap_plugin_ts.js} +0 -1
- package/dist/{src_plugins_swc_plugin_ts.js → 0~src_plugins_swc_plugin_ts.js} +0 -1
- package/dist/{src_plugins_target_plugin_ts.js → 0~src_plugins_target_plugin_ts.js} +7 -14
- package/dist/{src_cli_build_ts.js → 1~src_cli_build_ts.js} +8 -3
- package/dist/{src_cli_commands_ts.js → 1~src_cli_commands_ts.js} +1 -1
- package/dist/{src_cli_dev_ts.js → 1~src_cli_dev_ts.js} +8 -3
- package/dist/{src_cli_inspect_ts.js → 1~src_cli_inspect_ts.js} +8 -3
- package/dist/{src_cli_preview_ts.js → 1~src_cli_preview_ts.js} +8 -3
- package/dist/1~src_config_validate_ts.js +41047 -0
- package/dist/{src_plugins_api_plugin_ts.js → 1~src_plugins_api_plugin_ts.js} +0 -1
- package/dist/1~src_plugins_chunkLoading_plugin_ts.js +23 -0
- package/dist/1~src_plugins_dev_plugin_ts.js +149 -0
- package/dist/1~src_plugins_emitOnErrors_plugin_ts.js +21 -0
- package/dist/1~src_plugins_index_ts.js +52 -0
- package/dist/1~src_plugins_inspect_plugin_ts.js +48 -0
- package/dist/1~src_plugins_minify_plugin_ts.js +85 -0
- package/dist/1~src_plugins_optimization_plugin_ts.js +25 -0
- package/dist/1~src_plugins_output_plugin_ts.js +46 -0
- package/dist/1~src_plugins_resolve_plugin_ts.js +21 -0
- package/dist/{src_plugins_rsdoctor_plugin_ts.js → 1~src_plugins_rsdoctor_plugin_ts.js} +0 -1
- package/dist/1~src_plugins_sourcemap_plugin_ts.js +99 -0
- package/dist/1~src_plugins_swc_plugin_ts.js +39 -0
- package/dist/1~src_plugins_target_plugin_ts.js +39 -0
- package/dist/{src_version_ts.js → 1~src_version_ts.js} +1 -1
- package/dist/{vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js → 1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js} +2 -6
- package/dist/1~vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1068 -0
- package/dist/1~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +417 -0
- package/dist/cli/main.js +1 -1
- package/dist/index.d.ts +161 -0
- package/dist/index.js +10 -4
- package/package.json +3 -3
- package/dist/src_plugins_chunkLoading_plugin_ts.js +0 -37
- /package/dist/{src_cli_exit_ts.js → 0~src_cli_exit_ts.js} +0 -0
- /package/dist/{src_plugins_index_ts.js → 0~src_plugins_index_ts.js} +0 -0
- /package/dist/{vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 0~vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +0 -0
- /package/dist/{vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js → 0~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js} +0 -0
- /package/dist/{events-fs-fs_promises-os-path-stream.js → 1~events-fs-fs_promises-os-path-stream.js} +0 -0
- /package/dist/{node_child_process-node_events-node_fs-node_path.js → 1~node_child_process-node_events-node_fs-node_path.js} +0 -0
- /package/dist/{vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt → 1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt} +0 -0
- /package/dist/{vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js → 1~vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js} +0 -0
|
@@ -4,7 +4,6 @@ export const __webpack_ids__ = [
|
|
|
4
4
|
];
|
|
5
5
|
export const __webpack_modules__ = {
|
|
6
6
|
"./src/plugins/api.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
-
__webpack_require__.r(__webpack_exports__);
|
|
8
7
|
__webpack_require__.d(__webpack_exports__, {
|
|
9
8
|
pluginAPI: ()=>pluginAPI
|
|
10
9
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LynxCacheEventsPlugin } from "@lynx-js/cache-events-webpack-plugin";
|
|
2
|
+
import { ChunkLoadingWebpackPlugin } from "@lynx-js/chunk-loading-webpack-plugin";
|
|
3
|
+
export const __webpack_id__ = "src_plugins_chunkLoading_plugin_ts";
|
|
4
|
+
export const __webpack_ids__ = [
|
|
5
|
+
"src_plugins_chunkLoading_plugin_ts"
|
|
6
|
+
];
|
|
7
|
+
export const __webpack_modules__ = {
|
|
8
|
+
"./src/plugins/chunkLoading.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
9
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
10
|
+
pluginChunkLoading: ()=>pluginChunkLoading
|
|
11
|
+
});
|
|
12
|
+
function pluginChunkLoading() {
|
|
13
|
+
return {
|
|
14
|
+
name: 'lynx:rsbuild:chunk-loading',
|
|
15
|
+
setup (api) {
|
|
16
|
+
api.modifyBundlerChain((chain)=>{
|
|
17
|
+
chain.plugin('lynx:chunk-loading').use(ChunkLoadingWebpackPlugin).end().plugin('lynx:cache-events').use(LynxCacheEventsPlugin).end().output.chunkLoading('lynx').chunkFormat('commonjs').end();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
export const __webpack_id__ = "src_plugins_dev_plugin_ts";
|
|
3
|
+
export const __webpack_ids__ = [
|
|
4
|
+
"src_plugins_dev_plugin_ts"
|
|
5
|
+
];
|
|
6
|
+
export const __webpack_modules__ = {
|
|
7
|
+
"./src/plugins/dev.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
pluginDev: ()=>pluginDev
|
|
10
|
+
});
|
|
11
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
12
|
+
var core_ = __webpack_require__("@rsbuild/core");
|
|
13
|
+
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
14
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
15
|
+
var debug = __webpack_require__("./src/debug.ts");
|
|
16
|
+
function isLynx(environment) {
|
|
17
|
+
return 'string' == typeof environment ? 'lynx' === environment : 'lynx' === environment.name;
|
|
18
|
+
}
|
|
19
|
+
class ProvidePlugin_ProvidePlugin {
|
|
20
|
+
definitions;
|
|
21
|
+
constructor(definitions){
|
|
22
|
+
this.definitions = definitions;
|
|
23
|
+
}
|
|
24
|
+
apply(compiler) {
|
|
25
|
+
const { ProvidePlugin } = compiler.webpack;
|
|
26
|
+
new ProvidePlugin(this.definitions).apply(compiler);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function pluginDev(options, server) {
|
|
30
|
+
return {
|
|
31
|
+
name: 'lynx:rsbuild:dev',
|
|
32
|
+
apply (config, { action }) {
|
|
33
|
+
return 'dev' === action || 'development' === config.mode;
|
|
34
|
+
},
|
|
35
|
+
async setup (api) {
|
|
36
|
+
const hostname = server?.host ?? await findIp('v4');
|
|
37
|
+
let assetPrefix = options?.assetPrefix;
|
|
38
|
+
switch(typeof assetPrefix){
|
|
39
|
+
case 'string':
|
|
40
|
+
if (server?.port !== void 0) {
|
|
41
|
+
const hasPortPlaceholder = assetPrefix.includes('<port>');
|
|
42
|
+
if (!hasPortPlaceholder) {
|
|
43
|
+
const assetPrefixURL = new URL(assetPrefix);
|
|
44
|
+
if (assetPrefixURL.port !== String(server.port)) {
|
|
45
|
+
core_.logger.warn(`Setting different port values in ${picocolors_default().cyan('server.port')} and ${picocolors_default().cyan('dev.assetPrefix')}. Using server.port(${picocolors_default().cyan(server.port)}) to make HMR work.`);
|
|
46
|
+
assetPrefixURL.port = String(server.port);
|
|
47
|
+
assetPrefix = assetPrefixURL.toString();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case 'undefined':
|
|
53
|
+
case 'boolean':
|
|
54
|
+
if (options?.assetPrefix !== false) assetPrefix = `http://${hostname}:<port>/`;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
if (server?.base) {
|
|
58
|
+
if (assetPrefix.endsWith('/')) assetPrefix = assetPrefix.slice(0, -1);
|
|
59
|
+
assetPrefix = `${assetPrefix}${server.base}/`;
|
|
60
|
+
}
|
|
61
|
+
(0, debug.Yz)(`dev.assetPrefix is normalized to ${assetPrefix}`);
|
|
62
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
|
|
63
|
+
dev: {
|
|
64
|
+
assetPrefix,
|
|
65
|
+
client: {
|
|
66
|
+
host: hostname,
|
|
67
|
+
port: '<port>'
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
output: {
|
|
71
|
+
assetPrefix
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
const require = createRequire(import.meta.url);
|
|
75
|
+
api.modifyBundlerChain((chain, { isDev, environment })=>{
|
|
76
|
+
const { action } = api.context;
|
|
77
|
+
if ('dev' !== action && !isDev) return;
|
|
78
|
+
const rsbuildPath = require.resolve('@rsbuild/core');
|
|
79
|
+
const rspeedyDir = external_node_path_["default"].dirname(require.resolve('@lynx-js/rspeedy/package.json'));
|
|
80
|
+
const searchParams = new URLSearchParams({
|
|
81
|
+
hostname,
|
|
82
|
+
port: api.context.devServer?.port?.toString() ?? '',
|
|
83
|
+
pathname: '/rsbuild-hmr',
|
|
84
|
+
hot: options?.hmr ?? true ? 'true' : 'false',
|
|
85
|
+
'live-reload': options?.liveReload ?? true ? 'true' : 'false',
|
|
86
|
+
protocol: 'ws'
|
|
87
|
+
});
|
|
88
|
+
if (environment.webSocketToken) searchParams.set('token', environment.webSocketToken);
|
|
89
|
+
chain.resolve.alias.set('webpack/hot/log.js', require.resolve('@rspack/core/hot/log', {
|
|
90
|
+
paths: [
|
|
91
|
+
rsbuildPath
|
|
92
|
+
]
|
|
93
|
+
})).set('webpack/hot/emitter.js', require.resolve('@rspack/core/hot/emitter', {
|
|
94
|
+
paths: [
|
|
95
|
+
rsbuildPath
|
|
96
|
+
]
|
|
97
|
+
})).set('@lynx-js/webpack-dev-transport/client', `${require.resolve('@lynx-js/webpack-dev-transport/client')}?${searchParams.toString()}`).set('@rspack/core/hot/dev-server', require.resolve('@rspack/core/hot/dev-server', {
|
|
98
|
+
paths: [
|
|
99
|
+
rsbuildPath
|
|
100
|
+
]
|
|
101
|
+
})).end().end().plugin('lynx.hmr.provide.dev_server_client').use(ProvidePlugin_ProvidePlugin, [
|
|
102
|
+
{
|
|
103
|
+
__webpack_dev_server_client__: [
|
|
104
|
+
require.resolve('./client/hmr/WebSocketClient.js', {
|
|
105
|
+
paths: [
|
|
106
|
+
rspeedyDir
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
'default'
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]).end();
|
|
113
|
+
if (isLynx(environment)) chain.plugin('lynx.hmr.provide.websocket').use(ProvidePlugin_ProvidePlugin, [
|
|
114
|
+
{
|
|
115
|
+
WebSocket: [
|
|
116
|
+
options?.client?.websocketTransport ?? require.resolve('@lynx-js/websocket'),
|
|
117
|
+
'default'
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
]).end();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async function findIp(family, isInternal = false) {
|
|
126
|
+
const [{ default: ipaddr }, os] = await Promise.all([
|
|
127
|
+
__webpack_require__.e("vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js").then(__webpack_require__.t.bind(__webpack_require__, "../../../node_modules/.pnpm/ipaddr.js@2.2.0/node_modules/ipaddr.js/lib/ipaddr.js", 23)),
|
|
128
|
+
import("node:os")
|
|
129
|
+
]);
|
|
130
|
+
let host;
|
|
131
|
+
const networks = Object.values(os.networkInterfaces()).flatMap((networks)=>networks ?? []).filter((network)=>{
|
|
132
|
+
if (!network || !network.address) return false;
|
|
133
|
+
if (network.family !== `IP${family}`) return false;
|
|
134
|
+
if (network.internal !== isInternal) return false;
|
|
135
|
+
if ('v6' === family) {
|
|
136
|
+
const range = ipaddr.parse(network.address).range();
|
|
137
|
+
if ('ipv4Mapped' !== range && 'uniqueLocal' !== range) return false;
|
|
138
|
+
}
|
|
139
|
+
return network.address;
|
|
140
|
+
});
|
|
141
|
+
if (networks.length > 0) {
|
|
142
|
+
host = networks[0].address;
|
|
143
|
+
if (host.includes(':')) host = `[${host}]`;
|
|
144
|
+
}
|
|
145
|
+
if (!host) throw new Error("No valid IP found");
|
|
146
|
+
return host;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_emitOnErrors_plugin_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_emitOnErrors_plugin_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/plugins/emitOnErrors.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginEmitOnErrors: ()=>pluginEmitOnErrors
|
|
9
|
+
});
|
|
10
|
+
function pluginEmitOnErrors() {
|
|
11
|
+
return {
|
|
12
|
+
name: 'lynx:rsbuild:emit-on-errors',
|
|
13
|
+
setup (api) {
|
|
14
|
+
api.modifyBundlerChain((chain)=>{
|
|
15
|
+
chain.optimization.emitOnErrors(true);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_index_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_index_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/plugins/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
applyDefaultPlugins: ()=>applyDefaultPlugins
|
|
10
|
+
});
|
|
11
|
+
var _debug_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/debug.ts");
|
|
12
|
+
async function applyDebugPlugins(rsbuildInstance, config) {
|
|
13
|
+
const debugPlugins = Object.freeze([
|
|
14
|
+
__webpack_require__.e("src_plugins_emitOnErrors_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/emitOnErrors.plugin.ts")).then(({ pluginEmitOnErrors })=>pluginEmitOnErrors()),
|
|
15
|
+
Promise.all([
|
|
16
|
+
__webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc"),
|
|
17
|
+
__webpack_require__.e("src_plugins_inspect_plugin_ts")
|
|
18
|
+
]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts")).then(({ pluginInspect })=>pluginInspect(config))
|
|
19
|
+
]);
|
|
20
|
+
rsbuildInstance.addPlugins(await Promise.all(debugPlugins));
|
|
21
|
+
}
|
|
22
|
+
async function applyDefaultPlugins(rsbuildInstance, config) {
|
|
23
|
+
const defaultPlugins = Object.freeze([
|
|
24
|
+
__webpack_require__.e("src_plugins_api_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/api.plugin.ts")).then(({ pluginAPI })=>pluginAPI(config)),
|
|
25
|
+
__webpack_require__.e("src_plugins_chunkLoading_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/chunkLoading.plugin.ts")).then(({ pluginChunkLoading })=>pluginChunkLoading()),
|
|
26
|
+
__webpack_require__.e("src_plugins_dev_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/dev.plugin.ts")).then(({ pluginDev })=>pluginDev(config.dev, config.server)),
|
|
27
|
+
__webpack_require__.e("src_plugins_minify_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/minify.plugin.ts")).then(({ pluginMinify })=>pluginMinify(config.output?.minify)),
|
|
28
|
+
__webpack_require__.e("src_plugins_optimization_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/optimization.plugin.ts")).then(({ pluginOptimization })=>pluginOptimization()),
|
|
29
|
+
__webpack_require__.e("src_plugins_output_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/output.plugin.ts")).then(({ pluginOutput })=>pluginOutput(config.output)),
|
|
30
|
+
__webpack_require__.e("src_plugins_resolve_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/resolve.plugin.ts")).then(({ pluginResolve })=>pluginResolve()),
|
|
31
|
+
__webpack_require__.e("src_plugins_rsdoctor_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/rsdoctor.plugin.ts")).then(({ pluginRsdoctor })=>pluginRsdoctor(config.tools?.rsdoctor)),
|
|
32
|
+
__webpack_require__.e("src_plugins_sourcemap_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/sourcemap.plugin.ts")).then(({ pluginSourcemap })=>pluginSourcemap()),
|
|
33
|
+
__webpack_require__.e("src_plugins_swc_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/swc.plugin.ts")).then(({ pluginSwc })=>pluginSwc()),
|
|
34
|
+
__webpack_require__.e("src_plugins_target_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/target.plugin.ts")).then(({ pluginTarget })=>pluginTarget())
|
|
35
|
+
]);
|
|
36
|
+
const promises = [
|
|
37
|
+
Promise.all(defaultPlugins).then((plugins)=>{
|
|
38
|
+
rsbuildInstance.addPlugins(plugins);
|
|
39
|
+
})
|
|
40
|
+
];
|
|
41
|
+
if ((0, _debug_js__WEBPACK_IMPORTED_MODULE_0__._o)()) {
|
|
42
|
+
(0, _debug_js__WEBPACK_IMPORTED_MODULE_0__.Yz)('apply Rspeedy default debug plugins');
|
|
43
|
+
promises.push(applyDebugPlugins(rsbuildInstance, config));
|
|
44
|
+
}
|
|
45
|
+
await Promise.all(promises);
|
|
46
|
+
const { pluginCssMinimizer, PLUGIN_CSS_MINIMIZER_NAME } = await import("@rsbuild/plugin-css-minimizer");
|
|
47
|
+
if (!rsbuildInstance.isPluginExists(PLUGIN_CSS_MINIMIZER_NAME)) rsbuildInstance.addPlugins([
|
|
48
|
+
pluginCssMinimizer()
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
export const __webpack_id__ = "src_plugins_inspect_plugin_ts";
|
|
3
|
+
export const __webpack_ids__ = [
|
|
4
|
+
"src_plugins_inspect_plugin_ts"
|
|
5
|
+
];
|
|
6
|
+
export const __webpack_modules__ = {
|
|
7
|
+
"./src/config/output/dist-path.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
z: ()=>DEFAULT_DIST_PATH_INTERMEDIATE
|
|
10
|
+
});
|
|
11
|
+
const DEFAULT_DIST_PATH_INTERMEDIATE = '.rspeedy';
|
|
12
|
+
},
|
|
13
|
+
"./src/plugins/inspect.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
14
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
15
|
+
inspectRspeedyConfig: ()=>inspectRspeedyConfig,
|
|
16
|
+
pluginInspect: ()=>pluginInspect
|
|
17
|
+
});
|
|
18
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
19
|
+
var core_ = __webpack_require__("@rsbuild/core");
|
|
20
|
+
var dist = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js");
|
|
21
|
+
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
22
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
23
|
+
var dist_path = __webpack_require__("./src/config/output/dist-path.ts");
|
|
24
|
+
var debug = __webpack_require__("./src/debug.ts");
|
|
25
|
+
function pluginInspect(config) {
|
|
26
|
+
return {
|
|
27
|
+
name: 'lynx:rsbuild:inspect',
|
|
28
|
+
setup (api) {
|
|
29
|
+
api.onBeforeBuild(async ()=>{
|
|
30
|
+
await inspectRspeedyConfig(config, external_node_path_["default"].join(api.context.distPath, dist_path.z, 'rspeedy.config.js'), false);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async function inspectRspeedyConfig(config, path, verbose) {
|
|
36
|
+
const stringifiedConfig = (0, dist.stringify)(config, (value, _, stringify)=>{
|
|
37
|
+
if ('function' == typeof value && !verbose && value.toString().length > 100) return "function () { /* omitted long function */ }";
|
|
38
|
+
return stringify(value);
|
|
39
|
+
}, 2);
|
|
40
|
+
if (!stringifiedConfig) return void (0, debug.Yz)('No Rspeedy config found, skip inspect config.');
|
|
41
|
+
await mkdir((0, external_node_path_.dirname)(path), {
|
|
42
|
+
recursive: true
|
|
43
|
+
});
|
|
44
|
+
await writeFile(path, `export default ${stringifiedConfig}`);
|
|
45
|
+
core_.logger.success(`Inspect Rspeedy config succeed, open following files to view the content: \n\n - ${picocolors_default().bold(picocolors_default().yellow('Rspeedy'))}: ${picocolors_default().underline(path)}\n`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_minify_plugin_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_minify_plugin_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/plugins/minify.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginMinify: ()=>pluginMinify
|
|
9
|
+
});
|
|
10
|
+
var _debug_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/debug.ts");
|
|
11
|
+
function pluginMinify(options) {
|
|
12
|
+
const defaultConfig = Object.freeze({
|
|
13
|
+
output: {
|
|
14
|
+
minify: {
|
|
15
|
+
js: true,
|
|
16
|
+
jsOptions: {
|
|
17
|
+
minimizerOptions: {
|
|
18
|
+
compress: {
|
|
19
|
+
negate_iife: false,
|
|
20
|
+
join_vars: false,
|
|
21
|
+
ecma: 2015,
|
|
22
|
+
inline: 2,
|
|
23
|
+
comparisons: false,
|
|
24
|
+
toplevel: true,
|
|
25
|
+
side_effects: false
|
|
26
|
+
},
|
|
27
|
+
format: {
|
|
28
|
+
keep_quoted_props: true,
|
|
29
|
+
comments: false
|
|
30
|
+
},
|
|
31
|
+
mangle: {
|
|
32
|
+
toplevel: true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
css: true,
|
|
37
|
+
cssOptions: {
|
|
38
|
+
minimizerOptions: {
|
|
39
|
+
targets: '',
|
|
40
|
+
include: {
|
|
41
|
+
nesting: true,
|
|
42
|
+
doublePositionGradients: true,
|
|
43
|
+
spaceSeparatedColorNotation: true
|
|
44
|
+
},
|
|
45
|
+
exclude: {
|
|
46
|
+
vendorPrefixes: true,
|
|
47
|
+
logicalProperties: true,
|
|
48
|
+
hexAlphaColors: true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
name: 'lynx:rsbuild:minify',
|
|
57
|
+
setup (api) {
|
|
58
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
59
|
+
if (false === options) {
|
|
60
|
+
(0, _debug_js__WEBPACK_IMPORTED_MODULE_0__.Yz)("minification disabled");
|
|
61
|
+
return mergeRsbuildConfig(config, {
|
|
62
|
+
output: {
|
|
63
|
+
minify: false
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const configs = [
|
|
68
|
+
config,
|
|
69
|
+
defaultConfig
|
|
70
|
+
];
|
|
71
|
+
if (true !== options && void 0 !== options) {
|
|
72
|
+
(0, _debug_js__WEBPACK_IMPORTED_MODULE_0__.Yz)("merging minification options");
|
|
73
|
+
configs.push({
|
|
74
|
+
output: {
|
|
75
|
+
minify: options
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return mergeRsbuildConfig(...configs);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_optimization_plugin_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_optimization_plugin_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/plugins/optimization.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginOptimization: ()=>pluginOptimization
|
|
9
|
+
});
|
|
10
|
+
function pluginOptimization() {
|
|
11
|
+
return {
|
|
12
|
+
name: 'lynx:rsbuild:optimization',
|
|
13
|
+
setup (api) {
|
|
14
|
+
api.modifyBundlerChain((chain, { CHAIN_ID, isProd })=>{
|
|
15
|
+
const rule = chain.module.rules.get(CHAIN_ID.RULE.JS);
|
|
16
|
+
chain.module.rule('js-override-strict').type(rule.get('type')).test(rule.get('test')).parser({
|
|
17
|
+
overrideStrict: 'strict'
|
|
18
|
+
}).end();
|
|
19
|
+
if (isProd) chain.optimization.avoidEntryIife(true);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_output_plugin_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_output_plugin_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/config/output/dist-path.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
z: ()=>DEFAULT_DIST_PATH_INTERMEDIATE
|
|
9
|
+
});
|
|
10
|
+
const DEFAULT_DIST_PATH_INTERMEDIATE = '.rspeedy';
|
|
11
|
+
},
|
|
12
|
+
"./src/plugins/output.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
13
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
14
|
+
pluginOutput: ()=>pluginOutput
|
|
15
|
+
});
|
|
16
|
+
var _config_output_dist_path_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/config/output/dist-path.ts");
|
|
17
|
+
const defaultFilenameOptions = Object.freeze({
|
|
18
|
+
css: '[name]/[name].css'
|
|
19
|
+
});
|
|
20
|
+
const defaultDistPathOptions = Object.freeze({
|
|
21
|
+
css: _config_output_dist_path_js__WEBPACK_IMPORTED_MODULE_0__.z
|
|
22
|
+
});
|
|
23
|
+
function pluginOutput(options) {
|
|
24
|
+
return {
|
|
25
|
+
name: 'lynx:rsbuild:output',
|
|
26
|
+
setup (api) {
|
|
27
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
28
|
+
if (!options) return mergeRsbuildConfig({
|
|
29
|
+
output: {
|
|
30
|
+
filename: {
|
|
31
|
+
css: defaultFilenameOptions.css
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, config);
|
|
35
|
+
return mergeRsbuildConfig(config, {
|
|
36
|
+
output: {
|
|
37
|
+
distPath: Object.assign({}, defaultDistPathOptions, options.distPath),
|
|
38
|
+
filename: Object.assign({}, defaultFilenameOptions, options.filename)
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_resolve_plugin_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_resolve_plugin_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/plugins/resolve.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginResolve: ()=>pluginResolve
|
|
9
|
+
});
|
|
10
|
+
function pluginResolve() {
|
|
11
|
+
return {
|
|
12
|
+
name: 'lynx:rsbuild:resolve',
|
|
13
|
+
setup (api) {
|
|
14
|
+
api.modifyBundlerChain((chain)=>{
|
|
15
|
+
chain.resolve.aliasFields.add('browser').end().conditionNames.add('lynx').add('import').add('require').add('browser').end().extensions.add('.cjs').end().mainFields.add('lynx').add('module').add('main').end().mainFiles.add('index.lynx').add('index').end().end().end();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -4,7 +4,6 @@ export const __webpack_ids__ = [
|
|
|
4
4
|
];
|
|
5
5
|
export const __webpack_modules__ = {
|
|
6
6
|
"./src/plugins/rsdoctor.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
-
__webpack_require__.r(__webpack_exports__);
|
|
8
7
|
__webpack_require__.d(__webpack_exports__, {
|
|
9
8
|
pluginRsdoctor: ()=>pluginRsdoctor
|
|
10
9
|
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_sourcemap_plugin_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_sourcemap_plugin_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/plugins/sourcemap.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginSourcemap: ()=>pluginSourcemap
|
|
9
|
+
});
|
|
10
|
+
var isProduction = 'production' === process.env.NODE_ENV;
|
|
11
|
+
var prefix = 'Invariant failed';
|
|
12
|
+
function invariant(condition, message) {
|
|
13
|
+
if (condition) return;
|
|
14
|
+
if (isProduction) throw new Error(prefix);
|
|
15
|
+
var provided = 'function' == typeof message ? message() : message;
|
|
16
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
17
|
+
throw new Error(value);
|
|
18
|
+
}
|
|
19
|
+
class EvalSourceMapDevToolPlugin_EvalSourceMapDevToolPlugin {
|
|
20
|
+
options;
|
|
21
|
+
constructor(options){
|
|
22
|
+
this.options = options;
|
|
23
|
+
}
|
|
24
|
+
apply(compiler) {
|
|
25
|
+
const { EvalSourceMapDevToolPlugin } = compiler.webpack;
|
|
26
|
+
new EvalSourceMapDevToolPlugin(this.options).apply(compiler);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class SourceMapDevToolPlugin_SourceMapDevToolPlugin {
|
|
30
|
+
options;
|
|
31
|
+
constructor(options){
|
|
32
|
+
this.options = options;
|
|
33
|
+
}
|
|
34
|
+
apply(compiler) {
|
|
35
|
+
const { SourceMapDevToolPlugin } = compiler.webpack;
|
|
36
|
+
new SourceMapDevToolPlugin(this.options).apply(compiler);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function pluginSourcemap() {
|
|
40
|
+
return {
|
|
41
|
+
name: 'lynx:rsbuild:sourcemap',
|
|
42
|
+
pre: [
|
|
43
|
+
'lynx:rsbuild:dev'
|
|
44
|
+
],
|
|
45
|
+
setup (api) {
|
|
46
|
+
api.modifyBundlerChain((chain, { isDev })=>{
|
|
47
|
+
const { dev, output, server } = api.getRsbuildConfig('current');
|
|
48
|
+
const publicPath = isDev ? dev?.assetPrefix : output?.assetPrefix;
|
|
49
|
+
if (false === publicPath) return;
|
|
50
|
+
invariant('string' == typeof publicPath || void 0 === publicPath, `dev.assetPrefix should be normalized to string, got ${dev?.assetPrefix}`);
|
|
51
|
+
applySourceMapPlugin(chain, getDevtoolFromSourceMap(), publicPath?.replaceAll('<port>', String(api.context.devServer?.port ?? server?.port)));
|
|
52
|
+
function getDevtoolFromSourceMap() {
|
|
53
|
+
const DEFAULT_DEV_DEVTOOL = 'cheap-module-source-map';
|
|
54
|
+
switch(typeof output?.sourceMap){
|
|
55
|
+
case 'boolean':
|
|
56
|
+
if (output.sourceMap) return isDev ? DEFAULT_DEV_DEVTOOL : 'source-map';
|
|
57
|
+
return false;
|
|
58
|
+
case 'undefined':
|
|
59
|
+
case 'object':
|
|
60
|
+
return output?.sourceMap?.js ?? (isDev ? DEFAULT_DEV_DEVTOOL : false);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function applySourceMapPlugin(chain, devtool, publicPath) {
|
|
68
|
+
if (false === devtool) return;
|
|
69
|
+
const CHAIN_ID_DEV_SOURCEMAP = 'lynx:sourcemap';
|
|
70
|
+
const output = chain.get('output');
|
|
71
|
+
if (devtool.includes('source-map')) {
|
|
72
|
+
const hidden = devtool.includes('hidden');
|
|
73
|
+
const inline = devtool.includes('inline');
|
|
74
|
+
const evalWrapped = devtool.includes('eval');
|
|
75
|
+
const cheap = devtool.includes('cheap');
|
|
76
|
+
const moduleMaps = devtool.includes('module');
|
|
77
|
+
const noSources = devtool.includes('nosources');
|
|
78
|
+
const debugIds = devtool.includes('debugids');
|
|
79
|
+
const options = {
|
|
80
|
+
filename: inline ? null : output?.sourceMapFilename ?? '[file].map[query]',
|
|
81
|
+
moduleFilenameTemplate: output?.devtoolModuleFilenameTemplate ?? 'file://[absolute-resource-path]',
|
|
82
|
+
fallbackModuleFilenameTemplate: output?.devtoolFallbackModuleFilenameTemplate ?? 'file://[absolute-resource-path]?[hash]',
|
|
83
|
+
append: hidden ? false : void 0,
|
|
84
|
+
module: moduleMaps ? true : !cheap,
|
|
85
|
+
columns: !cheap,
|
|
86
|
+
noSources,
|
|
87
|
+
namespace: output?.devtoolNamespace,
|
|
88
|
+
publicPath,
|
|
89
|
+
debugIds
|
|
90
|
+
};
|
|
91
|
+
chain.devtool(false).plugin(CHAIN_ID_DEV_SOURCEMAP).when(evalWrapped, (plugin)=>plugin.use(EvalSourceMapDevToolPlugin_EvalSourceMapDevToolPlugin, [
|
|
92
|
+
options
|
|
93
|
+
]), (plugin)=>plugin.use(SourceMapDevToolPlugin_SourceMapDevToolPlugin, [
|
|
94
|
+
options
|
|
95
|
+
]));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_plugins_swc_plugin_ts";
|
|
2
|
+
export const __webpack_ids__ = [
|
|
3
|
+
"src_plugins_swc_plugin_ts"
|
|
4
|
+
];
|
|
5
|
+
export const __webpack_modules__ = {
|
|
6
|
+
"./src/plugins/swc.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginSwc: ()=>pluginSwc
|
|
9
|
+
});
|
|
10
|
+
var _utils_getESVersionTarget_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/getESVersionTarget.ts");
|
|
11
|
+
function pluginSwc() {
|
|
12
|
+
return {
|
|
13
|
+
name: 'lynx:rsbuild:swc',
|
|
14
|
+
setup (api) {
|
|
15
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
16
|
+
const isProd = 'production' === config.mode;
|
|
17
|
+
return mergeRsbuildConfig(config, {
|
|
18
|
+
tools: {
|
|
19
|
+
swc (config) {
|
|
20
|
+
delete config.env;
|
|
21
|
+
config.jsc ??= {};
|
|
22
|
+
config.jsc.target = (0, _utils_getESVersionTarget_js__WEBPACK_IMPORTED_MODULE_0__.y)(isProd);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./src/utils/getESVersionTarget.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
32
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
33
|
+
y: ()=>getESVersionTarget
|
|
34
|
+
});
|
|
35
|
+
function getESVersionTarget(isProd) {
|
|
36
|
+
return isProd ? 'es2015' : 'es2019';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|