@lynx-js/rspeedy 0.8.7 → 0.9.1
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 +51 -0
- package/bin/rspeedy.js +2 -2
- package/dist/cli/main.js +414 -0
- package/dist/cli/start.js +171 -0
- package/dist/index.d.ts +2971 -0
- package/dist/index.js +39556 -0
- package/dist/register/hooks.js +552 -0
- package/dist/register/index.js +22 -0
- package/dist/src_cli_build_ts.js +47 -0
- package/dist/src_cli_commands_ts.js +60 -0
- package/dist/src_cli_dev_ts.js +87 -0
- package/dist/src_cli_exit_ts.js +111 -0
- package/dist/src_cli_inspect_ts.js +42 -0
- package/dist/src_cli_preview_ts.js +49 -0
- package/dist/src_config_loadConfig_ts-src_create-rspeedy_ts.js +39311 -0
- package/dist/src_plugins_api_plugin_ts.js +32 -0
- package/dist/src_plugins_chunkLoading_plugin_ts.js +35 -0
- package/dist/src_plugins_dev_plugin_ts.js +141 -0
- package/dist/src_plugins_index_ts.js +60 -0
- package/dist/src_plugins_inspect_plugin_ts.js +48 -0
- package/dist/src_plugins_minify_plugin_ts.js +85 -0
- package/dist/src_plugins_optimization_plugin_ts.js +25 -0
- package/dist/src_plugins_output_plugin_ts.js +46 -0
- package/dist/src_plugins_resolve_plugin_ts.js +21 -0
- package/dist/src_plugins_rsdoctor_plugin_ts.js +59 -0
- package/dist/src_plugins_sourcemap_plugin_ts.js +99 -0
- package/dist/src_plugins_stats_plugin_ts.js +26 -0
- package/dist/src_plugins_swc_plugin_ts.js +36 -0
- package/dist/src_plugins_target_plugin_ts.js +45 -0
- package/dist/src_version_ts.js +18 -0
- package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1435 -0
- package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt +1 -0
- package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1761 -0
- package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1067 -0
- package/dist/vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be.js +416 -0
- package/package.json +36 -23
- package/LICENSE +0 -202
- package/lib/api.d.ts +0 -46
- package/lib/api.js +0 -2
- package/lib/cli/build.d.ts +0 -4
- package/lib/cli/build.js +0 -32
- package/lib/cli/commands.d.ts +0 -5
- package/lib/cli/commands.js +0 -45
- package/lib/cli/dev.d.ts +0 -4
- package/lib/cli/dev.js +0 -75
- package/lib/cli/exit.d.ts +0 -1
- package/lib/cli/exit.js +0 -51
- package/lib/cli/inspect.d.ts +0 -8
- package/lib/cli/inspect.js +0 -30
- package/lib/cli/main.d.ts +0 -1
- package/lib/cli/main.js +0 -39
- package/lib/cli/preview.d.ts +0 -4
- package/lib/cli/preview.js +0 -31
- package/lib/cli/start.d.ts +0 -6
- package/lib/cli/start.js +0 -88
- package/lib/config/defaults.d.ts +0 -2
- package/lib/config/defaults.js +0 -32
- package/lib/config/defineConfig.d.ts +0 -22
- package/lib/config/defineConfig.js +0 -24
- package/lib/config/dev/client.d.ts +0 -15
- package/lib/config/dev/client.js +0 -2
- package/lib/config/dev/index.d.ts +0 -173
- package/lib/config/dev/index.js +0 -2
- package/lib/config/index.d.ts +0 -172
- package/lib/config/index.js +0 -2
- package/lib/config/loadConfig.d.ts +0 -50
- package/lib/config/loadConfig.js +0 -98
- package/lib/config/mergeRspeedyConfig.d.ts +0 -36
- package/lib/config/mergeRspeedyConfig.js +0 -42
- package/lib/config/output/css-modules.d.ts +0 -84
- package/lib/config/output/css-modules.js +0 -2
- package/lib/config/output/dist-path.d.ts +0 -19
- package/lib/config/output/dist-path.js +0 -2
- package/lib/config/output/filename.d.ts +0 -167
- package/lib/config/output/filename.js +0 -2
- package/lib/config/output/index.d.ts +0 -324
- package/lib/config/output/index.js +0 -2
- package/lib/config/output/minify.d.ts +0 -80
- package/lib/config/output/minify.js +0 -2
- package/lib/config/output/source-map.d.ts +0 -68
- package/lib/config/output/source-map.js +0 -2
- package/lib/config/performance/chunk-split.d.ts +0 -192
- package/lib/config/performance/chunk-split.js +0 -2
- package/lib/config/performance/index.d.ts +0 -165
- package/lib/config/performance/index.js +0 -2
- package/lib/config/rsbuild/entry.d.ts +0 -3
- package/lib/config/rsbuild/entry.js +0 -31
- package/lib/config/rsbuild/index.d.ts +0 -4
- package/lib/config/rsbuild/index.js +0 -75
- package/lib/config/server/index.d.ts +0 -91
- package/lib/config/server/index.js +0 -2
- package/lib/config/source/decorators.d.ts +0 -43
- package/lib/config/source/decorators.js +0 -2
- package/lib/config/source/entry.d.ts +0 -84
- package/lib/config/source/entry.js +0 -2
- package/lib/config/source/index.d.ts +0 -474
- package/lib/config/source/index.js +0 -2
- package/lib/config/source/transformImport.d.ts +0 -106
- package/lib/config/source/transformImport.js +0 -2
- package/lib/config/tools/css-extract.d.ts +0 -72
- package/lib/config/tools/css-extract.js +0 -2
- package/lib/config/tools/css-loader.d.ts +0 -130
- package/lib/config/tools/css-loader.js +0 -2
- package/lib/config/tools/index.d.ts +0 -170
- package/lib/config/tools/index.js +0 -2
- package/lib/config/validate.d.ts +0 -4
- package/lib/config/validate.js +0 -28877
- package/lib/create-rspeedy.d.ts +0 -52
- package/lib/create-rspeedy.js +0 -49
- package/lib/debug.d.ts +0 -3
- package/lib/debug.js +0 -25
- package/lib/index.d.ts +0 -46
- package/lib/index.js +0 -11
- package/lib/plugins/api.plugin.d.ts +0 -3
- package/lib/plugins/api.plugin.js +0 -25
- package/lib/plugins/chunkLoading.plugin.d.ts +0 -2
- package/lib/plugins/chunkLoading.plugin.js +0 -43
- package/lib/plugins/dev.plugin.d.ts +0 -5
- package/lib/plugins/dev.plugin.js +0 -137
- package/lib/plugins/index.d.ts +0 -3
- package/lib/plugins/index.js +0 -49
- package/lib/plugins/inspect.plugin.d.ts +0 -4
- package/lib/plugins/inspect.plugin.js +0 -39
- package/lib/plugins/minify.plugin.d.ts +0 -3
- package/lib/plugins/minify.plugin.js +0 -89
- package/lib/plugins/optimization.plugin.d.ts +0 -2
- package/lib/plugins/optimization.plugin.js +0 -31
- package/lib/plugins/output.plugin.d.ts +0 -3
- package/lib/plugins/output.plugin.js +0 -34
- package/lib/plugins/resolve.plugin.d.ts +0 -2
- package/lib/plugins/resolve.plugin.js +0 -38
- package/lib/plugins/rsdoctor.plugin.d.ts +0 -3
- package/lib/plugins/rsdoctor.plugin.js +0 -48
- package/lib/plugins/sourcemap.plugin.d.ts +0 -2
- package/lib/plugins/sourcemap.plugin.js +0 -86
- package/lib/plugins/stats.plugin.d.ts +0 -2
- package/lib/plugins/stats.plugin.js +0 -20
- package/lib/plugins/swc.plugin.d.ts +0 -2
- package/lib/plugins/swc.plugin.js +0 -21
- package/lib/plugins/target.plugin.d.ts +0 -2
- package/lib/plugins/target.plugin.js +0 -22
- package/lib/utils/getESVersionTarget.d.ts +0 -1
- package/lib/utils/getESVersionTarget.js +0 -7
- package/lib/utils/is-ci.d.ts +0 -1
- package/lib/utils/is-ci.js +0 -7
- package/lib/utils/is-lynx.d.ts +0 -2
- package/lib/utils/is-lynx.js +0 -6
- package/lib/utils/is-web.d.ts +0 -2
- package/lib/utils/is-web.js +0 -6
- package/lib/version.d.ts +0 -4
- package/lib/version.js +0 -15
- package/lib/webpack/CompilationIdPlugin.d.ts +0 -4
- package/lib/webpack/CompilationIdPlugin.js +0 -20
- package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +0 -9
- package/lib/webpack/EvalSourceMapDevToolPlugin.js +0 -15
- package/lib/webpack/ProvidePlugin.d.ts +0 -9
- package/lib/webpack/ProvidePlugin.js +0 -15
- package/lib/webpack/SourceMapDevToolPlugin.d.ts +0 -9
- package/lib/webpack/SourceMapDevToolPlugin.js +0 -15
- package/register/data.d.ts +0 -9
- package/register/hooks.js +0 -146
- package/register/index.js +0 -47
- /package/{register → dist/register}/index.d.ts +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
'src_plugins_api_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/api.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginAPI: ()=>pluginAPI
|
|
9
|
+
});
|
|
10
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
11
|
+
var _debug_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/debug.ts");
|
|
12
|
+
var _version_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/version.ts");
|
|
13
|
+
const sAPI = Symbol.for('rspeedy.api');
|
|
14
|
+
function pluginAPI(config) {
|
|
15
|
+
return {
|
|
16
|
+
name: 'lynx:rsbuild:plugin-api',
|
|
17
|
+
setup (api) {
|
|
18
|
+
api.expose(sAPI, {
|
|
19
|
+
config,
|
|
20
|
+
debug: _debug_js__WEBPACK_IMPORTED_MODULE_1__.fF,
|
|
21
|
+
async exit (code) {
|
|
22
|
+
const { exit } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./src/cli/exit.ts"));
|
|
23
|
+
return exit(code);
|
|
24
|
+
},
|
|
25
|
+
logger: _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger,
|
|
26
|
+
version: _version_js__WEBPACK_IMPORTED_MODULE_2__.version
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
'src_plugins_chunkLoading_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/chunkLoading.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginChunkLoading: ()=>pluginChunkLoading
|
|
9
|
+
});
|
|
10
|
+
var chunk_loading_webpack_plugin_ = __webpack_require__("@lynx-js/chunk-loading-webpack-plugin");
|
|
11
|
+
function isLynx(environment) {
|
|
12
|
+
return 'string' == typeof environment ? 'lynx' === environment : 'lynx' === environment.name;
|
|
13
|
+
}
|
|
14
|
+
var is_web = __webpack_require__("./src/utils/is-web.ts");
|
|
15
|
+
function pluginChunkLoading() {
|
|
16
|
+
return {
|
|
17
|
+
name: 'lynx:rsbuild:chunk-loading',
|
|
18
|
+
setup (api) {
|
|
19
|
+
api.modifyBundlerChain((chain, { environment })=>{
|
|
20
|
+
if ((0, is_web.$)(environment)) return void chain.output.chunkLoading("import-scripts").end();
|
|
21
|
+
if (isLynx(environment)) chain.plugin('lynx:chunk-loading').use(chunk_loading_webpack_plugin_.ChunkLoadingWebpackPlugin).end().output.chunkLoading('lynx').chunkFormat('commonjs').iife(false).end();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./src/utils/is-web.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
28
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
+
$: ()=>isWeb
|
|
30
|
+
});
|
|
31
|
+
function isWeb(environment) {
|
|
32
|
+
return 'string' == typeof environment ? 'web' === environment : 'web' === environment.name;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
'src_plugins_dev_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/dev.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
findIp: ()=>findIp,
|
|
9
|
+
pluginDev: ()=>pluginDev
|
|
10
|
+
});
|
|
11
|
+
var external_node_module_ = __webpack_require__("node:module");
|
|
12
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
13
|
+
var core_ = __webpack_require__("@rsbuild/core");
|
|
14
|
+
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
15
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
16
|
+
var debug = __webpack_require__("./src/debug.ts");
|
|
17
|
+
class CompilationIdPlugin {
|
|
18
|
+
apply(compiler) {
|
|
19
|
+
compiler.hooks.initialize.tap('CompilationIdPlugin', ()=>{
|
|
20
|
+
const { DefinePlugin } = compiler.webpack;
|
|
21
|
+
new DefinePlugin({
|
|
22
|
+
RSPEEDY_COMPILATION_ID: JSON.stringify(getCompilationId(compiler))
|
|
23
|
+
}).apply(compiler);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const COMPILATION_ID_REGEX = /[^\w-]/g;
|
|
28
|
+
function getCompilationId(compiler) {
|
|
29
|
+
const uniqueName = compiler.options.output.uniqueName ?? '';
|
|
30
|
+
return `${compiler.name ?? ''}_${uniqueName.replace(COMPILATION_ID_REGEX, '_')}`;
|
|
31
|
+
}
|
|
32
|
+
class ProvidePlugin_ProvidePlugin {
|
|
33
|
+
definitions;
|
|
34
|
+
constructor(definitions){
|
|
35
|
+
this.definitions = definitions;
|
|
36
|
+
}
|
|
37
|
+
apply(compiler) {
|
|
38
|
+
const { ProvidePlugin } = compiler.webpack;
|
|
39
|
+
new ProvidePlugin(this.definitions).apply(compiler);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function pluginDev(options, server) {
|
|
43
|
+
return {
|
|
44
|
+
name: 'lynx:rsbuild:dev',
|
|
45
|
+
async setup (api) {
|
|
46
|
+
const hostname = server?.host ?? await findIp('v4');
|
|
47
|
+
let assetPrefix = options?.assetPrefix;
|
|
48
|
+
switch(typeof assetPrefix){
|
|
49
|
+
case 'string':
|
|
50
|
+
if (server?.port !== void 0) {
|
|
51
|
+
const hasPortPlaceholder = assetPrefix.includes('<port>');
|
|
52
|
+
if (!hasPortPlaceholder) {
|
|
53
|
+
const assetPrefixURL = new URL(assetPrefix);
|
|
54
|
+
if (assetPrefixURL.port !== String(server.port)) {
|
|
55
|
+
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.`);
|
|
56
|
+
assetPrefixURL.port = String(server.port);
|
|
57
|
+
assetPrefix = assetPrefixURL.toString();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case 'undefined':
|
|
63
|
+
case 'boolean':
|
|
64
|
+
if (options?.assetPrefix !== false) assetPrefix = `http://${hostname}:<port>/`;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (server?.base) {
|
|
68
|
+
if (assetPrefix.endsWith('/')) assetPrefix = assetPrefix.slice(0, -1);
|
|
69
|
+
assetPrefix = `${assetPrefix}${server.base}/`;
|
|
70
|
+
}
|
|
71
|
+
(0, debug.fF)(`dev.assetPrefix is normalized to ${assetPrefix}`);
|
|
72
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
|
|
73
|
+
dev: {
|
|
74
|
+
assetPrefix,
|
|
75
|
+
client: {
|
|
76
|
+
host: hostname
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
const require = (0, external_node_module_.createRequire)(import.meta.url);
|
|
81
|
+
api.modifyBundlerChain((chain, { isProd })=>{
|
|
82
|
+
if (isProd) return;
|
|
83
|
+
const rsbuildPath = require.resolve('@rsbuild/core');
|
|
84
|
+
const rspeedyDir = external_node_path_["default"].dirname(require.resolve('@lynx-js/rspeedy/package.json'));
|
|
85
|
+
chain.resolve.alias.set('webpack/hot/log.js', require.resolve('@rspack/core/hot/log', {
|
|
86
|
+
paths: [
|
|
87
|
+
rsbuildPath
|
|
88
|
+
]
|
|
89
|
+
})).set('webpack/hot/emitter.js', require.resolve('@rspack/core/hot/emitter', {
|
|
90
|
+
paths: [
|
|
91
|
+
rsbuildPath
|
|
92
|
+
]
|
|
93
|
+
})).set('@lynx-js/webpack-dev-transport/client', `${require.resolve('@lynx-js/webpack-dev-transport/client')}?hostname=${hostname}&port=${api.context.devServer?.port}&pathname=/rsbuild-hmr&hot=${options?.hmr ?? true}&live-reload=${options?.liveReload ?? true}&protocol=ws`).set('@rspack/core/hot/dev-server', require.resolve('@rspack/core/hot/dev-server', {
|
|
94
|
+
paths: [
|
|
95
|
+
rsbuildPath
|
|
96
|
+
]
|
|
97
|
+
})).end().end().plugin('lynx.hmr.provide').use(ProvidePlugin_ProvidePlugin, [
|
|
98
|
+
{
|
|
99
|
+
WebSocket: [
|
|
100
|
+
options?.client?.websocketTransport ?? require.resolve('@lynx-js/websocket'),
|
|
101
|
+
'default'
|
|
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().plugin('lynx.hmr.compilation-id').use(CompilationIdPlugin, []).end();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async function findIp(family, isInternal = false) {
|
|
118
|
+
const [{ default: ipaddr }, os] = await Promise.all([
|
|
119
|
+
__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)),
|
|
120
|
+
import("node:os")
|
|
121
|
+
]);
|
|
122
|
+
let host;
|
|
123
|
+
const networks = Object.values(os.networkInterfaces()).flatMap((networks)=>networks ?? []).filter((network)=>{
|
|
124
|
+
if (!network || !network.address) return false;
|
|
125
|
+
if (network.family !== `IP${family}`) return false;
|
|
126
|
+
if (network.internal !== isInternal) return false;
|
|
127
|
+
if ('v6' === family) {
|
|
128
|
+
const range = ipaddr.parse(network.address).range();
|
|
129
|
+
if ('ipv4Mapped' !== range && 'uniqueLocal' !== range) return false;
|
|
130
|
+
}
|
|
131
|
+
return network.address;
|
|
132
|
+
});
|
|
133
|
+
if (networks.length > 0) {
|
|
134
|
+
host = networks[0].address;
|
|
135
|
+
if (host.includes(':')) host = `[${host}]`;
|
|
136
|
+
}
|
|
137
|
+
if (!host) throw new Error("No valid IP found");
|
|
138
|
+
return host;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
'src_plugins_index_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
applyDefaultPlugins: ()=>applyDefaultPlugins
|
|
9
|
+
});
|
|
10
|
+
var _debug_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/debug.ts");
|
|
11
|
+
async function applyDebugPlugins(rsbuildInstance, config) {
|
|
12
|
+
const debugPlugins = Object.freeze([
|
|
13
|
+
Promise.all([
|
|
14
|
+
__webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be"),
|
|
15
|
+
__webpack_require__.e("src_plugins_inspect_plugin_ts")
|
|
16
|
+
]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts")).then(({ pluginInspect })=>pluginInspect(config)),
|
|
17
|
+
__webpack_require__.e("src_plugins_stats_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/stats.plugin.ts")).then(({ pluginStats })=>pluginStats())
|
|
18
|
+
]);
|
|
19
|
+
rsbuildInstance.addPlugins(await Promise.all(debugPlugins));
|
|
20
|
+
}
|
|
21
|
+
async function applyDefaultDevPlugins(rsbuildInstance, config) {
|
|
22
|
+
const devPlugins = Object.freeze([
|
|
23
|
+
__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))
|
|
24
|
+
]);
|
|
25
|
+
rsbuildInstance.addPlugins(await Promise.all(devPlugins));
|
|
26
|
+
}
|
|
27
|
+
async function applyDefaultPlugins(rsbuildInstance, config) {
|
|
28
|
+
const defaultPlugins = Object.freeze([
|
|
29
|
+
__webpack_require__.e("src_plugins_api_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/api.plugin.ts")).then(({ pluginAPI })=>pluginAPI(config)),
|
|
30
|
+
__webpack_require__.e("src_plugins_chunkLoading_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/chunkLoading.plugin.ts")).then(({ pluginChunkLoading })=>pluginChunkLoading()),
|
|
31
|
+
__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)),
|
|
32
|
+
__webpack_require__.e("src_plugins_optimization_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/optimization.plugin.ts")).then(({ pluginOptimization })=>pluginOptimization()),
|
|
33
|
+
__webpack_require__.e("src_plugins_output_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/output.plugin.ts")).then(({ pluginOutput })=>pluginOutput(config.output)),
|
|
34
|
+
__webpack_require__.e("src_plugins_resolve_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/resolve.plugin.ts")).then(({ pluginResolve })=>pluginResolve()),
|
|
35
|
+
__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)),
|
|
36
|
+
__webpack_require__.e("src_plugins_sourcemap_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/sourcemap.plugin.ts")).then(({ pluginSourcemap })=>pluginSourcemap()),
|
|
37
|
+
__webpack_require__.e("src_plugins_swc_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/swc.plugin.ts")).then(({ pluginSwc })=>pluginSwc()),
|
|
38
|
+
__webpack_require__.e("src_plugins_target_plugin_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/target.plugin.ts")).then(({ pluginTarget })=>pluginTarget())
|
|
39
|
+
]);
|
|
40
|
+
const promises = [
|
|
41
|
+
Promise.all(defaultPlugins).then((plugins)=>{
|
|
42
|
+
rsbuildInstance.addPlugins(plugins);
|
|
43
|
+
})
|
|
44
|
+
];
|
|
45
|
+
if ('development' === process.env['NODE_ENV']) {
|
|
46
|
+
(0, _debug_js__WEBPACK_IMPORTED_MODULE_0__.fF)('apply Rspeedy default development plugins');
|
|
47
|
+
promises.push(applyDefaultDevPlugins(rsbuildInstance, config));
|
|
48
|
+
}
|
|
49
|
+
if ((0, _debug_js__WEBPACK_IMPORTED_MODULE_0__.L1)()) {
|
|
50
|
+
(0, _debug_js__WEBPACK_IMPORTED_MODULE_0__.fF)('apply Rspeedy default debug plugins');
|
|
51
|
+
promises.push(applyDebugPlugins(rsbuildInstance, config));
|
|
52
|
+
}
|
|
53
|
+
await Promise.all(promises);
|
|
54
|
+
const { pluginCssMinimizer, PLUGIN_CSS_MINIMIZER_NAME } = await import("@rsbuild/plugin-css-minimizer");
|
|
55
|
+
if (!rsbuildInstance.isPluginExists(PLUGIN_CSS_MINIMIZER_NAME)) rsbuildInstance.addPlugins([
|
|
56
|
+
pluginCssMinimizer()
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
'src_plugins_inspect_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/config/output/dist-path.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
+
A: ()=>DEFAULT_DIST_PATH_INTERMEDIATE
|
|
8
|
+
});
|
|
9
|
+
const DEFAULT_DIST_PATH_INTERMEDIATE = '.rspeedy';
|
|
10
|
+
},
|
|
11
|
+
"./src/plugins/inspect.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
12
|
+
__webpack_require__.r(__webpack_exports__);
|
|
13
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
14
|
+
inspectRspeedyConfig: ()=>inspectRspeedyConfig,
|
|
15
|
+
pluginInspect: ()=>pluginInspect
|
|
16
|
+
});
|
|
17
|
+
var node_fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs/promises");
|
|
18
|
+
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
19
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@rsbuild/core");
|
|
20
|
+
var javascript_stringify__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js");
|
|
21
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
22
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_6__);
|
|
23
|
+
var _config_output_dist_path_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/config/output/dist-path.ts");
|
|
24
|
+
var _debug_js__WEBPACK_IMPORTED_MODULE_5__ = __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, node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(api.context.distPath, config.output?.distPath?.intermediate ?? _config_output_dist_path_js__WEBPACK_IMPORTED_MODULE_4__.A, 'rspeedy.config.js'), false);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async function inspectRspeedyConfig(config, path, verbose) {
|
|
36
|
+
const stringifiedConfig = (0, javascript_stringify__WEBPACK_IMPORTED_MODULE_3__.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_js__WEBPACK_IMPORTED_MODULE_5__.fF)('No Rspeedy config found, skip inspect config.');
|
|
41
|
+
await (0, node_fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir)((0, node_path__WEBPACK_IMPORTED_MODULE_1__.dirname)(path), {
|
|
42
|
+
recursive: true
|
|
43
|
+
});
|
|
44
|
+
await (0, node_fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile)(path, `export default ${stringifiedConfig}`);
|
|
45
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_2__.logger.success(`Inspect Rspeedy config succeed, open following files to view the content: \n\n - ${picocolors__WEBPACK_IMPORTED_MODULE_6___default().bold(picocolors__WEBPACK_IMPORTED_MODULE_6___default().yellow('Rspeedy'))}: ${picocolors__WEBPACK_IMPORTED_MODULE_6___default().underline(path)}\n`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
'src_plugins_minify_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/minify.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
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__.fF)("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__.fF)("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_ids__ = [
|
|
2
|
+
'src_plugins_optimization_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/optimization.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
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_ids__ = [
|
|
2
|
+
'src_plugins_output_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/config/output/dist-path.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
+
A: ()=>DEFAULT_DIST_PATH_INTERMEDIATE
|
|
8
|
+
});
|
|
9
|
+
const DEFAULT_DIST_PATH_INTERMEDIATE = '.rspeedy';
|
|
10
|
+
},
|
|
11
|
+
"./src/plugins/output.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
12
|
+
__webpack_require__.r(__webpack_exports__);
|
|
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__.A
|
|
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_ids__ = [
|
|
2
|
+
'src_plugins_resolve_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/resolve.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
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
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
'src_plugins_rsdoctor_plugin_ts'
|
|
3
|
+
];
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
|
+
"./src/plugins/rsdoctor.plugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.r(__webpack_exports__);
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
pluginRsdoctor: ()=>pluginRsdoctor
|
|
9
|
+
});
|
|
10
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
11
|
+
var _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/is-ci.ts");
|
|
12
|
+
function pluginRsdoctor(options) {
|
|
13
|
+
return {
|
|
14
|
+
name: 'lynx:rsbuild:rsdoctor',
|
|
15
|
+
remove: [
|
|
16
|
+
'rsbuild:rsdoctor'
|
|
17
|
+
],
|
|
18
|
+
setup (api) {
|
|
19
|
+
if ('true' !== process.env['RSDOCTOR']) return;
|
|
20
|
+
api.onBeforeCreateCompiler(async ({ bundlerConfigs })=>{
|
|
21
|
+
const { RsdoctorRspackPlugin } = await import("@rsdoctor/rspack-plugin");
|
|
22
|
+
for (const config of bundlerConfigs){
|
|
23
|
+
const pluginName = 'RsdoctorRspackPlugin';
|
|
24
|
+
const registered = config.plugins?.some((plugin)=>'object' == typeof plugin && plugin?.['isRsdoctorPlugin'] === true || plugin?.constructor?.name === pluginName);
|
|
25
|
+
if (registered) continue;
|
|
26
|
+
config.plugins ??= [];
|
|
27
|
+
const defaultOptions = {
|
|
28
|
+
disableClientServer: (0, _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_1__.y)(),
|
|
29
|
+
supports: {
|
|
30
|
+
banner: true
|
|
31
|
+
},
|
|
32
|
+
linter: {
|
|
33
|
+
rules: {
|
|
34
|
+
'ecma-version-check': options?.linter?.rules?.['ecma-version-check'] ?? [
|
|
35
|
+
'Warn',
|
|
36
|
+
{
|
|
37
|
+
ecmaVersion: 2019
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
config.plugins.push(new RsdoctorRspackPlugin((0, _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.mergeRsbuildConfig)(defaultOptions, options)));
|
|
44
|
+
}
|
|
45
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.info("Rsdoctor is enabled.");
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"./src/utils/is-ci.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
52
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
53
|
+
y: ()=>isCI
|
|
54
|
+
});
|
|
55
|
+
function isCI() {
|
|
56
|
+
return !!process.env['CI'] && 'false' !== process.env['CI'];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|