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