@lynx-js/rspeedy 0.8.6 → 0.8.7

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @lynx-js/rspeedy
2
2
 
3
+ ## 0.8.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Support using `-debugids` in `output.sourceMap.js`. ([#342](https://github.com/lynx-family/lynx-stack/pull/342))
8
+
9
+ See [Source Map Debug ID Proposal](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) for more details.
10
+
11
+ - Use `chunkLoading: 'import-scripts'` for Web platform ([#352](https://github.com/lynx-family/lynx-stack/pull/352))
12
+
13
+ - Support `output.distPath.*`. ([#366](https://github.com/lynx-family/lynx-stack/pull/366))
14
+
15
+ See [Rsbuild - distPath](https://rsbuild.dev/config/output/dist-path) for all available options.
16
+
17
+ - Support `performance.printFileSize` ([#336](https://github.com/lynx-family/lynx-stack/pull/336))
18
+
19
+ Whether to print the file sizes after production build.
20
+
3
21
  ## 0.8.6
4
22
 
5
23
  ### Patch Changes
@@ -1,39 +1,10 @@
1
+ import type { DistPathConfig } from '@rsbuild/core';
1
2
  /**
2
3
  * {@inheritdoc Output.distPath}
3
4
  *
4
5
  * @public
5
6
  */
6
- export interface DistPath {
7
- /**
8
- * The root directory of all output files.
9
- *
10
- * @remarks
11
- *
12
- * Default value:
13
- *
14
- * - `'dist'`
15
- */
16
- root?: string | undefined;
17
- /**
18
- * The output directory of CSS style files.
19
- *
20
- * @remarks
21
- *
22
- * Default value:
23
- *
24
- * - The same as {@link DistPath.intermediate}
25
- */
26
- css?: string | undefined;
27
- /**
28
- * The output directory of async JavaScript files.
29
- *
30
- * @remarks
31
- *
32
- * Default value:
33
- *
34
- * - The `async` subdirectory of {@link DistPath.css}.
35
- */
36
- cssAsync?: string | undefined;
7
+ export interface DistPath extends DistPathConfig {
37
8
  /**
38
9
  * The output directory of the intermediate files.
39
10
  *
@@ -44,25 +15,5 @@ export interface DistPath {
44
15
  * - `'.rspeedy'`
45
16
  */
46
17
  intermediate?: string | undefined;
47
- /**
48
- * The output directory of JavaScript files.
49
- *
50
- * @remarks
51
- *
52
- * Default value:
53
- *
54
- * - `'static/js'`
55
- */
56
- js?: string | undefined;
57
- /**
58
- * The output directory of async JavaScript files.
59
- *
60
- * @remarks
61
- *
62
- * Default value:
63
- *
64
- * - The `async` subdirectory of {@link DistPath.js}.
65
- */
66
- jsAsync?: string | undefined;
67
18
  }
68
19
  export declare const DEFAULT_DIST_PATH_INTERMEDIATE = ".rspeedy";
@@ -42,7 +42,7 @@ export interface Output {
42
42
  *
43
43
  * By default, if the output directory is a subdirectory of the project root path, Rspeedy will automatically clean all files in the build directory.
44
44
  *
45
- * When {@link DistPath.root | output.distPath.root} is an external directory or the same as the project root directory, `cleanDistPath` is not enabled by default to prevent accidental deletion of files from other directories.
45
+ * When {@link https://rsbuild.dev/config/output/dist-path#root-directory | output.distPath.root} is an external directory or the same as the project root directory, `cleanDistPath` is not enabled by default to prevent accidental deletion of files from other directories.
46
46
  *
47
47
  * @example
48
48
  *
@@ -200,6 +200,10 @@ export interface Output {
200
200
  /**
201
201
  * Set the directory of the dist files.
202
202
  *
203
+ * @remarks
204
+ *
205
+ * More options can be found at {@link https://rsbuild.dev/config/output/dist-path | Rsbuild - distPath}.
206
+ *
203
207
  * @example
204
208
  *
205
209
  * Use `output` instead of `dist`(the default value):
@@ -64,5 +64,5 @@ export interface SourceMap {
64
64
  * })
65
65
  * ```
66
66
  */
67
- js?: Rspack.DevTool | undefined;
67
+ js?: Rspack.DevTool | undefined | `${Exclude<Rspack.DevTool, false | 'eval'>}-debugids`;
68
68
  }
@@ -1,3 +1,4 @@
1
+ import type { PerformanceConfig } from '@rsbuild/core';
1
2
  import type { ChunkSplit, ChunkSplitBySize, ChunkSplitCustom } from './chunk-split.js';
2
3
  /**
3
4
  * The type of the console method.
@@ -47,4 +48,118 @@ export interface Performance {
47
48
  * ```
48
49
  */
49
50
  removeConsole?: boolean | ConsoleType[] | undefined;
51
+ /**
52
+ * Whether to print the file sizes after production build.
53
+ *
54
+ * {@link Performance.printFileSize}
55
+ *
56
+ * See {@link https://rsbuild.dev/config/performance/print-file-size | Rsbuild - performance.printFileSize} for details.
57
+ *
58
+ * @example
59
+ *
60
+ * If you don't want to print any information, you can disable it by setting printFileSize to false:
61
+ *
62
+ * ```ts
63
+ * import { defineConfig } from '@lynx-js/rspeedy'
64
+ *
65
+ * export default defineConfig({
66
+ * performance: {
67
+ * printFileSize: false
68
+ * },
69
+ * })
70
+ * ```
71
+ *
72
+ * @example
73
+ *
74
+ * Set total to false to disable total size output.
75
+ *
76
+ * ```ts
77
+ * import { defineConfig } from '@lynx-js/rspeedy'
78
+ *
79
+ * export default defineConfig({
80
+ * performance: {
81
+ * printFileSize: {
82
+ * total: false,
83
+ * },
84
+ * },
85
+ * })
86
+ * ```
87
+ *
88
+ * @example
89
+ *
90
+ * Set detail to false to disable per-asset size output.
91
+ *
92
+ * If you don't need to view the size of each static asset, you can set detail to false. In this case, only the total size will be output:
93
+ *
94
+ * ```ts
95
+ * import { defineConfig } from '@lynx-js/rspeedy'
96
+ *
97
+ * export default defineConfig({
98
+ * performance: {
99
+ * printFileSize: {
100
+ * detail: false,
101
+ * },
102
+ * },
103
+ * })
104
+ * ```
105
+ *
106
+ * @example
107
+ *
108
+ * If you don't need to view the gzipped size, you can set compressed to false. This can save some gzip computation time for large projects:
109
+ *
110
+ * ```ts
111
+ * import { defineConfig } from '@lynx-js/rspeedy'
112
+ *
113
+ * export default defineConfig({
114
+ * performance: {
115
+ * printFileSize: {
116
+ * compressed: false,
117
+ * },
118
+ * },
119
+ * })
120
+ * ```
121
+ *
122
+ * @example
123
+ *
124
+ * To include only static assets that meet certain criteria, use a filter function with include.
125
+ *
126
+ * If returned false, the static asset will be excluded and not included in the total size or detailed size.
127
+ *
128
+ * only output static assets larger than 10kB:
129
+ *
130
+ * ```ts
131
+ * import { defineConfig } from '@lynx-js/rspeedy'
132
+ *
133
+ * export default defineConfig({
134
+ * performance: {
135
+ * printFileSize: {
136
+ * include: (asset) => asset.size > 10 * 1000,
137
+ * }
138
+ * },
139
+ * })
140
+ * ```
141
+ *
142
+ * @example
143
+ *
144
+ * To exclude static assets that meet certain criteria, use a filter function with exclude. If both include and exclude are set, exclude will take precedence.
145
+ *
146
+ * Rspeedy defaults to excluding source map, license files, and .d.ts type files, as these files do not affect page load performance.
147
+ *
148
+ * exclude .html files in addition to the default:
149
+ *
150
+ * ```ts
151
+ * import { defineConfig } from '@lynx-js/rspeedy'
152
+ *
153
+ * export default defineConfig({
154
+ * performance: {
155
+ * printFileSize: {
156
+ * exclude: (asset) =>
157
+ * /\.(?:map|LICENSE\.txt)$/.test(asset.name) ||
158
+ * /\.html$/.test(asset.name),
159
+ * }
160
+ * },
161
+ * })
162
+ * ```
163
+ */
164
+ printFileSize?: PerformanceConfig['printFileSize'] | undefined;
50
165
  }
@@ -27,6 +27,7 @@ export function toRsbuildConfig(config) {
27
27
  // We expect to use different default legalComments with Rsbuild
28
28
  legalComments: config.output?.legalComments ?? 'none',
29
29
  polyfill: 'off',
30
+ // TODO: update the Rsbuild type to allow `sourceMap.js` to be `*-debugids`
30
31
  sourceMap: config.output?.sourceMap,
31
32
  },
32
33
  source: {
@@ -51,6 +52,7 @@ export function toRsbuildConfig(config) {
51
52
  performance: {
52
53
  chunkSplit: config.performance?.chunkSplit,
53
54
  removeConsole: toRsbuildRemoveConsole(config),
55
+ printFileSize: config.performance?.printFileSize ?? true,
54
56
  },
55
57
  tools: {
56
58
  bundlerChain: config.tools?.bundlerChain,
@@ -44,6 +44,22 @@ export interface Server {
44
44
  headers?: Record<string, string | string[]> | undefined;
45
45
  /**
46
46
  * Specify the host that the Rspeedy Server listens to.
47
+ *
48
+ * @remarks
49
+ * By default, the server listens on local network IP, for example, `192.168.1.50`, verify your local net IP by the command `ifconfig` on your system for (en0 for MacOS and eth0 for LinuxOS users). In case you have multiple local network IP(s) particularly when you are running dockers on the host machine, then you can specify your desired host IP.
50
+ *
51
+ * @example
52
+ *
53
+ * Set the host to a custom value:
54
+ *
55
+ * ```js
56
+ * import { defineConfig } from '@lynx-js/rspeedy'
57
+ * export default defineConfig({
58
+ * server: {
59
+ * host: "192.168.1.50",
60
+ * },
61
+ * })
62
+ * ```
47
63
  */
48
64
  host?: string | undefined;
49
65
  /**