@lynx-js/rspeedy 0.9.3 → 0.9.5
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 +82 -4
- package/dist/index.d.ts +232 -22
- package/dist/index.js +16 -5
- package/dist/src_cli_build_ts.js +77 -45
- package/dist/src_cli_commands_ts.js +4 -4
- package/dist/src_cli_dev_ts.js +79 -52
- package/dist/src_cli_exit_ts.js +1 -1
- package/dist/src_cli_inspect_ts.js +99 -66
- package/dist/src_cli_preview_ts.js +101 -73
- package/dist/src_config_validate_ts.js +2674 -2286
- package/dist/src_plugins_api_plugin_ts.js +1 -1
- package/dist/src_plugins_chunkLoading_plugin_ts.js +1 -1
- package/dist/src_plugins_dev_plugin_ts.js +1 -1
- package/dist/src_plugins_index_ts.js +1 -1
- package/dist/src_plugins_inspect_plugin_ts.js +1 -1
- package/dist/src_plugins_minify_plugin_ts.js +1 -1
- package/dist/src_plugins_optimization_plugin_ts.js +1 -1
- package/dist/src_plugins_output_plugin_ts.js +1 -1
- package/dist/src_plugins_resolve_plugin_ts.js +1 -1
- package/dist/src_plugins_rsdoctor_plugin_ts.js +1 -1
- package/dist/src_plugins_sourcemap_plugin_ts.js +1 -1
- package/dist/src_plugins_stats_plugin_ts.js +2 -5
- package/dist/src_plugins_swc_plugin_ts.js +1 -1
- package/dist/src_plugins_target_plugin_ts.js +1 -1
- package/dist/src_version_ts.js +2 -2
- package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1 -1
- package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1 -1
- package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,83 @@
|
|
|
1
1
|
# @lynx-js/rspeedy
|
|
2
2
|
|
|
3
|
+
## 0.9.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Support `source.preEntry`. ([#750](https://github.com/lynx-family/lynx-stack/pull/750))
|
|
8
|
+
|
|
9
|
+
Add a script before the entry file of each page. This script will be executed before the page code.
|
|
10
|
+
It can be used to execute global logics, such as injecting polyfills, setting global styles, etc.
|
|
11
|
+
|
|
12
|
+
example:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import { defineConfig } from '@lynx-js/rspeedy'
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
source: {
|
|
18
|
+
preEntry: './src/polyfill.ts',
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- Bump Rsbuild v1.3.20 with Rspack v1.3.10. ([#799](https://github.com/lynx-family/lynx-stack/pull/799))
|
|
24
|
+
|
|
25
|
+
- Add `callerName` option to `createRspeedy`. ([#757](https://github.com/lynx-family/lynx-stack/pull/757))
|
|
26
|
+
|
|
27
|
+
It can be accessed by Rsbuild plugins through [`api.context.callerName`](https://rsbuild.dev/api/javascript-api/instance#contextcallername), and execute different logic based on this identifier.
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
export const myPlugin = {
|
|
31
|
+
name: 'my-plugin',
|
|
32
|
+
setup(api) {
|
|
33
|
+
const { callerName } = api.context
|
|
34
|
+
|
|
35
|
+
if (callerName === 'rslib') {
|
|
36
|
+
// ...
|
|
37
|
+
} else if (callerName === 'rspeedy') {
|
|
38
|
+
// ...
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- Support `performance.buildCache`. ([#766](https://github.com/lynx-family/lynx-stack/pull/766))
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`fbc4fbb`](https://github.com/lynx-family/lynx-stack/commit/fbc4fbbdb572ad7128a33dc06e8d8a026d18e388)]:
|
|
47
|
+
- @lynx-js/webpack-dev-transport@0.1.3
|
|
48
|
+
|
|
49
|
+
## 0.9.4
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Bump Rsbuild v1.3.17 with Rspack v1.3.9. ([#708](https://github.com/lynx-family/lynx-stack/pull/708))
|
|
54
|
+
|
|
55
|
+
- Support `performance.profile`. ([#691](https://github.com/lynx-family/lynx-stack/pull/691))
|
|
56
|
+
|
|
57
|
+
- Support CLI flag `--mode` to specify the build mode. ([#723](https://github.com/lynx-family/lynx-stack/pull/723))
|
|
58
|
+
|
|
59
|
+
- Enable native Rsdoctor plugin by default. ([#688](https://github.com/lynx-family/lynx-stack/pull/688))
|
|
60
|
+
|
|
61
|
+
Set `tools.rsdoctor.experiments.enableNativePlugin` to `false` to use the old JS plugin.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import { defineConfig } from '@lynx-js/rspeedy'
|
|
65
|
+
|
|
66
|
+
export default defineConfig({
|
|
67
|
+
tools: {
|
|
68
|
+
rsdoctor: {
|
|
69
|
+
experiments: {
|
|
70
|
+
enableNativePlugin: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
See [Rsdoctor - 1.0](https://rsdoctor.dev/blog/release/release-note-1_0#-faster-analysis) for more details.
|
|
78
|
+
|
|
79
|
+
- Bump Rsbuild v1.3.14 with Rspack v1.3.8. ([#630](https://github.com/lynx-family/lynx-stack/pull/630))
|
|
80
|
+
|
|
3
81
|
## 0.9.3
|
|
4
82
|
|
|
5
83
|
### Patch Changes
|
|
@@ -10,7 +88,7 @@
|
|
|
10
88
|
|
|
11
89
|
### Patch Changes
|
|
12
90
|
|
|
13
|
-
- Support
|
|
91
|
+
- Support CLI option `--no-env` to disable loading of `.env` files ([#483](https://github.com/lynx-family/lynx-stack/pull/483))
|
|
14
92
|
|
|
15
93
|
- Bump Rsbuild v1.3.8 with Rspack v1.3.5. ([#579](https://github.com/lynx-family/lynx-stack/pull/579))
|
|
16
94
|
|
|
@@ -46,9 +124,9 @@
|
|
|
46
124
|
|
|
47
125
|
### Patch Changes
|
|
48
126
|
|
|
49
|
-
- Support
|
|
127
|
+
- Support CLI flag `--base` to specify the base path of the server. ([#387](https://github.com/lynx-family/lynx-stack/pull/387))
|
|
50
128
|
|
|
51
|
-
- Support
|
|
129
|
+
- Support CLI flag `--environment` to specify the name of environment to build ([#462](https://github.com/lynx-family/lynx-stack/pull/462))
|
|
52
130
|
|
|
53
131
|
- Select the most appropriate network interface. ([#457](https://github.com/lynx-family/lynx-stack/pull/457))
|
|
54
132
|
|
|
@@ -58,7 +136,7 @@
|
|
|
58
136
|
|
|
59
137
|
See [Node.js - TypeScript](https://nodejs.org/api/typescript.html) for more details.
|
|
60
138
|
|
|
61
|
-
- Support
|
|
139
|
+
- Support CLI flag `--env-mode` to specify the env mode to load the `.env.[mode]` file. ([#453](https://github.com/lynx-family/lynx-stack/pull/453))
|
|
62
140
|
|
|
63
141
|
- Support `dev.hmr` and `dev.liveReload`. ([#458](https://github.com/lynx-family/lynx-stack/pull/458))
|
|
64
142
|
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,79 @@ import { rspack } from '@rsbuild/core';
|
|
|
31
31
|
import type { ToolsConfig } from '@rsbuild/core';
|
|
32
32
|
import type { WatchFiles } from '@rsbuild/core';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* {@inheritdoc Performance.buildCache}
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare interface BuildCache {
|
|
40
|
+
/**
|
|
41
|
+
* Add additional cache digests, the previous build cache will be invalidated
|
|
42
|
+
* when any value in the array changes.
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue undefined
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
*
|
|
48
|
+
* Add `process.env.SOME_ENV` to the cache digest.
|
|
49
|
+
*
|
|
50
|
+
* ```js
|
|
51
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
52
|
+
*
|
|
53
|
+
* export default defineConfig({
|
|
54
|
+
* performance: {
|
|
55
|
+
* buildCache: {
|
|
56
|
+
* cacheDigest: [process.env.SOME_ENV],
|
|
57
|
+
* },
|
|
58
|
+
* },
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
cacheDigest?: Array<string | undefined> | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* The output directory of the cache files.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue 'node_modules/.cache'
|
|
67
|
+
*/
|
|
68
|
+
cacheDirectory?: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* An array of files containing build dependencies.
|
|
71
|
+
* Rspack will use the hash of each of these files to invalidate the persistent cache.
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
*
|
|
75
|
+
* Rspeedy will use the following configuration files as the default build dependencies:
|
|
76
|
+
*
|
|
77
|
+
* - `package.json`
|
|
78
|
+
*
|
|
79
|
+
* - `tsconfig.json` (or `source.tsconfigPath`)
|
|
80
|
+
*
|
|
81
|
+
* - `.env`, `.env.*`
|
|
82
|
+
*
|
|
83
|
+
* - `tailwindcss.config.*`
|
|
84
|
+
*
|
|
85
|
+
* When using Rspeedy CLI, it will also automatically add
|
|
86
|
+
* `lynx.config.js` to the build dependencies.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* Add `postcss.config.js` to the build dependencies.
|
|
91
|
+
*
|
|
92
|
+
* ```js
|
|
93
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
94
|
+
*
|
|
95
|
+
* export default defineConfig({
|
|
96
|
+
* performance: {
|
|
97
|
+
* buildCache: {
|
|
98
|
+
* buildDependencies: ['postcss.config.js'],
|
|
99
|
+
* },
|
|
100
|
+
* },
|
|
101
|
+
* })
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
buildDependencies?: string[] | undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
34
107
|
/**
|
|
35
108
|
* {@inheritdoc Performance.chunkSplit}
|
|
36
109
|
*
|
|
@@ -417,7 +490,7 @@ export declare type ConsoleType = 'log' | 'warn' | 'error' | 'info' | 'debug' |
|
|
|
417
490
|
*
|
|
418
491
|
* @public
|
|
419
492
|
*/
|
|
420
|
-
export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv, environment }: CreateRspeedyOptions): Promise<RspeedyInstance>;
|
|
493
|
+
export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv, environment, callerName, }: CreateRspeedyOptions): Promise<RspeedyInstance>;
|
|
421
494
|
|
|
422
495
|
/**
|
|
423
496
|
* The options of `createRspeedy` method.
|
|
@@ -448,6 +521,42 @@ export declare interface CreateRspeedyOptions {
|
|
|
448
521
|
* @defaultValue []
|
|
449
522
|
*/
|
|
450
523
|
environment?: CreateRsbuildOptions['environment'];
|
|
524
|
+
/**
|
|
525
|
+
* The name of the framework or tool that is currently invoking Rsbuild.
|
|
526
|
+
* This allows plugins to tailor their behavior based on the calling context.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
*
|
|
530
|
+
* Rsbuild plugins can access this value via `api.context.callerName`.
|
|
531
|
+
*
|
|
532
|
+
* ```js
|
|
533
|
+
* export function myPlugin() {
|
|
534
|
+
* return {
|
|
535
|
+
* name: 'my-plugin',
|
|
536
|
+
* setup(api) {
|
|
537
|
+
* // Log the name of the tool invoking Rsbuild
|
|
538
|
+
* console.log(`Called by: ${api.context.callerName}`);
|
|
539
|
+
*
|
|
540
|
+
* // Conditionally apply plugin logic based on caller
|
|
541
|
+
* if (api.context.callerName === 'rspeedy') {
|
|
542
|
+
* api.modifyRsbuildConfig((config) => {
|
|
543
|
+
* // Apply rspeedy-specific config changes
|
|
544
|
+
* return config;
|
|
545
|
+
* });
|
|
546
|
+
* } else if (api.context.callerName === 'rslib') {
|
|
547
|
+
* api.modifyRsbuildConfig((config) => {
|
|
548
|
+
* // Apply rslib-specific config changes
|
|
549
|
+
* return config;
|
|
550
|
+
* });
|
|
551
|
+
* }
|
|
552
|
+
* }
|
|
553
|
+
* };
|
|
554
|
+
* }
|
|
555
|
+
* ```
|
|
556
|
+
*
|
|
557
|
+
* @defaultValue 'rspeedy'
|
|
558
|
+
*/
|
|
559
|
+
callerName?: string;
|
|
451
560
|
}
|
|
452
561
|
|
|
453
562
|
/**
|
|
@@ -1104,7 +1213,9 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1104
1213
|
* ```js
|
|
1105
1214
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1106
1215
|
* export default defineConfig({
|
|
1107
|
-
*
|
|
1216
|
+
* source: {
|
|
1217
|
+
* entry: './src/pages/main/index.js',
|
|
1218
|
+
* }
|
|
1108
1219
|
* })
|
|
1109
1220
|
* ```
|
|
1110
1221
|
*
|
|
@@ -1115,7 +1226,9 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1115
1226
|
* ```js
|
|
1116
1227
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1117
1228
|
* export default defineConfig({
|
|
1118
|
-
*
|
|
1229
|
+
* source: {
|
|
1230
|
+
* entry: ['./src/prefetch.js', './src/pages/main/index.js'],
|
|
1231
|
+
* }
|
|
1119
1232
|
* })
|
|
1120
1233
|
* ```
|
|
1121
1234
|
*
|
|
@@ -1126,10 +1239,12 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1126
1239
|
* ```js
|
|
1127
1240
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1128
1241
|
* export default defineConfig({
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1242
|
+
* source: {
|
|
1243
|
+
* entry: {
|
|
1244
|
+
* foo: './src/pages/foo/index.js',
|
|
1245
|
+
* bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
|
|
1246
|
+
* }
|
|
1247
|
+
* }
|
|
1133
1248
|
* })
|
|
1134
1249
|
* ```
|
|
1135
1250
|
*
|
|
@@ -1140,12 +1255,14 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1140
1255
|
* ```js
|
|
1141
1256
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1142
1257
|
* export default defineConfig({
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1258
|
+
* source: {
|
|
1259
|
+
* entry: {
|
|
1260
|
+
* foo: './src/pages/foo/index.js',
|
|
1261
|
+
* bar: {
|
|
1262
|
+
* import: ['./src/prefetch.js', './src/pages/bar'],
|
|
1263
|
+
* }
|
|
1264
|
+
* }
|
|
1265
|
+
* }
|
|
1149
1266
|
* })
|
|
1150
1267
|
* ```
|
|
1151
1268
|
* @public
|
|
@@ -1887,10 +2004,73 @@ export declare interface Output {
|
|
|
1887
2004
|
* @public
|
|
1888
2005
|
*/
|
|
1889
2006
|
export declare interface Performance {
|
|
2007
|
+
/**
|
|
2008
|
+
* Enable or configure persistent build cache.
|
|
2009
|
+
*
|
|
2010
|
+
* @beta This feature is experimental and may be changed in the future.
|
|
2011
|
+
*
|
|
2012
|
+
* @example
|
|
2013
|
+
*
|
|
2014
|
+
* Enable persistent build cache.
|
|
2015
|
+
*
|
|
2016
|
+
* ```js
|
|
2017
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2018
|
+
*
|
|
2019
|
+
* export default defineConfig({
|
|
2020
|
+
* performance: {
|
|
2021
|
+
* buildCache: true,
|
|
2022
|
+
* },
|
|
2023
|
+
* })
|
|
2024
|
+
* ```
|
|
2025
|
+
*
|
|
2026
|
+
* @example
|
|
2027
|
+
*
|
|
2028
|
+
* Customize build cache.
|
|
2029
|
+
*
|
|
2030
|
+
* ```js
|
|
2031
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2032
|
+
*
|
|
2033
|
+
* export default defineConfig({
|
|
2034
|
+
* performance: {
|
|
2035
|
+
* buildCache: {
|
|
2036
|
+
* cacheDigest: [process.env.SOME_ENV],
|
|
2037
|
+
* buildDependencies: ['postcss.config.js'],
|
|
2038
|
+
* },
|
|
2039
|
+
* },
|
|
2040
|
+
* })
|
|
2041
|
+
* ```
|
|
2042
|
+
*/
|
|
2043
|
+
buildCache?: BuildCache | boolean | undefined;
|
|
1890
2044
|
/**
|
|
1891
2045
|
* {@link Performance.chunkSplit} is used to configure the chunk splitting strategy.
|
|
1892
2046
|
*/
|
|
1893
2047
|
chunkSplit?: ChunkSplit | ChunkSplitBySize | ChunkSplitCustom | undefined;
|
|
2048
|
+
/**
|
|
2049
|
+
* Whether capture timing information in the build time and the runtime, the same as the {@link https://rspack.dev/config/other-options#profile | profile} config of Rspack.
|
|
2050
|
+
*
|
|
2051
|
+
* @remarks
|
|
2052
|
+
*
|
|
2053
|
+
* This option would be `true` when `DEBUG` environment variable contains `rspeedy`.
|
|
2054
|
+
*
|
|
2055
|
+
* @example
|
|
2056
|
+
*
|
|
2057
|
+
* Enable profile.
|
|
2058
|
+
*
|
|
2059
|
+
* - Rsbuild will auto-generate `dist/stats.json` file through bundle analyzer.
|
|
2060
|
+
*
|
|
2061
|
+
* - Rspack will include the build time information when generating `stats.json`.
|
|
2062
|
+
*
|
|
2063
|
+
* - Frameworks like ReactLynx will include runtime information using `console.profile`.
|
|
2064
|
+
*
|
|
2065
|
+
* ```ts
|
|
2066
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2067
|
+
*
|
|
2068
|
+
* export default defineConfig({
|
|
2069
|
+
* performance: { profile: true },
|
|
2070
|
+
* })
|
|
2071
|
+
* ```
|
|
2072
|
+
*/
|
|
2073
|
+
profile?: boolean | undefined;
|
|
1894
2074
|
/**
|
|
1895
2075
|
* Whether to remove `console.[methodName]` in production build.
|
|
1896
2076
|
*
|
|
@@ -2381,7 +2561,9 @@ export declare interface Source {
|
|
|
2381
2561
|
* ```js
|
|
2382
2562
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2383
2563
|
* export default defineConfig({
|
|
2384
|
-
*
|
|
2564
|
+
* source: {
|
|
2565
|
+
* entry: './src/pages/main/index.js',
|
|
2566
|
+
* },
|
|
2385
2567
|
* })
|
|
2386
2568
|
* ```
|
|
2387
2569
|
*
|
|
@@ -2392,7 +2574,9 @@ export declare interface Source {
|
|
|
2392
2574
|
* ```js
|
|
2393
2575
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2394
2576
|
* export default defineConfig({
|
|
2395
|
-
*
|
|
2577
|
+
* source: {
|
|
2578
|
+
* entry: ['./src/prefetch.js', './src/pages/main/index.js'],
|
|
2579
|
+
* },
|
|
2396
2580
|
* })
|
|
2397
2581
|
* ```
|
|
2398
2582
|
*
|
|
@@ -2403,9 +2587,11 @@ export declare interface Source {
|
|
|
2403
2587
|
* ```js
|
|
2404
2588
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2405
2589
|
* export default defineConfig({
|
|
2406
|
-
*
|
|
2407
|
-
*
|
|
2408
|
-
*
|
|
2590
|
+
* source: {
|
|
2591
|
+
* entry: {
|
|
2592
|
+
* foo: './src/pages/foo/index.js',
|
|
2593
|
+
* bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
|
|
2594
|
+
* },
|
|
2409
2595
|
* },
|
|
2410
2596
|
* })
|
|
2411
2597
|
* ```
|
|
@@ -2417,10 +2603,12 @@ export declare interface Source {
|
|
|
2417
2603
|
* ```js
|
|
2418
2604
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2419
2605
|
* export default defineConfig({
|
|
2420
|
-
*
|
|
2421
|
-
*
|
|
2422
|
-
*
|
|
2423
|
-
*
|
|
2606
|
+
* source: {
|
|
2607
|
+
* entry: {
|
|
2608
|
+
* foo: './src/pages/foo/index.js',
|
|
2609
|
+
* bar: {
|
|
2610
|
+
* import: ['./src/prefetch.js', './src/pages/bar'],
|
|
2611
|
+
* },
|
|
2424
2612
|
* },
|
|
2425
2613
|
* },
|
|
2426
2614
|
* })
|
|
@@ -2563,6 +2751,28 @@ export declare interface Source {
|
|
|
2563
2751
|
* ```
|
|
2564
2752
|
*/
|
|
2565
2753
|
include?: Rspack.RuleSetCondition[] | undefined;
|
|
2754
|
+
/**
|
|
2755
|
+
* Add a script before the entry file of each page. This script will be executed before the page code.
|
|
2756
|
+
* It can be used to execute global logics, such as injecting polyfills, setting global styles, etc.
|
|
2757
|
+
*
|
|
2758
|
+
* @remarks
|
|
2759
|
+
*
|
|
2760
|
+
* See {@link https://rsbuild.dev/config/source/pre-entry | source.preEntry} for more details.
|
|
2761
|
+
*
|
|
2762
|
+
* @example
|
|
2763
|
+
*
|
|
2764
|
+
* Relative path will be resolved relative to the project root directory.
|
|
2765
|
+
*
|
|
2766
|
+
* ```js
|
|
2767
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
2768
|
+
* export default defineConfig({
|
|
2769
|
+
* source: {
|
|
2770
|
+
* preEntry: './src/polyfill.ts',
|
|
2771
|
+
* },
|
|
2772
|
+
* })
|
|
2773
|
+
* ```
|
|
2774
|
+
*/
|
|
2775
|
+
preEntry?: string | string[] | undefined;
|
|
2566
2776
|
/**
|
|
2567
2777
|
* The {@link TransformImport} option transforms the import paths to enable modular imports from subpaths of third-party packages, similar to the functionality provided by {@link https://npmjs.com/package/babel-plugin-import | babel-plugin-import}.
|
|
2568
2778
|
*
|
package/dist/index.js
CHANGED
|
@@ -112,7 +112,7 @@ var __webpack_modules__ = {
|
|
|
112
112
|
});
|
|
113
113
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
114
114
|
var package_namespaceObject = {
|
|
115
|
-
i8: "0.9.
|
|
115
|
+
i8: "0.9.5"
|
|
116
116
|
};
|
|
117
117
|
const version = package_namespaceObject.i8;
|
|
118
118
|
const rspackVersion = core_.rspack.rspackVersion;
|
|
@@ -254,11 +254,18 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
254
254
|
var external_node_path_ = __webpack_require__("node:path");
|
|
255
255
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
256
256
|
function applyDefaultRspeedyConfig(config) {
|
|
257
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
257
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
258
258
|
output: {
|
|
259
259
|
filename: getFilename(config.output?.filename)
|
|
260
|
+
},
|
|
261
|
+
tools: {
|
|
262
|
+
rsdoctor: {
|
|
263
|
+
experiments: {
|
|
264
|
+
enableNativePlugin: true
|
|
265
|
+
}
|
|
266
|
+
}
|
|
260
267
|
}
|
|
261
|
-
});
|
|
268
|
+
}, config);
|
|
262
269
|
return ret;
|
|
263
270
|
}
|
|
264
271
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -348,6 +355,7 @@ function toRsbuildConfig(config) {
|
|
|
348
355
|
entry: toRsbuildEntry(config.source?.entry),
|
|
349
356
|
exclude: config.source?.exclude,
|
|
350
357
|
include: config.source?.include,
|
|
358
|
+
preEntry: config.source?.preEntry,
|
|
351
359
|
transformImport: config.source?.transformImport,
|
|
352
360
|
tsconfigPath: config.source?.tsconfigPath
|
|
353
361
|
},
|
|
@@ -360,7 +368,9 @@ function toRsbuildConfig(config) {
|
|
|
360
368
|
},
|
|
361
369
|
plugins: config.plugins,
|
|
362
370
|
performance: {
|
|
371
|
+
buildCache: config.performance?.buildCache,
|
|
363
372
|
chunkSplit: config.performance?.chunkSplit,
|
|
373
|
+
profile: config.performance?.profile,
|
|
364
374
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
365
375
|
printFileSize: config.performance?.printFileSize ?? true
|
|
366
376
|
},
|
|
@@ -386,14 +396,15 @@ function toRsbuildRemoveConsole(config) {
|
|
|
386
396
|
];
|
|
387
397
|
return config.performance?.removeConsole;
|
|
388
398
|
}
|
|
389
|
-
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
|
|
399
|
+
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
390
400
|
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
391
401
|
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
392
402
|
(0, core_.createRsbuild)({
|
|
393
403
|
cwd,
|
|
394
404
|
loadEnv,
|
|
395
405
|
rsbuildConfig: toRsbuildConfig(config),
|
|
396
|
-
environment
|
|
406
|
+
environment,
|
|
407
|
+
callerName
|
|
397
408
|
}),
|
|
398
409
|
__webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
|
|
399
410
|
]);
|