@lynx-js/rspeedy 0.14.4 → 0.15.0
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 +123 -0
- package/dist/{0~src_plugins_api_plugin_ts.js → 0~api.plugin.js} +3 -4
- package/dist/{0~src_plugins_dev_plugin_ts.js → 0~dev.plugin.js} +19 -13
- package/dist/{0~src_cli_exit_ts.js → 0~exit.js} +4 -3
- package/dist/0~getESVersionTarget.js +33 -0
- package/dist/{0~src_plugins_inspect_plugin_ts.js → 0~inspect.plugin.js} +13 -28
- package/dist/{0~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 0~ipaddr.js} +2 -1
- package/dist/0~is-lynx.js +5 -0
- package/dist/{1~src_plugins_optimization_plugin_ts.js → 0~optimization.plugin.js} +3 -2
- package/dist/{0~src_plugins_output_plugin_ts.js → 0~output.plugin.js} +14 -3
- package/dist/0~plugins.js +40 -0
- package/dist/{0~src_plugins_rsdoctor_plugin_ts.js → 0~rsdoctor.plugin.js} +1 -1
- package/dist/{1~src_plugins_sourcemap_plugin_ts.js → 0~sourcemap.plugin.js} +19 -2
- package/dist/0~statsJson.plugin.js +26 -0
- package/dist/0~swc.plugin.js +25 -0
- package/dist/{0~src_plugins_target_plugin_ts.js → 0~target.plugin.js} +4 -4
- package/dist/{1~src_config_validate_ts.js → 0~validate.js} +17963 -28527
- package/dist/{1~src_plugins_api_plugin_ts.js → 1~api.plugin.js} +3 -4
- package/dist/{1~src_cli_build_ts.js → 1~build.js} +7 -7
- package/dist/{1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js → 1~chokidar.js} +47 -47
- package/dist/{1~src_cli_commands_ts.js → 1~commands.js} +7 -17
- package/dist/{1~src_cli_dev_ts.js → 1~dev.js} +6 -6
- package/dist/{1~src_plugins_dev_plugin_ts.js → 1~dev.plugin.js} +20 -16
- package/dist/{1~node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js → 1~esm.js} +33 -29
- package/dist/1~getESVersionTarget.js +33 -0
- package/dist/{1~src_cli_inspect_ts.js → 1~inspect.js} +2 -1
- package/dist/{1~src_plugins_inspect_plugin_ts.js → 1~inspect.plugin.js} +15 -32
- package/dist/{1~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 1~ipaddr.js} +2 -1
- package/dist/1~is-lynx.js +5 -0
- package/dist/{1~src_plugins_minify_plugin_ts.js → 1~minify.plugin.js} +2 -1
- package/dist/{0~src_plugins_optimization_plugin_ts.js → 1~optimization.plugin.js} +3 -2
- package/dist/{1~src_plugins_output_plugin_ts.js → 1~output.plugin.js} +14 -3
- package/dist/1~plugins.js +40 -0
- package/dist/{1~src_cli_preview_ts.js → 1~preview.js} +5 -5
- package/dist/{1~src_plugins_rsdoctor_plugin_ts.js → 1~rsdoctor.plugin.js} +2 -2
- package/dist/{0~src_plugins_sourcemap_plugin_ts.js → 1~sourcemap.plugin.js} +19 -2
- package/dist/1~src_cli_init_ts-src_create-rspeedy_ts.js +43 -29
- package/dist/1~statsJson.plugin.js +26 -0
- package/dist/1~swc.plugin.js +25 -0
- package/dist/{1~src_plugins_target_plugin_ts.js → 1~target.plugin.js} +4 -4
- package/dist/{0~src_config_validate_ts.js → 1~validate.js} +17963 -28527
- package/dist/{1~src_cli_watch_ts.js → 1~watch.js} +1 -3
- package/dist/cli/main.js +1 -1
- package/dist/index.d.ts +94 -17
- package/dist/{src_cli_main_ts.js → src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js} +127 -30
- package/dist/src_index_ts.js +132 -19
- package/package.json +18 -17
- package/dist/0~src_plugins_index_ts.js +0 -64
- package/dist/0~src_plugins_swc_plugin_ts.js +0 -21
- package/dist/0~src_utils_getESVersionTarget_ts.js +0 -4
- package/dist/1~node_fs.js +0 -7
- package/dist/1~node_path.js +0 -7
- package/dist/1~src_plugins_index_ts.js +0 -64
- package/dist/1~src_plugins_swc_plugin_ts.js +0 -21
- package/dist/1~src_utils_getESVersionTarget_ts.js +0 -4
- package/dist/rslib-runtime.js +0 -75
- /package/dist/{0~src_plugins_chunkLoading_plugin_ts.js → 0~chunkLoading.plugin.js} +0 -0
- /package/dist/{0~src_config_output_dist-path_ts.js → 0~dist-path.js} +0 -0
- /package/dist/{0~src_plugins_emitOnErrors_plugin_ts.js → 0~emitOnErrors.plugin.js} +0 -0
- /package/dist/{0~src_plugins_minify_plugin_ts.js → 0~minify.plugin.js} +0 -0
- /package/dist/{0~src_plugins_resolve_plugin_ts.js → 0~resolve.plugin.js} +0 -0
- /package/dist/{1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt → 1~chokidar.js.LICENSE.txt} +0 -0
- /package/dist/{1~src_plugins_chunkLoading_plugin_ts.js → 1~chunkLoading.plugin.js} +0 -0
- /package/dist/{1~src_config_output_dist-path_ts.js → 1~dist-path.js} +0 -0
- /package/dist/{1~src_plugins_emitOnErrors_plugin_ts.js → 1~emitOnErrors.plugin.js} +0 -0
- /package/dist/{1~src_utils_is-ci_ts.js → 1~is-ci.js} +0 -0
- /package/dist/{1~src_plugins_resolve_plugin_ts.js → 1~resolve.plugin.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,128 @@
|
|
|
1
1
|
# @lynx-js/rspeedy
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add unified `debug-metadata.json` per Lynx entry. ([#2642](https://github.com/lynx-family/lynx-stack/pull/2642))
|
|
8
|
+
|
|
9
|
+
- New `@lynx-js/debug-metadata` schema package (zero-dep).
|
|
10
|
+
- New `@lynx-js/debug-metadata-rsbuild-plugin` emits the file and serves `?field=…` queries in dev.
|
|
11
|
+
- JS `//# sourceMappingURL=` and tasm `templateDebugUrl` repointed at the new endpoint.
|
|
12
|
+
- `debug-info.json` no longer written to disk.
|
|
13
|
+
- Auto-registered by Rspeedy — zero user config.
|
|
14
|
+
|
|
15
|
+
- Lower `let`/`const` to `var` in the build output for faster QuickJS parsing. The SWC `transform-block-scoping` pass is added to both the background and main-thread layers (on top of the existing target baseline), and rspack `output.environment.const` is set to `false` so bundler-generated runtime code also uses `var`. ([#2755](https://github.com/lynx-family/lynx-stack/pull/2755))
|
|
16
|
+
|
|
17
|
+
- Default `output.sourceMap.js` to `source-map` for `lynx` environments in production when the project leaves it unset. The production default was previously `false` (no JS source map), which left the emitted `debug-metadata.json` without source maps and made reverse-resolution of production errors impossible without manual config. Non-`lynx` environments (e.g. `web`) are unchanged, and any explicit `output.sourceMap` is respected. ([#2642](https://github.com/lynx-family/lynx-stack/pull/2642))
|
|
18
|
+
|
|
19
|
+
- refactor: set target to es2017 by default ([#2783](https://github.com/lynx-family/lynx-stack/pull/2783))
|
|
20
|
+
|
|
21
|
+
- Support a function form for `output.filename.bundle`. ([#2701](https://github.com/lynx-family/lynx-stack/pull/2701))
|
|
22
|
+
|
|
23
|
+
`output.filename.bundle` now accepts a function `(context: { lazyBundle: boolean; entryName?: string; platform: string }) => string` in addition to a string. The function is called once for the main bundle (`lazyBundle: false`) and once for the lazy bundles (`lazyBundle: true`), so a single config can control both the main bundle filename and the lazy bundle filename — without a dedicated `lazyBundle` field or a custom plugin.
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { execSync } from 'node:child_process'
|
|
27
|
+
|
|
28
|
+
import { defineConfig } from '@lynx-js/rspeedy'
|
|
29
|
+
|
|
30
|
+
const gitHash = execSync('git rev-parse --short HEAD').toString().trim()
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
output: {
|
|
34
|
+
filename: {
|
|
35
|
+
bundle: ({ lazyBundle, platform }) =>
|
|
36
|
+
lazyBundle
|
|
37
|
+
? `my-lazy-bundles/[name].[fullhash]-${gitHash}.bundle`
|
|
38
|
+
: `[name].${platform}.bundle`,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- **BREAKING CHANGE** ([#2603](https://github.com/lynx-family/lynx-stack/pull/2603))
|
|
45
|
+
|
|
46
|
+
[Rsbuild v2](https://rsbuild.rs/guide/upgrade/v1-to-v2) deprecated `performance.chunkSplit`, so configure chunk splitting with Rspeedy's top-level `splitChunks` option instead. Rspeedy still accepts the old `performance.chunkSplit` shape as a deprecated compatibility path, but new configs should migrate:
|
|
47
|
+
|
|
48
|
+
```diff
|
|
49
|
+
import { defineConfig } from '@lynx-js/rspeedy';
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
- performance: {
|
|
53
|
+
- chunkSplit: {
|
|
54
|
+
- strategy: 'single-vendor',
|
|
55
|
+
- },
|
|
56
|
+
- },
|
|
57
|
+
+ splitChunks: {
|
|
58
|
+
+ preset: 'single-vendor',
|
|
59
|
+
+ },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Move aliases from `source.alias` to `resolve.alias`:
|
|
64
|
+
|
|
65
|
+
```diff
|
|
66
|
+
import { defineConfig } from '@lynx-js/rspeedy';
|
|
67
|
+
|
|
68
|
+
export default defineConfig({
|
|
69
|
+
- source: {
|
|
70
|
+
- alias: {
|
|
71
|
+
- '@': './src',
|
|
72
|
+
- },
|
|
73
|
+
- },
|
|
74
|
+
+ resolve: {
|
|
75
|
+
+ alias: {
|
|
76
|
+
+ '@': './src',
|
|
77
|
+
+ },
|
|
78
|
+
+ },
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The bundled Rspack/Rsbuild toolchain is updated to `@rspack/core` 2.0.6, `@rspack/cli` 2.0.6, `@rspack/dev-server` 2.0.3, and `@rsbuild/core` 2.0.11.
|
|
83
|
+
|
|
84
|
+
- Align Rspeedy, the QRCode plugin, and the Lynx bundle Rslib config Node.js engine metadata with Rsbuild v2 and Rslib requirements: Node.js 20.19+ or 22.12+. ([#2789](https://github.com/lynx-family/lynx-stack/pull/2789))
|
|
85
|
+
|
|
86
|
+
- In Lynx environments, all `.map` assets are removed before emit. ([#2804](https://github.com/lynx-family/lynx-stack/pull/2804))
|
|
87
|
+
|
|
88
|
+
- Express the SWC compilation baseline through `env` (a high `targets` plus an explicit `include` transform list) instead of `jsc.target`. The emitted build output is unchanged for existing projects. ([#2748](https://github.com/lynx-family/lynx-stack/pull/2748))
|
|
89
|
+
|
|
90
|
+
Because `env` and `jsc.target` are mutually exclusive in SWC, `tools.swc.jsc.target` is no longer accepted and now throws a clear error. To downlevel specific syntax, add the corresponding transforms to `tools.swc.env.include` instead — they extend the base/background baseline (the main thread keeps its fixed es2019 baseline, matching the previous `jsc.target` behavior).
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Update the `tools.cssExtract` documentation example to use `CssExtractRspackPlugin` instead of the removed `CssExtractWebpackPlugin`. ([#2838](https://github.com/lynx-family/lynx-stack/pull/2838))
|
|
95
|
+
|
|
96
|
+
- Updated dependencies [[`a839d59`](https://github.com/lynx-family/lynx-stack/commit/a839d59b7f477a86f2cd10215d0b754264e54425), [`409594b`](https://github.com/lynx-family/lynx-stack/commit/409594b9c51bb0c13f01c7d3f16949b27ebfdced), [`e16f86c`](https://github.com/lynx-family/lynx-stack/commit/e16f86cfc6666dca3ede655e5e22b3d76dd17bf6), [`e0aa6a3`](https://github.com/lynx-family/lynx-stack/commit/e0aa6a3f4fc8ba848a3a41789b3775a46fea24dc), [`d08154d`](https://github.com/lynx-family/lynx-stack/commit/d08154dbb2fb34bdf69678b328c1c75cfc100326), [`409594b`](https://github.com/lynx-family/lynx-stack/commit/409594b9c51bb0c13f01c7d3f16949b27ebfdced), [`445c6c7`](https://github.com/lynx-family/lynx-stack/commit/445c6c77c227bb30ae4a92f8385518cf8b4b8bc2)]:
|
|
97
|
+
- @lynx-js/debug-metadata-rsbuild-plugin@0.1.0
|
|
98
|
+
- @lynx-js/cache-events-webpack-plugin@0.1.0
|
|
99
|
+
- @lynx-js/chunk-loading-webpack-plugin@0.4.0
|
|
100
|
+
- @lynx-js/webpack-dev-transport@0.3.0
|
|
101
|
+
- @lynx-js/web-rsbuild-server-middleware@0.21.1
|
|
102
|
+
|
|
103
|
+
## 0.14.5
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- Respect custom SWC target configuration in `lynx.config.js`, such as: ([#2654](https://github.com/lynx-family/lynx-stack/pull/2654))
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import { defineConfig } from '@lynx-js/rspeedy'
|
|
111
|
+
|
|
112
|
+
export default defineConfig({
|
|
113
|
+
tools: {
|
|
114
|
+
swc: {
|
|
115
|
+
jsc: {
|
|
116
|
+
target: 'es5',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- Updated dependencies []:
|
|
124
|
+
- @lynx-js/web-rsbuild-server-middleware@0.21.0
|
|
125
|
+
|
|
3
126
|
## 0.14.4
|
|
4
127
|
|
|
5
128
|
### Patch Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger } from "@rsbuild/core";
|
|
2
|
+
import { debug, version as version_version } from "./src_index_ts.js";
|
|
2
3
|
const sAPI = Symbol.for('rspeedy.api');
|
|
3
4
|
function pluginAPI(config) {
|
|
4
5
|
return {
|
|
@@ -8,9 +9,7 @@ function pluginAPI(config) {
|
|
|
8
9
|
config,
|
|
9
10
|
debug: debug,
|
|
10
11
|
async exit (code) {
|
|
11
|
-
const { exit } = await import("./0~
|
|
12
|
-
exit: mod.exit_exit
|
|
13
|
-
}));
|
|
12
|
+
const { exit } = await import("./0~exit.js");
|
|
14
13
|
return exit(code);
|
|
15
14
|
},
|
|
16
15
|
logger: logger,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
1
|
import { createRequire } from "node:module";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { logger } from "@rsbuild/core";
|
|
4
|
+
import { __webpack_require__ } from "./src_index_ts.js";
|
|
5
|
+
import { debug } from "./src_index_ts.js";
|
|
6
|
+
import { isLynx } from "./0~is-lynx.js";
|
|
8
7
|
class ProvidePlugin_ProvidePlugin {
|
|
9
8
|
definitions;
|
|
10
9
|
constructor(definitions){
|
|
@@ -72,8 +71,15 @@ function pluginDev(options, server) {
|
|
|
72
71
|
const rspeedyAPIs = api.useExposed(Symbol.for('rspeedy.api'));
|
|
73
72
|
const defaultFilename = '[name].[platform].bundle';
|
|
74
73
|
const { filename } = rspeedyAPIs.config.output ?? {};
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const bundle = 'object' == typeof filename ? filename.bundle ?? filename.template : filename;
|
|
75
|
+
const resolveName = (entry, platform)=>{
|
|
76
|
+
const resolved = 'function' == typeof bundle ? bundle({
|
|
77
|
+
lazyBundle: false,
|
|
78
|
+
entryName: entry,
|
|
79
|
+
platform
|
|
80
|
+
}) : bundle ?? defaultFilename;
|
|
81
|
+
return resolved.replaceAll('[name]', entry).replaceAll('[platform]', platform);
|
|
82
|
+
};
|
|
77
83
|
if (config.server?.printUrls === void 0 || config.server?.printUrls === true) {
|
|
78
84
|
const environmentNames = Object.keys(config.environments ?? {});
|
|
79
85
|
return mergeRsbuildConfig(config, {
|
|
@@ -82,7 +88,7 @@ function pluginDev(options, server) {
|
|
|
82
88
|
const finalUrls = [];
|
|
83
89
|
const baseForUrls = ('string' == typeof assetPrefix ? assetPrefix : `http://${hostname}:<port>/`).replaceAll('<port>', String(param.port));
|
|
84
90
|
for (const entry of Object.keys(config.source?.entry ?? {}))for (const environmentName of environmentNames){
|
|
85
|
-
const pathname =
|
|
91
|
+
const pathname = resolveName(entry, environmentName);
|
|
86
92
|
finalUrls.push({
|
|
87
93
|
label: environmentName,
|
|
88
94
|
url: new URL(pathname, baseForUrls).toString()
|
|
@@ -122,11 +128,11 @@ function pluginDev(options, server) {
|
|
|
122
128
|
paths: [
|
|
123
129
|
rsbuildPath
|
|
124
130
|
]
|
|
125
|
-
})).set('webpack/hot/emitter.js', require.resolve('@rspack/core/hot/emitter', {
|
|
131
|
+
})).set('@lynx-js/webpack-dev-transport/client', `${require.resolve('@lynx-js/webpack-dev-transport/client')}?${searchParams.toString()}`).set('@rspack/core/hot/emitter.js', require.resolve('@rspack/core/hot/emitter.js', {
|
|
126
132
|
paths: [
|
|
127
133
|
rsbuildPath
|
|
128
134
|
]
|
|
129
|
-
})).set('@
|
|
135
|
+
})).set('@rspack/core/hot/dev-server', require.resolve('@rspack/core/hot/dev-server', {
|
|
130
136
|
paths: [
|
|
131
137
|
rsbuildPath
|
|
132
138
|
]
|
|
@@ -155,8 +161,8 @@ function pluginDev(options, server) {
|
|
|
155
161
|
};
|
|
156
162
|
}
|
|
157
163
|
async function findIp(family, isInternal = false) {
|
|
158
|
-
const [{ default: ipaddr }, os] = await Promise.all([
|
|
159
|
-
import("./0~
|
|
164
|
+
const [{ default: ipaddr }, { default: os }] = await Promise.all([
|
|
165
|
+
import("./0~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)),
|
|
160
166
|
import("node:os")
|
|
161
167
|
]);
|
|
162
168
|
let host;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./
|
|
1
|
+
import { __webpack_require__ } from "./src_index_ts.js";
|
|
2
|
+
import { logger } from "@rsbuild/core";
|
|
2
3
|
import node_process from "node:process";
|
|
3
|
-
import { debug
|
|
4
|
+
import { debug } from "./src_index_ts.js";
|
|
4
5
|
const asyncCallbacks = new Set();
|
|
5
6
|
const callbacks = new Set();
|
|
6
7
|
let isCalled = false;
|
|
@@ -99,4 +100,4 @@ async function exit_onExit(signal) {
|
|
|
99
100
|
debug(`awaiting exit promises(length: ${exitPromises.length})...`);
|
|
100
101
|
await Promise.allSettled(exitPromises);
|
|
101
102
|
}
|
|
102
|
-
export { exit_exit };
|
|
103
|
+
export { exit_exit as exit };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function getESVersionTarget() {
|
|
2
|
+
return 'es2017';
|
|
3
|
+
}
|
|
4
|
+
const ES2019_INCLUDE = [
|
|
5
|
+
'transform-nullish-coalescing-operator',
|
|
6
|
+
'transform-optional-chaining',
|
|
7
|
+
'transform-export-namespace-from',
|
|
8
|
+
'transform-logical-assignment-operators',
|
|
9
|
+
'transform-numeric-separator',
|
|
10
|
+
'transform-class-properties',
|
|
11
|
+
'transform-class-static-block',
|
|
12
|
+
'transform-private-methods',
|
|
13
|
+
'transform-private-property-in-object'
|
|
14
|
+
];
|
|
15
|
+
const ES2017_INCLUDE = [
|
|
16
|
+
'transform-async-generator-functions',
|
|
17
|
+
'transform-dotall-regex',
|
|
18
|
+
'transform-named-capturing-groups-regex',
|
|
19
|
+
'transform-object-rest-spread',
|
|
20
|
+
'transform-unicode-property-regex',
|
|
21
|
+
'transform-json-strings',
|
|
22
|
+
'transform-optional-catch-binding',
|
|
23
|
+
...ES2019_INCLUDE
|
|
24
|
+
];
|
|
25
|
+
function getESVersionEnvInclude() {
|
|
26
|
+
return [
|
|
27
|
+
...ES2017_INCLUDE
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
const ES_ENV_TARGETS = {
|
|
31
|
+
chrome: '120'
|
|
32
|
+
};
|
|
33
|
+
export { ES_ENV_TARGETS, getESVersionEnvInclude, getESVersionTarget };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
1
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import node_path, { dirname } from "node:path";
|
|
3
|
+
import { logger } from "@rsbuild/core";
|
|
4
|
+
import { __webpack_require__ } from "./src_index_ts.js";
|
|
5
|
+
import { debug } from "./src_index_ts.js";
|
|
6
|
+
import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./0~dist-path.js";
|
|
5
7
|
__webpack_require__.add({
|
|
6
8
|
"../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js" (__unused_rspack_module, exports) {
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
9
|
exports.arrayToString = void 0;
|
|
11
10
|
const arrayToString = (array, space, next)=>{
|
|
12
11
|
const values = array.map(function(value, index) {
|
|
@@ -20,10 +19,7 @@ __webpack_require__.add({
|
|
|
20
19
|
exports.arrayToString = arrayToString;
|
|
21
20
|
},
|
|
22
21
|
"../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
23
|
-
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
exports.FunctionParser = exports.dedentFunction = exports.functionToString = exports.USED_METHOD_KEY = void 0;
|
|
22
|
+
exports.functionToString = exports.USED_METHOD_KEY = void 0;
|
|
27
23
|
const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
|
|
28
24
|
const METHOD_NAMES_ARE_QUOTED = '"' === ({
|
|
29
25
|
" " () {}
|
|
@@ -59,7 +55,6 @@ __webpack_require__.add({
|
|
|
59
55
|
}
|
|
60
56
|
return found ? fnString.split(`\n${found}`).join("\n") : fnString;
|
|
61
57
|
}
|
|
62
|
-
exports.dedentFunction = dedentFunction;
|
|
63
58
|
class FunctionParser {
|
|
64
59
|
constructor(fn, indent, next, key){
|
|
65
60
|
this.fn = fn;
|
|
@@ -210,10 +205,9 @@ __webpack_require__.add({
|
|
|
210
205
|
this.consumeMatch(/^(?:\s|\/\/.*|\/\*[^]*?\*\/)*/);
|
|
211
206
|
}
|
|
212
207
|
}
|
|
213
|
-
exports.FunctionParser = FunctionParser;
|
|
214
208
|
},
|
|
215
209
|
"../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
216
|
-
exports.
|
|
210
|
+
exports.A = void 0;
|
|
217
211
|
const stringify_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js");
|
|
218
212
|
const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
|
|
219
213
|
const ROOT_SENTINEL = Symbol("root");
|
|
@@ -266,23 +260,20 @@ __webpack_require__.add({
|
|
|
266
260
|
}
|
|
267
261
|
return result;
|
|
268
262
|
}
|
|
269
|
-
exports.
|
|
263
|
+
exports.A = stringify;
|
|
270
264
|
function replacerToString(replacer) {
|
|
271
265
|
if (!replacer) return stringify_1.toString;
|
|
272
266
|
return (value, space, next, key)=>replacer(value, space, (value)=>stringify_1.toString(value, space, next, key), key);
|
|
273
267
|
}
|
|
274
268
|
},
|
|
275
269
|
"../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
276
|
-
Object.defineProperty(exports, "__esModule", {
|
|
277
|
-
value: true
|
|
278
|
-
});
|
|
279
270
|
exports.objectToString = void 0;
|
|
280
271
|
const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
|
|
281
272
|
const function_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js");
|
|
282
273
|
const array_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js");
|
|
283
274
|
const objectToString = (value, space, next, key)=>{
|
|
284
275
|
if ("function" == typeof Buffer && Buffer.isBuffer(value)) return `Buffer.from(${next(value.toString("base64"))}, 'base64')`;
|
|
285
|
-
if ("object" == typeof global && value === global) return globalToString(value, space, next
|
|
276
|
+
if ("object" == typeof global && value === global) return globalToString(value, space, next);
|
|
286
277
|
const toString = OBJECT_TYPES[Object.prototype.toString.call(value)];
|
|
287
278
|
return toString ? toString(value, space, next, key) : void 0;
|
|
288
279
|
};
|
|
@@ -322,10 +313,7 @@ __webpack_require__.add({
|
|
|
322
313
|
};
|
|
323
314
|
},
|
|
324
315
|
"../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js" (__unused_rspack_module, exports) {
|
|
325
|
-
|
|
326
|
-
value: true
|
|
327
|
-
});
|
|
328
|
-
exports.stringifyPath = exports.quoteKey = exports.isValidVariableName = exports.IS_VALID_IDENTIFIER = exports.quoteString = void 0;
|
|
316
|
+
exports.stringifyPath = exports.quoteKey = exports.isValidVariableName = exports.W = exports.quoteString = void 0;
|
|
329
317
|
const ESCAPABLE = /[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
|
330
318
|
const META_CHARS = new Map([
|
|
331
319
|
[
|
|
@@ -369,9 +357,9 @@ __webpack_require__.add({
|
|
|
369
357
|
}
|
|
370
358
|
exports.quoteString = quoteString;
|
|
371
359
|
const RESERVED_WORDS = new Set("break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield".split(" "));
|
|
372
|
-
exports.
|
|
360
|
+
exports.W = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
373
361
|
function isValidVariableName(name) {
|
|
374
|
-
return "string" == typeof name && !RESERVED_WORDS.has(name) && exports.
|
|
362
|
+
return "string" == typeof name && !RESERVED_WORDS.has(name) && exports.W.test(name);
|
|
375
363
|
}
|
|
376
364
|
exports.isValidVariableName = isValidVariableName;
|
|
377
365
|
function quoteKey(key, next) {
|
|
@@ -387,9 +375,6 @@ __webpack_require__.add({
|
|
|
387
375
|
exports.stringifyPath = stringifyPath;
|
|
388
376
|
},
|
|
389
377
|
"../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
390
|
-
Object.defineProperty(exports, "__esModule", {
|
|
391
|
-
value: true
|
|
392
|
-
});
|
|
393
378
|
exports.toString = void 0;
|
|
394
379
|
const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
|
|
395
380
|
const object_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js");
|
|
@@ -429,7 +414,7 @@ function pluginInspect(config) {
|
|
|
429
414
|
};
|
|
430
415
|
}
|
|
431
416
|
async function inspectRspeedyConfig(config, path, verbose) {
|
|
432
|
-
const stringifiedConfig = (0, dist.
|
|
417
|
+
const stringifiedConfig = (0, dist.A)(config, (value, _, stringify)=>{
|
|
433
418
|
if ('function' == typeof value && !verbose && value.toString().length > 100) return "function () { /* omitted long function */ }";
|
|
434
419
|
return stringify(value);
|
|
435
420
|
}, 2);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./
|
|
1
|
+
import { __webpack_require__ } from "./src_index_ts.js";
|
|
2
2
|
__webpack_require__.add({
|
|
3
3
|
"../../../node_modules/.pnpm/ipaddr.js@2.3.0/node_modules/ipaddr.js/lib/ipaddr.js" (module) {
|
|
4
4
|
(function(root) {
|
|
@@ -1068,3 +1068,4 @@ __webpack_require__.add({
|
|
|
1068
1068
|
})(this);
|
|
1069
1069
|
}
|
|
1070
1070
|
});
|
|
1071
|
+
__webpack_require__("../../../node_modules/.pnpm/ipaddr.js@2.3.0/node_modules/ipaddr.js/lib/ipaddr.js");
|
|
@@ -3,8 +3,9 @@ function pluginOptimization() {
|
|
|
3
3
|
name: 'lynx:rsbuild:optimization',
|
|
4
4
|
setup (api) {
|
|
5
5
|
api.modifyBundlerChain((chain, { CHAIN_ID, isProd })=>{
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const jsRule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
7
|
+
const jsMainRule = jsRule.oneOf(CHAIN_ID.ONE_OF.JS_MAIN);
|
|
8
|
+
chain.module.rule('js-override-strict').type(jsMainRule.get('type')).test(jsRule.get('test')).parser({
|
|
8
9
|
overrideStrict: 'strict'
|
|
9
10
|
}).end();
|
|
10
11
|
if (isProd) chain.optimization.avoidEntryIife(true);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./0~
|
|
1
|
+
import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./0~dist-path.js";
|
|
2
2
|
const defaultFilenameOptions = Object.freeze({
|
|
3
3
|
css: '[name]/[name].css'
|
|
4
4
|
});
|
|
@@ -10,14 +10,25 @@ function pluginOutput(options) {
|
|
|
10
10
|
name: 'lynx:rsbuild:output',
|
|
11
11
|
setup (api) {
|
|
12
12
|
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
13
|
-
|
|
13
|
+
const lowerToVar = {
|
|
14
|
+
tools: {
|
|
15
|
+
rspack: {
|
|
16
|
+
output: {
|
|
17
|
+
environment: {
|
|
18
|
+
const: false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
if (!options) return mergeRsbuildConfig(lowerToVar, {
|
|
14
25
|
output: {
|
|
15
26
|
filename: {
|
|
16
27
|
css: defaultFilenameOptions.css
|
|
17
28
|
}
|
|
18
29
|
}
|
|
19
30
|
}, config);
|
|
20
|
-
return mergeRsbuildConfig(config, {
|
|
31
|
+
return mergeRsbuildConfig(lowerToVar, config, {
|
|
21
32
|
output: {
|
|
22
33
|
distPath: Object.assign({}, defaultDistPathOptions, options.distPath),
|
|
23
34
|
filename: Object.assign({}, defaultFilenameOptions, options.filename)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { debug, isDebug } from "./src_index_ts.js";
|
|
2
|
+
async function applyDebugPlugins(rsbuildInstance, config) {
|
|
3
|
+
const debugPlugins = Object.freeze([
|
|
4
|
+
import("./0~emitOnErrors.plugin.js").then(({ pluginEmitOnErrors })=>pluginEmitOnErrors()),
|
|
5
|
+
import("./0~inspect.plugin.js").then(({ pluginInspect })=>pluginInspect(config))
|
|
6
|
+
]);
|
|
7
|
+
rsbuildInstance.addPlugins(await Promise.all(debugPlugins));
|
|
8
|
+
}
|
|
9
|
+
async function applyDefaultPlugins(rsbuildInstance, config) {
|
|
10
|
+
const defaultPlugins = Object.freeze([
|
|
11
|
+
import("./0~api.plugin.js").then(({ pluginAPI })=>pluginAPI(config)),
|
|
12
|
+
import("./0~chunkLoading.plugin.js").then(({ pluginChunkLoading })=>pluginChunkLoading()),
|
|
13
|
+
import("@lynx-js/debug-metadata-rsbuild-plugin").then(({ pluginLynxDebugMetadata })=>pluginLynxDebugMetadata()),
|
|
14
|
+
import("./0~dev.plugin.js").then(({ pluginDev })=>pluginDev(config.dev, config.server)),
|
|
15
|
+
import("./0~minify.plugin.js").then(({ pluginMinify })=>pluginMinify(config.output?.minify)),
|
|
16
|
+
import("./0~optimization.plugin.js").then(({ pluginOptimization })=>pluginOptimization()),
|
|
17
|
+
import("./0~output.plugin.js").then(({ pluginOutput })=>pluginOutput(config.output)),
|
|
18
|
+
import("./0~resolve.plugin.js").then(({ pluginResolve })=>pluginResolve()),
|
|
19
|
+
import("./0~rsdoctor.plugin.js").then(({ pluginRsdoctor })=>pluginRsdoctor(config.tools?.rsdoctor)),
|
|
20
|
+
import("./0~sourcemap.plugin.js").then(({ pluginSourcemap })=>pluginSourcemap()),
|
|
21
|
+
import("./0~statsJson.plugin.js").then(({ pluginStatsJson })=>pluginStatsJson(config)),
|
|
22
|
+
import("./0~swc.plugin.js").then(({ pluginSwc })=>pluginSwc()),
|
|
23
|
+
import("./0~target.plugin.js").then(({ pluginTarget })=>pluginTarget())
|
|
24
|
+
]);
|
|
25
|
+
const promises = [
|
|
26
|
+
Promise.all(defaultPlugins).then((plugins)=>{
|
|
27
|
+
rsbuildInstance.addPlugins(plugins);
|
|
28
|
+
})
|
|
29
|
+
];
|
|
30
|
+
if (isDebug()) {
|
|
31
|
+
debug('apply Rspeedy default debug plugins');
|
|
32
|
+
promises.push(applyDebugPlugins(rsbuildInstance, config));
|
|
33
|
+
}
|
|
34
|
+
await Promise.all(promises);
|
|
35
|
+
const { pluginCssMinimizer, PLUGIN_CSS_MINIMIZER_NAME } = await import("@rsbuild/plugin-css-minimizer");
|
|
36
|
+
if (!rsbuildInstance.isPluginExists(PLUGIN_CSS_MINIMIZER_NAME)) rsbuildInstance.addPlugins([
|
|
37
|
+
pluginCssMinimizer()
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
export { applyDefaultPlugins };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isLynx } from "./0~is-lynx.js";
|
|
1
2
|
var isProduction = 'production' === process.env.NODE_ENV;
|
|
2
3
|
var prefix = 'Invariant failed';
|
|
3
4
|
function invariant(condition, message) {
|
|
@@ -34,12 +35,13 @@ function pluginSourcemap() {
|
|
|
34
35
|
'lynx:rsbuild:dev'
|
|
35
36
|
],
|
|
36
37
|
setup (api) {
|
|
37
|
-
api.modifyBundlerChain((chain, { isDev })=>{
|
|
38
|
+
api.modifyBundlerChain((chain, { isDev, environment })=>{
|
|
38
39
|
const { dev, output, server } = api.getRsbuildConfig('current');
|
|
39
40
|
const publicPath = isDev ? dev?.assetPrefix : output?.assetPrefix;
|
|
40
41
|
if (false === publicPath) return;
|
|
41
42
|
invariant('string' == typeof publicPath || void 0 === publicPath, `dev.assetPrefix should be normalized to string, got ${dev?.assetPrefix}`);
|
|
42
43
|
applySourceMapPlugin(chain, getDevtoolFromSourceMap(), publicPath?.replaceAll('<port>', String(api.context.devServer?.port ?? server?.port)));
|
|
44
|
+
if (isLynx(environment)) applyDropSourceMapAssets(chain);
|
|
43
45
|
function getDevtoolFromSourceMap() {
|
|
44
46
|
const DEFAULT_DEV_DEVTOOL = 'cheap-module-source-map';
|
|
45
47
|
switch(typeof output?.sourceMap){
|
|
@@ -48,13 +50,28 @@ function pluginSourcemap() {
|
|
|
48
50
|
return false;
|
|
49
51
|
case 'undefined':
|
|
50
52
|
case 'object':
|
|
51
|
-
return output?.sourceMap?.js ?? (isDev ? DEFAULT_DEV_DEVTOOL : false);
|
|
53
|
+
return output?.sourceMap?.js ?? (isDev ? DEFAULT_DEV_DEVTOOL : isLynx(environment) ? 'source-map' : false);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
};
|
|
57
59
|
}
|
|
60
|
+
function applyDropSourceMapAssets(chain) {
|
|
61
|
+
chain.plugin('lynx:sourcemap-drop').use(class {
|
|
62
|
+
apply(compiler) {
|
|
63
|
+
const { Compilation } = compiler.webpack;
|
|
64
|
+
compiler.hooks.compilation.tap('LynxDropSourceMapAssetsPlugin', (compilation)=>{
|
|
65
|
+
compilation.hooks.processAssets.tap({
|
|
66
|
+
name: 'LynxDropSourceMapAssetsPlugin',
|
|
67
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT + 1
|
|
68
|
+
}, ()=>{
|
|
69
|
+
for (const name of Object.keys(compilation.assets))if (name.endsWith('.map')) compilation.deleteAsset(name);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, []);
|
|
74
|
+
}
|
|
58
75
|
function applySourceMapPlugin(chain, devtool, publicPath) {
|
|
59
76
|
if (false === devtool) return;
|
|
60
77
|
const CHAIN_ID_DEV_SOURCEMAP = 'lynx:sourcemap';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
const BUNDLE_STATS_JSON_OPTIONS = {
|
|
4
|
+
assets: true,
|
|
5
|
+
chunks: true,
|
|
6
|
+
modules: true,
|
|
7
|
+
entrypoints: true,
|
|
8
|
+
chunkGroups: true
|
|
9
|
+
};
|
|
10
|
+
function pluginStatsJson(config) {
|
|
11
|
+
return {
|
|
12
|
+
name: 'lynx:stats-json',
|
|
13
|
+
setup (api) {
|
|
14
|
+
if (!config.performance?.profile) return;
|
|
15
|
+
api.onAfterBuild(async ({ stats })=>{
|
|
16
|
+
if (!stats) return;
|
|
17
|
+
const statsPath = node_path.join(api.context.distPath, 'stats.json');
|
|
18
|
+
await mkdir(node_path.dirname(statsPath), {
|
|
19
|
+
recursive: true
|
|
20
|
+
});
|
|
21
|
+
await writeFile(statsPath, JSON.stringify(stats.toJson(BUNDLE_STATS_JSON_OPTIONS), null, 2));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { pluginStatsJson };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ES_ENV_TARGETS, getESVersionEnvInclude } from "./0~getESVersionTarget.js";
|
|
2
|
+
function pluginSwc() {
|
|
3
|
+
return {
|
|
4
|
+
name: 'lynx:rsbuild:swc',
|
|
5
|
+
setup (api) {
|
|
6
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
|
|
7
|
+
tools: {
|
|
8
|
+
swc (config) {
|
|
9
|
+
if (config.jsc?.target !== void 0) throw new Error(`Rspeedy manages the SWC compilation target via \`env\`, which is mutually exclusive with \`jsc.target\`. Remove \`tools.swc.jsc.target\` (received \`${JSON.stringify(config.jsc.target)}\`). To downlevel specific syntax, add the corresponding transforms to \`tools.swc.env.include\` instead (e.g. \`[\'transform-class-properties\']\`).`);
|
|
10
|
+
config.env = {
|
|
11
|
+
...config.env,
|
|
12
|
+
targets: ES_ENV_TARGETS,
|
|
13
|
+
include: [
|
|
14
|
+
'transform-block-scoping',
|
|
15
|
+
...getESVersionEnvInclude(),
|
|
16
|
+
...config.env?.include ?? []
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export { pluginSwc };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getESVersionTarget } from "./0~
|
|
1
|
+
import { getESVersionTarget } from "./0~getESVersionTarget.js";
|
|
2
2
|
function isWeb(environment) {
|
|
3
3
|
const environmentName = 'string' == typeof environment ? environment : environment.name;
|
|
4
4
|
return 'web' === environmentName || environmentName.startsWith('web-');
|
|
@@ -7,13 +7,13 @@ function pluginTarget() {
|
|
|
7
7
|
return {
|
|
8
8
|
name: 'lynx:rsbuild:target',
|
|
9
9
|
setup (api) {
|
|
10
|
-
api.modifyBundlerChain((options, { environment
|
|
10
|
+
api.modifyBundlerChain((options, { environment })=>{
|
|
11
11
|
if (isWeb(environment)) options.target([
|
|
12
|
-
getESVersionTarget(
|
|
12
|
+
getESVersionTarget(),
|
|
13
13
|
'web'
|
|
14
14
|
]);
|
|
15
15
|
else options.target([
|
|
16
|
-
getESVersionTarget(
|
|
16
|
+
getESVersionTarget()
|
|
17
17
|
]);
|
|
18
18
|
});
|
|
19
19
|
}
|