@lynx-js/rspeedy 0.9.10 → 0.10.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 +46 -0
- package/dist/cli/main.js +6 -6
- package/dist/index.d.ts +12 -5
- package/dist/index.js +4 -4
- package/dist/register/hooks.js +14 -14
- package/dist/register/index.js +3 -3
- package/dist/src_cli_commands_ts.js +1 -1
- package/dist/src_config_validate_ts.js +3629 -3800
- package/dist/src_plugins_inspect_plugin_ts.js +1 -1
- package/dist/src_version_ts.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @lynx-js/rspeedy
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Bump Rsbuild v1.4.3 with Rspack v1.4.2. ([#1204](https://github.com/lynx-family/lynx-stack/pull/1204))
|
|
8
|
+
|
|
9
|
+
See [Announcing Rspack 1.4](https://rspack.rs/blog/announcing-1-4) for more details.
|
|
10
|
+
|
|
11
|
+
- Deprecated `output.distPath.intermediate` ([#1154](https://github.com/lynx-family/lynx-stack/pull/1154))
|
|
12
|
+
|
|
13
|
+
This option is never read and will be removed in the future version.
|
|
14
|
+
|
|
15
|
+
## 0.9.11
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Enable fine-grained control for `output.inlineScripts` ([#883](https://github.com/lynx-family/lynx-stack/pull/883))
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
type InlineChunkTestFunction = (params: {
|
|
23
|
+
size: number
|
|
24
|
+
name: string
|
|
25
|
+
}) => boolean
|
|
26
|
+
|
|
27
|
+
type InlineChunkTest = RegExp | InlineChunkTestFunction
|
|
28
|
+
|
|
29
|
+
type InlineChunkConfig =
|
|
30
|
+
| boolean
|
|
31
|
+
| InlineChunkTest
|
|
32
|
+
| { enable?: boolean | 'auto', test: InlineChunkTest }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { defineConfig } from '@lynx-js/rspeedy'
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
output: {
|
|
40
|
+
inlineScripts: ({ name, size }) => {
|
|
41
|
+
return name.includes('foo') && size < 1000
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- docs: remove chunks: 'all' in comments ([#1168](https://github.com/lynx-family/lynx-stack/pull/1168))
|
|
48
|
+
|
|
3
49
|
## 0.9.10
|
|
4
50
|
|
|
5
51
|
## 0.9.9
|
package/dist/cli/main.js
CHANGED
|
@@ -194,9 +194,9 @@ var __webpack_modules__ = {
|
|
|
194
194
|
NW: ()=>debugList,
|
|
195
195
|
fF: ()=>debug
|
|
196
196
|
});
|
|
197
|
-
var
|
|
198
|
-
var
|
|
199
|
-
var
|
|
197
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
198
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
199
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_1__);
|
|
200
200
|
const isDebug = ()=>{
|
|
201
201
|
if (!process.env['DEBUG']) return false;
|
|
202
202
|
const values = process.env['DEBUG'].toLocaleLowerCase().split(',');
|
|
@@ -206,12 +206,12 @@ var __webpack_modules__ = {
|
|
|
206
206
|
'*'
|
|
207
207
|
].some((key)=>values.includes(key));
|
|
208
208
|
};
|
|
209
|
-
const label =
|
|
209
|
+
const label = picocolors__WEBPACK_IMPORTED_MODULE_1___default().bgCyan('lynx');
|
|
210
210
|
const debug = (message)=>{
|
|
211
211
|
if (isDebug()) {
|
|
212
212
|
const result = 'string' == typeof message ? message : message();
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.level = 'verbose';
|
|
214
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.debug(`${label} ${result}`);
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
217
|
const debugList = (prefix, messages)=>debug(()=>`${prefix} ${[
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import type { CreateRsbuildOptions } from '@rsbuild/core';
|
|
19
19
|
import type { DistPathConfig } from '@rsbuild/core';
|
|
20
|
+
import type { InlineChunkConfig } from '@rsbuild/core';
|
|
20
21
|
import { logger } from '@rsbuild/core';
|
|
21
22
|
import type { PerformanceConfig } from '@rsbuild/core';
|
|
22
23
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
@@ -179,7 +180,6 @@ export declare interface ChunkSplit {
|
|
|
179
180
|
* react: {
|
|
180
181
|
* test: /node_modules[\\/](@lynx-js[\\/]react|react-router)[\\/]/,
|
|
181
182
|
* name: 'lib-react',
|
|
182
|
-
* chunks: 'all',
|
|
183
183
|
* },
|
|
184
184
|
* },
|
|
185
185
|
* },
|
|
@@ -282,7 +282,6 @@ export declare interface ChunkSplitCustom {
|
|
|
282
282
|
* react: {
|
|
283
283
|
* test: /node_modules[\\/](@lynx-js[\\/]react|react-router)[\\/]/,
|
|
284
284
|
* name: 'lib-react',
|
|
285
|
-
* chunks: 'all',
|
|
286
285
|
* },
|
|
287
286
|
* },
|
|
288
287
|
* },
|
|
@@ -1194,6 +1193,10 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1194
1193
|
/**
|
|
1195
1194
|
* The output directory of the intermediate files.
|
|
1196
1195
|
*
|
|
1196
|
+
* @deprecated
|
|
1197
|
+
*
|
|
1198
|
+
* This option is never read and will be removed in the future version.
|
|
1199
|
+
*
|
|
1197
1200
|
* @remarks
|
|
1198
1201
|
*
|
|
1199
1202
|
* Default value:
|
|
@@ -1963,11 +1966,15 @@ export declare interface Output {
|
|
|
1963
1966
|
*
|
|
1964
1967
|
* @remarks
|
|
1965
1968
|
*
|
|
1966
|
-
* If no value is provided, the default value would be `true
|
|
1969
|
+
* If no value is provided, the default value would be `true`, which means all background thread scripts will be inlined.
|
|
1967
1970
|
*
|
|
1968
1971
|
* This is different with {@link https://rsbuild.dev/config/output/inline-scripts | output.inlineScripts } since we normally want to inline scripts in Lynx bundle (`.lynx.bundle`).
|
|
1969
1972
|
*
|
|
1970
|
-
*
|
|
1973
|
+
* There are two points that need to be especially noted:
|
|
1974
|
+
*
|
|
1975
|
+
* 1. Only background thread scripts can remain non-inlined, whereas the main thread script is always inlined.
|
|
1976
|
+
*
|
|
1977
|
+
* 2. Currently, when `experimental_isLazyBundle` is enabled, `inlineScripts` will always be `true`.
|
|
1971
1978
|
*
|
|
1972
1979
|
* @example
|
|
1973
1980
|
*
|
|
@@ -1982,7 +1989,7 @@ export declare interface Output {
|
|
|
1982
1989
|
* })
|
|
1983
1990
|
* ```
|
|
1984
1991
|
*/
|
|
1985
|
-
inlineScripts?:
|
|
1992
|
+
inlineScripts?: InlineChunkConfig | undefined;
|
|
1986
1993
|
/**
|
|
1987
1994
|
* The {@link Output.legalComments} controls how to handle the legal comment.
|
|
1988
1995
|
*
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/
|
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
|
|
7
|
-
import
|
|
7
|
+
import node_fs from "node:fs";
|
|
8
8
|
import { pathToFileURL } from "node:url";
|
|
9
9
|
import { register } from "@lynx-js/rspeedy/register";
|
|
10
10
|
var __webpack_modules__ = {
|
|
@@ -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.
|
|
115
|
+
i8: "0.10.0"
|
|
116
116
|
};
|
|
117
117
|
const version = package_namespaceObject.i8;
|
|
118
118
|
const rspackVersion = core_.rspack.rspackVersion;
|
|
@@ -439,7 +439,7 @@ const resolveConfigPath = (root, customConfig)=>{
|
|
|
439
439
|
if (customConfig) {
|
|
440
440
|
(0, debug.fF)(`load custom config file ${customConfig} from ${root}`);
|
|
441
441
|
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
442
|
-
if (
|
|
442
|
+
if (node_fs.existsSync(customConfigPath)) return customConfigPath;
|
|
443
443
|
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
444
444
|
}
|
|
445
445
|
const CONFIG_FILES = [
|
|
@@ -451,7 +451,7 @@ const resolveConfigPath = (root, customConfig)=>{
|
|
|
451
451
|
for (const file of CONFIG_FILES){
|
|
452
452
|
(0, debug.fF)(`load default config file ${file} from ${root}`);
|
|
453
453
|
const configFile = (0, external_node_path_.join)(root, file);
|
|
454
|
-
if (
|
|
454
|
+
if (node_fs.existsSync(configFile)) {
|
|
455
455
|
(0, debug.fF)(`default config ${configFile} found`);
|
|
456
456
|
return configFile;
|
|
457
457
|
}
|
package/dist/register/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { URL } from "node:url";
|
|
2
|
-
import
|
|
2
|
+
import typescript from "typescript";
|
|
3
3
|
const FLAG_REPLACE_WITH_OPEN_PAREN = 1;
|
|
4
4
|
const FLAG_REPLACE_WITH_CLOSE_PAREN = 2;
|
|
5
5
|
const FLAG_REPLACE_WITH_SEMI = 3;
|
|
@@ -67,17 +67,17 @@ class BlankString {
|
|
|
67
67
|
return out + input.slice(previousEnd);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
const SK =
|
|
70
|
+
const SK = typescript.SyntaxKind;
|
|
71
71
|
const VISIT_BLANKED = "";
|
|
72
72
|
const VISITED_JS = null;
|
|
73
73
|
const languageOptions = {
|
|
74
|
-
languageVersion:
|
|
75
|
-
impliedNodeFormat:
|
|
74
|
+
languageVersion: typescript.ScriptTarget.ESNext,
|
|
75
|
+
impliedNodeFormat: typescript.ModuleKind.ESNext
|
|
76
76
|
};
|
|
77
|
-
const scanner =
|
|
78
|
-
if (
|
|
79
|
-
languageOptions.jsDocParsingMode =
|
|
80
|
-
scanner.setJSDocParsingMode(
|
|
77
|
+
const scanner = typescript.createScanner(typescript.ScriptTarget.ESNext, true, typescript.LanguageVariant.Standard);
|
|
78
|
+
if (typescript.JSDocParsingMode) {
|
|
79
|
+
languageOptions.jsDocParsingMode = typescript.JSDocParsingMode.ParseNone;
|
|
80
|
+
scanner.setJSDocParsingMode(typescript.JSDocParsingMode.ParseNone);
|
|
81
81
|
}
|
|
82
82
|
let src = "";
|
|
83
83
|
let str = new BlankString("");
|
|
@@ -86,7 +86,7 @@ let onError;
|
|
|
86
86
|
let seenJS = false;
|
|
87
87
|
let parentStatement;
|
|
88
88
|
function tsBlankSpace(input, onErrorArg) {
|
|
89
|
-
return blankSourceFile(
|
|
89
|
+
return blankSourceFile(typescript.createSourceFile("input.ts", input, languageOptions, false, typescript.ScriptKind.TS), onErrorArg);
|
|
90
90
|
}
|
|
91
91
|
function blankSourceFile(source, onErrorArg) {
|
|
92
92
|
try {
|
|
@@ -110,7 +110,7 @@ function blankSourceFile(source, onErrorArg) {
|
|
|
110
110
|
}
|
|
111
111
|
function visitUnknownNodeArray(nodes) {
|
|
112
112
|
if (0 === nodes.length) return VISITED_JS;
|
|
113
|
-
return visitNodeArray(nodes,
|
|
113
|
+
return visitNodeArray(nodes, typescript.isStatement(nodes[0]), false);
|
|
114
114
|
}
|
|
115
115
|
function visitNodeArray(nodes, isStatementLike, isFunctionBody) {
|
|
116
116
|
const previousParentStatement = parentStatement;
|
|
@@ -371,7 +371,7 @@ function visitImportDeclaration(node) {
|
|
|
371
371
|
return VISIT_BLANKED;
|
|
372
372
|
}
|
|
373
373
|
const { namedBindings } = node.importClause;
|
|
374
|
-
if (namedBindings &&
|
|
374
|
+
if (namedBindings && typescript.isNamedImports(namedBindings)) {
|
|
375
375
|
const elements = namedBindings.elements;
|
|
376
376
|
for(let i = 0; i < elements.length; i++){
|
|
377
377
|
const e = elements[i];
|
|
@@ -387,7 +387,7 @@ function visitExportDeclaration(node) {
|
|
|
387
387
|
return VISIT_BLANKED;
|
|
388
388
|
}
|
|
389
389
|
const { exportClause } = node;
|
|
390
|
-
if (exportClause &&
|
|
390
|
+
if (exportClause && typescript.isNamedExports(exportClause)) {
|
|
391
391
|
const elements = exportClause.elements;
|
|
392
392
|
for(let i = 0; i < elements.length; i++){
|
|
393
393
|
const e = elements[i];
|
|
@@ -405,7 +405,7 @@ function visitExportAssignment(node) {
|
|
|
405
405
|
return VISITED_JS;
|
|
406
406
|
}
|
|
407
407
|
function visitModule(node) {
|
|
408
|
-
if (node.flags &
|
|
408
|
+
if (node.flags & typescript.NodeFlags.GlobalAugmentation || node.flags & typescript.NodeFlags.Namespace && (node.modifiers && modifiersContainsDeclare(node.modifiers) || !valueNamespaceWorker(node)) || node.name.kind === SK.StringLiteral) {
|
|
409
409
|
blankStatement(node);
|
|
410
410
|
return VISIT_BLANKED;
|
|
411
411
|
}
|
|
@@ -432,7 +432,7 @@ function valueNamespaceWorker(node) {
|
|
|
432
432
|
}
|
|
433
433
|
case SK.ModuleDeclaration:
|
|
434
434
|
{
|
|
435
|
-
if (!(node.flags &
|
|
435
|
+
if (!(node.flags & typescript.NodeFlags.Namespace)) return true;
|
|
436
436
|
const { body } = node;
|
|
437
437
|
if (!body) return false;
|
|
438
438
|
if (body.kind === SK.ModuleDeclaration) return valueNamespaceWorker(body);
|
package/dist/register/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import node_module from "node:module";
|
|
2
2
|
function register() {
|
|
3
|
-
if (!
|
|
3
|
+
if (!node_module.register) throw new Error([
|
|
4
4
|
`This version of Node.js (${process.version}) does not support module.register(). You can either:`,
|
|
5
5
|
" - Upgrade to Node.js v18.19 or v20.6 and above",
|
|
6
6
|
" - Use `lynx.config.js` instead of `lynx.config.ts`"
|
|
7
7
|
].join('\n'));
|
|
8
8
|
const { port1, port2 } = new MessageChannel();
|
|
9
|
-
|
|
9
|
+
node_module.register(`./hooks.js?${Date.now()}`, import.meta.url, {
|
|
10
10
|
parentURL: import.meta.url,
|
|
11
11
|
data: {
|
|
12
12
|
port: port2
|
|
@@ -40,7 +40,7 @@ export const __webpack_modules__ = {
|
|
|
40
40
|
});
|
|
41
41
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
42
42
|
var package_namespaceObject = {
|
|
43
|
-
i8: "0.
|
|
43
|
+
i8: "0.10.0"
|
|
44
44
|
};
|
|
45
45
|
const version = package_namespaceObject.i8;
|
|
46
46
|
const rspackVersion = core_.rspack.rspackVersion;
|