@lynx-js/rspeedy-canary 0.13.0-canary-20260105-ec1caf1a → 0.13.0-canary-20260105-03ea61ec
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 +1 -1
- package/dist/{0~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 0~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
- package/dist/0~src_cli_exit_ts.js +98 -108
- package/dist/0~src_config_output_dist-path_ts.js +2 -0
- package/dist/0~src_config_validate_ts.js +41917 -41925
- package/dist/0~src_plugins_api_plugin_ts.js +21 -31
- package/dist/0~src_plugins_chunkLoading_plugin_ts.js +10 -20
- package/dist/0~src_plugins_dev_plugin_ts.js +168 -179
- package/dist/0~src_plugins_emitOnErrors_plugin_ts.js +10 -20
- package/dist/0~src_plugins_index_ts.js +63 -51
- package/dist/0~src_plugins_inspect_plugin_ts.js +434 -39
- package/dist/0~src_plugins_minify_plugin_ts.js +66 -76
- package/dist/0~src_plugins_optimization_plugin_ts.js +14 -24
- package/dist/0~src_plugins_output_plugin_ts.js +29 -45
- package/dist/0~src_plugins_resolve_plugin_ts.js +10 -20
- package/dist/0~src_plugins_rsdoctor_plugin_ts.js +39 -49
- package/dist/0~src_plugins_sourcemap_plugin_ts.js +86 -96
- package/dist/0~src_plugins_swc_plugin_ts.js +20 -38
- package/dist/0~src_plugins_target_plugin_ts.js +21 -39
- package/dist/0~src_utils_getESVersionTarget_ts.js +4 -0
- package/dist/1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1422 -0
- package/dist/{1~vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js → 1~node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js} +17 -24
- package/dist/{1~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 1~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
- package/dist/1~src_cli_build_ts.js +35 -424
- package/dist/1~src_cli_commands_ts.js +56 -74
- package/dist/1~src_cli_dev_ts.js +29 -410
- package/dist/1~src_cli_init_ts-src_create-rspeedy_ts.js +318 -0
- package/dist/1~src_cli_inspect_ts.js +18 -356
- package/dist/1~src_cli_preview_ts.js +23 -359
- package/dist/1~src_cli_watch_ts.js +39 -0
- package/dist/1~src_config_output_dist-path_ts.js +2 -0
- package/dist/1~src_config_validate_ts.js +41917 -41925
- package/dist/1~src_plugins_api_plugin_ts.js +22 -31
- package/dist/1~src_plugins_chunkLoading_plugin_ts.js +10 -20
- package/dist/1~src_plugins_dev_plugin_ts.js +170 -179
- package/dist/1~src_plugins_emitOnErrors_plugin_ts.js +10 -20
- package/dist/1~src_plugins_index_ts.js +63 -51
- package/dist/1~src_plugins_inspect_plugin_ts.js +436 -39
- package/dist/1~src_plugins_minify_plugin_ts.js +66 -76
- package/dist/1~src_plugins_optimization_plugin_ts.js +14 -24
- package/dist/1~src_plugins_output_plugin_ts.js +29 -45
- package/dist/1~src_plugins_resolve_plugin_ts.js +10 -20
- package/dist/1~src_plugins_rsdoctor_plugin_ts.js +37 -55
- package/dist/1~src_plugins_sourcemap_plugin_ts.js +86 -96
- package/dist/1~src_plugins_swc_plugin_ts.js +20 -38
- package/dist/1~src_plugins_target_plugin_ts.js +21 -39
- package/dist/1~src_utils_getESVersionTarget_ts.js +4 -0
- package/dist/1~src_utils_is-ci_ts.js +4 -0
- package/dist/1~src_version_ts.js +6 -18
- package/dist/cli/main.js +1 -357
- package/dist/cli/start.js +16 -130
- package/dist/index.js +1 -524
- package/dist/node_fs.js +7 -0
- package/dist/node_path.js +7 -0
- package/dist/node_url.js +1 -0
- package/dist/rslib-runtime.js +75 -0
- package/dist/src_cli_main_ts.js +149 -0
- package/dist/src_debug_ts.js +93 -0
- package/dist/src_index_ts.js +381 -0
- package/package.json +1 -1
- package/dist/0~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
- package/dist/1~events-fs-fs_promises-os-path-stream.js +0 -30
- package/dist/1~node_child_process-node_events-node_fs-node_path.js +0 -22
- package/dist/1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +0 -1432
- package/dist/1~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
- /package/dist/{1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt → 1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt} +0 -0
|
@@ -1,32 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
config,
|
|
20
|
-
debug: _debug_js__rspack_import_1.Yz,
|
|
21
|
-
async exit (code) {
|
|
22
|
-
const { exit } = await __webpack_require__.e("src_cli_exit_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/exit.ts"));
|
|
23
|
-
return exit(code);
|
|
24
|
-
},
|
|
25
|
-
logger: _rsbuild_core__rspack_import_0.logger,
|
|
26
|
-
version: _version_js__rspack_import_2.rE
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
};
|
|
1
|
+
import { debug, logger, version as version_version } from "./src_index_ts.js";
|
|
2
|
+
const sAPI = Symbol.for('rspeedy.api');
|
|
3
|
+
function pluginAPI(config) {
|
|
4
|
+
return {
|
|
5
|
+
name: 'lynx:rsbuild:plugin-api',
|
|
6
|
+
setup (api) {
|
|
7
|
+
api.expose(sAPI, {
|
|
8
|
+
config,
|
|
9
|
+
debug: debug,
|
|
10
|
+
async exit (code) {
|
|
11
|
+
const { exit } = await import("./0~src_cli_exit_ts.js").then((mod)=>({
|
|
12
|
+
exit: mod.exit_exit
|
|
13
|
+
}));
|
|
14
|
+
return exit(code);
|
|
15
|
+
},
|
|
16
|
+
logger: logger,
|
|
17
|
+
version: version_version
|
|
18
|
+
});
|
|
30
19
|
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { pluginAPI };
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { LynxCacheEventsPlugin } from "@lynx-js/cache-events-webpack-plugin";
|
|
2
2
|
import { ChunkLoadingWebpackPlugin } from "@lynx-js/chunk-loading-webpack-plugin";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
};
|
|
3
|
+
function pluginChunkLoading() {
|
|
4
|
+
return {
|
|
5
|
+
name: 'lynx:rsbuild:chunk-loading',
|
|
6
|
+
setup (api) {
|
|
7
|
+
api.modifyBundlerChain((chain)=>{
|
|
8
|
+
chain.plugin('lynx:chunk-loading').use(ChunkLoadingWebpackPlugin).end().plugin('lynx:cache-events').use(LynxCacheEventsPlugin).end().output.chunkLoading('lynx').chunkFormat('commonjs').end();
|
|
9
|
+
});
|
|
21
10
|
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export { pluginChunkLoading };
|
|
@@ -1,191 +1,180 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let assetPrefix = options?.assetPrefix;
|
|
39
|
-
switch(typeof assetPrefix){
|
|
40
|
-
case 'string':
|
|
41
|
-
if (server?.port !== void 0) {
|
|
42
|
-
const hasPortPlaceholder = assetPrefix.includes('<port>');
|
|
43
|
-
if (!hasPortPlaceholder) {
|
|
44
|
-
const assetPrefixURL = new URL(assetPrefix);
|
|
45
|
-
if (assetPrefixURL.port !== String(server.port)) {
|
|
46
|
-
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.`);
|
|
47
|
-
assetPrefixURL.port = String(server.port);
|
|
48
|
-
assetPrefix = assetPrefixURL.toString();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
3
|
+
import { debug, node_path, logger } from "./src_index_ts.js";
|
|
4
|
+
function isLynx(environment) {
|
|
5
|
+
const environmentName = 'string' == typeof environment ? environment : environment.name;
|
|
6
|
+
return 'lynx' === environmentName || environmentName.startsWith('lynx-');
|
|
7
|
+
}
|
|
8
|
+
class ProvidePlugin_ProvidePlugin {
|
|
9
|
+
definitions;
|
|
10
|
+
constructor(definitions){
|
|
11
|
+
this.definitions = definitions;
|
|
12
|
+
}
|
|
13
|
+
apply(compiler) {
|
|
14
|
+
const { ProvidePlugin } = compiler.webpack;
|
|
15
|
+
new ProvidePlugin(this.definitions).apply(compiler);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
19
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
20
|
+
function pluginDev(options, server) {
|
|
21
|
+
return {
|
|
22
|
+
name: 'lynx:rsbuild:dev',
|
|
23
|
+
apply (config, { action }) {
|
|
24
|
+
return 'dev' === action || 'development' === config.mode;
|
|
25
|
+
},
|
|
26
|
+
async setup (api) {
|
|
27
|
+
const hostname = server?.host ?? await findIp('v4');
|
|
28
|
+
let assetPrefix = options?.assetPrefix;
|
|
29
|
+
switch(typeof assetPrefix){
|
|
30
|
+
case 'string':
|
|
31
|
+
if (server?.port !== void 0) {
|
|
32
|
+
const hasPortPlaceholder = assetPrefix.includes('<port>');
|
|
33
|
+
if (!hasPortPlaceholder) {
|
|
34
|
+
const assetPrefixURL = new URL(assetPrefix);
|
|
35
|
+
if (assetPrefixURL.port !== String(server.port)) {
|
|
36
|
+
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.`);
|
|
37
|
+
assetPrefixURL.port = String(server.port);
|
|
38
|
+
assetPrefix = assetPrefixURL.toString();
|
|
51
39
|
}
|
|
52
|
-
|
|
53
|
-
case 'undefined':
|
|
54
|
-
case 'boolean':
|
|
55
|
-
if (options?.assetPrefix !== false) assetPrefix = `http://${hostname}:<port>/`;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
if (server?.base) {
|
|
59
|
-
if (assetPrefix.endsWith('/')) assetPrefix = assetPrefix.slice(0, -1);
|
|
60
|
-
assetPrefix = `${assetPrefix}${server.base}/`;
|
|
40
|
+
}
|
|
61
41
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
42
|
+
break;
|
|
43
|
+
case 'undefined':
|
|
44
|
+
case 'boolean':
|
|
45
|
+
if (options?.assetPrefix !== false) assetPrefix = `http://${hostname}:<port>/`;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (server?.base) {
|
|
49
|
+
if (assetPrefix.endsWith('/')) assetPrefix = assetPrefix.slice(0, -1);
|
|
50
|
+
assetPrefix = `${assetPrefix}${server.base}/`;
|
|
51
|
+
}
|
|
52
|
+
debug(`dev.assetPrefix is normalized to ${assetPrefix}`);
|
|
53
|
+
api.onBeforeStartDevServer(async ({ environments, server })=>{
|
|
54
|
+
if (environments['web']) {
|
|
55
|
+
const { createWebVirtualFilesMiddleware } = await import("@lynx-js/web-rsbuild-server-middleware");
|
|
56
|
+
server.middlewares.use(createWebVirtualFilesMiddleware('/__web_preview'));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
|
|
60
|
+
dev: {
|
|
61
|
+
assetPrefix,
|
|
62
|
+
client: {
|
|
63
|
+
host: hostname,
|
|
64
|
+
port: '<port>'
|
|
67
65
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
},
|
|
67
|
+
output: {
|
|
68
|
+
assetPrefix
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
72
|
+
const rspeedyAPIs = api.useExposed(Symbol.for('rspeedy.api'));
|
|
73
|
+
const defaultFilename = '[name].[platform].bundle';
|
|
74
|
+
const { filename } = rspeedyAPIs.config.output ?? {};
|
|
75
|
+
let name;
|
|
76
|
+
name = filename ? 'object' == typeof filename ? filename.bundle ?? filename.template ?? defaultFilename : filename : defaultFilename;
|
|
77
|
+
if (config.server?.printUrls === void 0 || config.server?.printUrls === true) {
|
|
78
|
+
const environmentNames = Object.keys(config.environments ?? {});
|
|
79
|
+
return mergeRsbuildConfig(config, {
|
|
80
|
+
server: {
|
|
81
|
+
printUrls: (param)=>{
|
|
82
|
+
const finalUrls = [];
|
|
83
|
+
const baseForUrls = ('string' == typeof assetPrefix ? assetPrefix : `http://${hostname}:<port>/`).replaceAll('<port>', String(param.port));
|
|
84
|
+
for (const entry of Object.keys(config.source?.entry ?? {}))for (const environmentName of environmentNames){
|
|
85
|
+
const pathname = name.replaceAll('[name]', entry).replaceAll('[platform]', environmentName);
|
|
86
|
+
finalUrls.push({
|
|
87
|
+
label: environmentName,
|
|
88
|
+
url: new URL(pathname, baseForUrls).toString()
|
|
89
|
+
});
|
|
90
|
+
if ('web' === environmentName) finalUrls.push({
|
|
91
|
+
label: "Web Preview",
|
|
92
|
+
url: new URL(`/__web_preview?casename=${encodeURIComponent(pathname)}`, baseForUrls).toString()
|
|
93
|
+
});
|
|
75
94
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
95
|
+
return finalUrls.map((urlInfo)=>{
|
|
96
|
+
const label = urlInfo.label.charAt(0).toUpperCase() + urlInfo.label.slice(1);
|
|
97
|
+
urlInfo.label = label;
|
|
98
|
+
return urlInfo;
|
|
99
|
+
});
|
|
79
100
|
}
|
|
80
|
-
}));
|
|
81
|
-
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
82
|
-
const rspeedyAPIs = api.useExposed(Symbol.for('rspeedy.api'));
|
|
83
|
-
const defaultFilename = '[name].[platform].bundle';
|
|
84
|
-
const { filename } = rspeedyAPIs.config.output ?? {};
|
|
85
|
-
let name;
|
|
86
|
-
name = filename ? 'object' == typeof filename ? filename.bundle ?? filename.template ?? defaultFilename : filename : defaultFilename;
|
|
87
|
-
if (config.server?.printUrls === void 0 || config.server?.printUrls === true) {
|
|
88
|
-
const environmentNames = Object.keys(config.environments ?? {});
|
|
89
|
-
return mergeRsbuildConfig(config, {
|
|
90
|
-
server: {
|
|
91
|
-
printUrls: (param)=>{
|
|
92
|
-
const finalUrls = [];
|
|
93
|
-
const baseForUrls = ('string' == typeof assetPrefix ? assetPrefix : `http://${hostname}:<port>/`).replaceAll('<port>', String(param.port));
|
|
94
|
-
for (const entry of Object.keys(config.source?.entry ?? {}))for (const environmentName of environmentNames){
|
|
95
|
-
const pathname = name.replaceAll('[name]', entry).replaceAll('[platform]', environmentName);
|
|
96
|
-
finalUrls.push({
|
|
97
|
-
label: environmentName,
|
|
98
|
-
url: new URL(pathname, baseForUrls).toString()
|
|
99
|
-
});
|
|
100
|
-
if ('web' === environmentName) finalUrls.push({
|
|
101
|
-
label: "Web Preview",
|
|
102
|
-
url: new URL(`/__web_preview?casename=${encodeURIComponent(pathname)}`, baseForUrls).toString()
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return finalUrls.map((urlInfo)=>{
|
|
106
|
-
const label = urlInfo.label.charAt(0).toUpperCase() + urlInfo.label.slice(1);
|
|
107
|
-
urlInfo.label = label;
|
|
108
|
-
return urlInfo;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
101
|
}
|
|
114
|
-
return config;
|
|
115
102
|
});
|
|
116
|
-
const require = createRequire(import.meta.url);
|
|
117
|
-
api.modifyBundlerChain((chain, { isDev, environment })=>{
|
|
118
|
-
const { action } = api.context;
|
|
119
|
-
if ('dev' !== action && !isDev) return;
|
|
120
|
-
const rsbuildPath = require.resolve('@rsbuild/core');
|
|
121
|
-
const rspeedyDir = external_node_path_["default"].dirname(require.resolve('@lynx-js/rspeedy/package.json'));
|
|
122
|
-
const searchParams = new URLSearchParams({
|
|
123
|
-
hostname,
|
|
124
|
-
port: api.context.devServer?.port?.toString() ?? '',
|
|
125
|
-
pathname: '/rsbuild-hmr',
|
|
126
|
-
hot: environment.config.dev?.hmr ?? true ? 'true' : 'false',
|
|
127
|
-
'live-reload': environment.config.dev?.liveReload ?? true ? 'true' : 'false',
|
|
128
|
-
protocol: 'ws'
|
|
129
|
-
});
|
|
130
|
-
if (environment.webSocketToken) searchParams.set('token', environment.webSocketToken);
|
|
131
|
-
chain.resolve.alias.set('webpack/hot/log.js', require.resolve('@rspack/core/hot/log', {
|
|
132
|
-
paths: [
|
|
133
|
-
rsbuildPath
|
|
134
|
-
]
|
|
135
|
-
})).set('webpack/hot/emitter.js', require.resolve('@rspack/core/hot/emitter', {
|
|
136
|
-
paths: [
|
|
137
|
-
rsbuildPath
|
|
138
|
-
]
|
|
139
|
-
})).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', {
|
|
140
|
-
paths: [
|
|
141
|
-
rsbuildPath
|
|
142
|
-
]
|
|
143
|
-
})).end().end().plugin('lynx.hmr.provide.dev_server_client').use(ProvidePlugin_ProvidePlugin, [
|
|
144
|
-
{
|
|
145
|
-
__webpack_dev_server_client__: [
|
|
146
|
-
require.resolve('./client/hmr/WebSocketClient.js', {
|
|
147
|
-
paths: [
|
|
148
|
-
rspeedyDir
|
|
149
|
-
]
|
|
150
|
-
}),
|
|
151
|
-
'default'
|
|
152
|
-
]
|
|
153
|
-
}
|
|
154
|
-
]).end();
|
|
155
|
-
if (isLynx(environment)) chain.plugin('lynx.hmr.provide.websocket').use(ProvidePlugin_ProvidePlugin, [
|
|
156
|
-
{
|
|
157
|
-
WebSocket: [
|
|
158
|
-
options?.client?.websocketTransport ?? require.resolve('@lynx-js/websocket'),
|
|
159
|
-
'default'
|
|
160
|
-
]
|
|
161
|
-
}
|
|
162
|
-
]).end();
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
async function findIp(family, isInternal = false) {
|
|
168
|
-
const [{ default: ipaddr }, os] = await Promise.all([
|
|
169
|
-
__webpack_require__.e("vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js").then(__webpack_require__.t.bind(__webpack_require__, "../../../node_modules/.pnpm/ipaddr.js@2.3.0/node_modules/ipaddr.js/lib/ipaddr.js", 23)),
|
|
170
|
-
import("node:os")
|
|
171
|
-
]);
|
|
172
|
-
let host;
|
|
173
|
-
const networks = Object.values(os.networkInterfaces()).flatMap((networks)=>networks ?? []).filter((network)=>{
|
|
174
|
-
if (!network || !network.address) return false;
|
|
175
|
-
if (network.family !== `IP${family}`) return false;
|
|
176
|
-
if (network.internal !== isInternal) return false;
|
|
177
|
-
if ('v6' === family) {
|
|
178
|
-
const range = ipaddr.parse(network.address).range();
|
|
179
|
-
if ('ipv4Mapped' !== range && 'uniqueLocal' !== range) return false;
|
|
180
103
|
}
|
|
181
|
-
return
|
|
104
|
+
return config;
|
|
182
105
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
106
|
+
const require = createRequire(import.meta.url);
|
|
107
|
+
api.modifyBundlerChain((chain, { isDev, environment })=>{
|
|
108
|
+
const { action } = api.context;
|
|
109
|
+
if ('dev' !== action && !isDev) return;
|
|
110
|
+
const rsbuildPath = require.resolve('@rsbuild/core');
|
|
111
|
+
const rspeedyDir = node_path.dirname(require.resolve('@lynx-js/rspeedy/package.json'));
|
|
112
|
+
const searchParams = new URLSearchParams({
|
|
113
|
+
hostname,
|
|
114
|
+
port: api.context.devServer?.port?.toString() ?? '',
|
|
115
|
+
pathname: '/rsbuild-hmr',
|
|
116
|
+
hot: environment.config.dev?.hmr ?? true ? 'true' : 'false',
|
|
117
|
+
'live-reload': environment.config.dev?.liveReload ?? true ? 'true' : 'false',
|
|
118
|
+
protocol: 'ws'
|
|
119
|
+
});
|
|
120
|
+
if (environment.webSocketToken) searchParams.set('token', environment.webSocketToken);
|
|
121
|
+
chain.resolve.alias.set('webpack/hot/log.js', require.resolve('@rspack/core/hot/log', {
|
|
122
|
+
paths: [
|
|
123
|
+
rsbuildPath
|
|
124
|
+
]
|
|
125
|
+
})).set('webpack/hot/emitter.js', require.resolve('@rspack/core/hot/emitter', {
|
|
126
|
+
paths: [
|
|
127
|
+
rsbuildPath
|
|
128
|
+
]
|
|
129
|
+
})).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', {
|
|
130
|
+
paths: [
|
|
131
|
+
rsbuildPath
|
|
132
|
+
]
|
|
133
|
+
})).end().end().plugin('lynx.hmr.provide.dev_server_client').use(ProvidePlugin_ProvidePlugin, [
|
|
134
|
+
{
|
|
135
|
+
__webpack_dev_server_client__: [
|
|
136
|
+
require.resolve('./client/hmr/WebSocketClient.js', {
|
|
137
|
+
paths: [
|
|
138
|
+
rspeedyDir
|
|
139
|
+
]
|
|
140
|
+
}),
|
|
141
|
+
'default'
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
]).end();
|
|
145
|
+
if (isLynx(environment)) chain.plugin('lynx.hmr.provide.websocket').use(ProvidePlugin_ProvidePlugin, [
|
|
146
|
+
{
|
|
147
|
+
WebSocket: [
|
|
148
|
+
options?.client?.websocketTransport ?? require.resolve('@lynx-js/websocket'),
|
|
149
|
+
'default'
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
]).end();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async function findIp(family, isInternal = false) {
|
|
158
|
+
const [{ default: ipaddr }, os] = await Promise.all([
|
|
159
|
+
import("./0~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js").then(__webpack_require__.t.bind(__webpack_require__, "../../../node_modules/.pnpm/ipaddr.js@2.3.0/node_modules/ipaddr.js/lib/ipaddr.js", 23)),
|
|
160
|
+
import("node:os")
|
|
161
|
+
]);
|
|
162
|
+
let host;
|
|
163
|
+
const networks = Object.values(os.networkInterfaces()).flatMap((networks)=>networks ?? []).filter((network)=>{
|
|
164
|
+
if (!network || !network.address) return false;
|
|
165
|
+
if (network.family !== `IP${family}`) return false;
|
|
166
|
+
if (network.internal !== isInternal) return false;
|
|
167
|
+
if ('v6' === family) {
|
|
168
|
+
const range = ipaddr.parse(network.address).range();
|
|
169
|
+
if ('ipv4Mapped' !== range && 'uniqueLocal' !== range) return false;
|
|
189
170
|
}
|
|
171
|
+
return network.address;
|
|
172
|
+
});
|
|
173
|
+
if (networks.length > 0) {
|
|
174
|
+
host = networks[0].address;
|
|
175
|
+
if (host.includes(':')) host = `[${host}]`;
|
|
190
176
|
}
|
|
191
|
-
|
|
177
|
+
if (!host) throw new Error("No valid IP found");
|
|
178
|
+
return host;
|
|
179
|
+
}
|
|
180
|
+
export { pluginDev };
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
};
|
|
1
|
+
function pluginEmitOnErrors() {
|
|
2
|
+
return {
|
|
3
|
+
name: 'lynx:rsbuild:emit-on-errors',
|
|
4
|
+
setup (api) {
|
|
5
|
+
api.modifyBundlerChain((chain)=>{
|
|
6
|
+
chain.optimization.emitOnErrors(true);
|
|
7
|
+
});
|
|
19
8
|
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export { pluginEmitOnErrors };
|
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import { debug, isDebug } from "./src_index_ts.js";
|
|
2
|
+
async function applyDebugPlugins(rsbuildInstance, config) {
|
|
3
|
+
const debugPlugins = Object.freeze([
|
|
4
|
+
import("./0~src_plugins_emitOnErrors_plugin_ts.js").then((mod)=>({
|
|
5
|
+
pluginEmitOnErrors: mod.pluginEmitOnErrors
|
|
6
|
+
})).then(({ pluginEmitOnErrors })=>pluginEmitOnErrors()),
|
|
7
|
+
import("./0~src_plugins_inspect_plugin_ts.js").then((mod)=>({
|
|
8
|
+
pluginInspect: mod.pluginInspect
|
|
9
|
+
})).then(({ pluginInspect })=>pluginInspect(config))
|
|
10
|
+
]);
|
|
11
|
+
rsbuildInstance.addPlugins(await Promise.all(debugPlugins));
|
|
12
|
+
}
|
|
13
|
+
async function applyDefaultPlugins(rsbuildInstance, config) {
|
|
14
|
+
const defaultPlugins = Object.freeze([
|
|
15
|
+
import("./0~src_plugins_api_plugin_ts.js").then((mod)=>({
|
|
16
|
+
pluginAPI: mod.pluginAPI
|
|
17
|
+
})).then(({ pluginAPI })=>pluginAPI(config)),
|
|
18
|
+
import("./0~src_plugins_chunkLoading_plugin_ts.js").then((mod)=>({
|
|
19
|
+
pluginChunkLoading: mod.pluginChunkLoading
|
|
20
|
+
})).then(({ pluginChunkLoading })=>pluginChunkLoading()),
|
|
21
|
+
import("./0~src_plugins_dev_plugin_ts.js").then((mod)=>({
|
|
22
|
+
pluginDev: mod.pluginDev
|
|
23
|
+
})).then(({ pluginDev })=>pluginDev(config.dev, config.server)),
|
|
24
|
+
import("./0~src_plugins_minify_plugin_ts.js").then((mod)=>({
|
|
25
|
+
pluginMinify: mod.pluginMinify
|
|
26
|
+
})).then(({ pluginMinify })=>pluginMinify(config.output?.minify)),
|
|
27
|
+
import("./0~src_plugins_optimization_plugin_ts.js").then((mod)=>({
|
|
28
|
+
pluginOptimization: mod.pluginOptimization
|
|
29
|
+
})).then(({ pluginOptimization })=>pluginOptimization()),
|
|
30
|
+
import("./0~src_plugins_output_plugin_ts.js").then((mod)=>({
|
|
31
|
+
pluginOutput: mod.pluginOutput
|
|
32
|
+
})).then(({ pluginOutput })=>pluginOutput(config.output)),
|
|
33
|
+
import("./0~src_plugins_resolve_plugin_ts.js").then((mod)=>({
|
|
34
|
+
pluginResolve: mod.pluginResolve
|
|
35
|
+
})).then(({ pluginResolve })=>pluginResolve()),
|
|
36
|
+
import("./0~src_plugins_rsdoctor_plugin_ts.js").then((mod)=>({
|
|
37
|
+
pluginRsdoctor: mod.pluginRsdoctor
|
|
38
|
+
})).then(({ pluginRsdoctor })=>pluginRsdoctor(config.tools?.rsdoctor)),
|
|
39
|
+
import("./0~src_plugins_sourcemap_plugin_ts.js").then((mod)=>({
|
|
40
|
+
pluginSourcemap: mod.pluginSourcemap
|
|
41
|
+
})).then(({ pluginSourcemap })=>pluginSourcemap()),
|
|
42
|
+
import("./0~src_plugins_swc_plugin_ts.js").then((mod)=>({
|
|
43
|
+
pluginSwc: mod.pluginSwc
|
|
44
|
+
})).then(({ pluginSwc })=>pluginSwc()),
|
|
45
|
+
import("./0~src_plugins_target_plugin_ts.js").then((mod)=>({
|
|
46
|
+
pluginTarget: mod.pluginTarget
|
|
47
|
+
})).then(({ pluginTarget })=>pluginTarget())
|
|
48
|
+
]);
|
|
49
|
+
const promises = [
|
|
50
|
+
Promise.all(defaultPlugins).then((plugins)=>{
|
|
51
|
+
rsbuildInstance.addPlugins(plugins);
|
|
52
|
+
})
|
|
53
|
+
];
|
|
54
|
+
if (isDebug()) {
|
|
55
|
+
debug('apply Rspeedy default debug plugins');
|
|
56
|
+
promises.push(applyDebugPlugins(rsbuildInstance, config));
|
|
51
57
|
}
|
|
52
|
-
|
|
58
|
+
await Promise.all(promises);
|
|
59
|
+
const { pluginCssMinimizer, PLUGIN_CSS_MINIMIZER_NAME } = await import("@rsbuild/plugin-css-minimizer");
|
|
60
|
+
if (!rsbuildInstance.isPluginExists(PLUGIN_CSS_MINIMIZER_NAME)) rsbuildInstance.addPlugins([
|
|
61
|
+
pluginCssMinimizer()
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
export { applyDefaultPlugins };
|