@lynx-js/rspeedy 0.13.5 → 0.14.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 +23 -0
- package/dist/0~src_config_validate_ts.js +1455 -1397
- package/dist/0~src_plugins_dev_plugin_ts.js +1 -1
- package/dist/0~src_plugins_minify_plugin_ts.js +92 -21
- package/dist/1~src_config_validate_ts.js +1485 -1427
- package/dist/1~src_plugins_dev_plugin_ts.js +1 -1
- package/dist/1~src_plugins_minify_plugin_ts.js +95 -21
- package/dist/index.d.ts +49 -0
- package/dist/src_cli_main_ts.js +1 -1
- package/dist/src_index_ts.js +1 -1
- package/package.json +4 -4
|
@@ -90,7 +90,7 @@ function pluginDev(options, server) {
|
|
|
90
90
|
url: new URL(pathname, baseForUrls).toString()
|
|
91
91
|
});
|
|
92
92
|
if ('web' === environmentName) finalUrls.push({
|
|
93
|
-
label: "
|
|
93
|
+
label: "∟ Preview",
|
|
94
94
|
url: new URL(`/__web_preview?casename=${encodeURIComponent(pathname)}`, baseForUrls).toString()
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -1,29 +1,51 @@
|
|
|
1
|
-
import { debug } from "./src_cli_main_ts.js";
|
|
1
|
+
import { mergeRsbuildConfig as core_mergeRsbuildConfig, debug } from "./src_cli_main_ts.js";
|
|
2
|
+
function mergeRspeedyConfig(...configs) {
|
|
3
|
+
return core_mergeRsbuildConfig(...configs);
|
|
4
|
+
}
|
|
5
|
+
const MAIN_THREAD_JS_PATTERN = /.*main-thread(?:\.[A-Fa-f0-9]*)?\.js$/;
|
|
6
|
+
const BACKGROUND_JS_PATTERN = /.*background(?:\.[A-Fa-f0-9]*)?\.js$/;
|
|
7
|
+
function mergeJsOptions(baseOptions, threadOptions) {
|
|
8
|
+
const merged = mergeRspeedyConfig({
|
|
9
|
+
output: {
|
|
10
|
+
minify: {
|
|
11
|
+
jsOptions: baseOptions
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}, {
|
|
15
|
+
output: {
|
|
16
|
+
minify: {
|
|
17
|
+
jsOptions: threadOptions
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return merged.output?.minify?.jsOptions ?? {};
|
|
22
|
+
}
|
|
2
23
|
function pluginMinify(options) {
|
|
24
|
+
const defaultJsOptions = Object.freeze({
|
|
25
|
+
minimizerOptions: {
|
|
26
|
+
compress: {
|
|
27
|
+
negate_iife: false,
|
|
28
|
+
join_vars: false,
|
|
29
|
+
ecma: 2015,
|
|
30
|
+
inline: 2,
|
|
31
|
+
comparisons: false,
|
|
32
|
+
toplevel: true,
|
|
33
|
+
side_effects: false
|
|
34
|
+
},
|
|
35
|
+
format: {
|
|
36
|
+
keep_quoted_props: true,
|
|
37
|
+
comments: false
|
|
38
|
+
},
|
|
39
|
+
mangle: {
|
|
40
|
+
toplevel: true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
3
44
|
const defaultConfig = Object.freeze({
|
|
4
45
|
output: {
|
|
5
46
|
minify: {
|
|
6
47
|
js: true,
|
|
7
|
-
jsOptions:
|
|
8
|
-
minimizerOptions: {
|
|
9
|
-
compress: {
|
|
10
|
-
negate_iife: false,
|
|
11
|
-
join_vars: false,
|
|
12
|
-
ecma: 2015,
|
|
13
|
-
inline: 2,
|
|
14
|
-
comparisons: false,
|
|
15
|
-
toplevel: true,
|
|
16
|
-
side_effects: false
|
|
17
|
-
},
|
|
18
|
-
format: {
|
|
19
|
-
keep_quoted_props: true,
|
|
20
|
-
comments: false
|
|
21
|
-
},
|
|
22
|
-
mangle: {
|
|
23
|
-
toplevel: true
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
48
|
+
jsOptions: defaultJsOptions,
|
|
27
49
|
css: true,
|
|
28
50
|
cssOptions: {
|
|
29
51
|
minimizerOptions: {
|
|
@@ -69,6 +91,58 @@ function pluginMinify(options) {
|
|
|
69
91
|
}
|
|
70
92
|
return mergeRsbuildConfig(...configs);
|
|
71
93
|
});
|
|
94
|
+
api.modifyBundlerChain((chain, { rspack, CHAIN_ID })=>{
|
|
95
|
+
const currentConfig = api.getRsbuildConfig('normalized');
|
|
96
|
+
const minify = currentConfig.output?.minify;
|
|
97
|
+
if ('object' != typeof minify || null === minify || false === minify.js) return;
|
|
98
|
+
if (void 0 === minify.mainThreadOptions && void 0 === minify.backgroundOptions) return;
|
|
99
|
+
const jsOptions = minify.jsOptions ?? {};
|
|
100
|
+
if (chain.optimization.minimizers.has(CHAIN_ID.MINIMIZER.JS)) chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).tap((args)=>{
|
|
101
|
+
const defaultOptions = args[0] ?? {};
|
|
102
|
+
const threadExclude = [
|
|
103
|
+
MAIN_THREAD_JS_PATTERN,
|
|
104
|
+
BACKGROUND_JS_PATTERN
|
|
105
|
+
];
|
|
106
|
+
defaultOptions.exclude = defaultOptions.exclude ? Array.isArray(defaultOptions.exclude) ? [
|
|
107
|
+
...defaultOptions.exclude,
|
|
108
|
+
...threadExclude
|
|
109
|
+
] : [
|
|
110
|
+
defaultOptions.exclude,
|
|
111
|
+
...threadExclude
|
|
112
|
+
] : threadExclude;
|
|
113
|
+
return [
|
|
114
|
+
defaultOptions
|
|
115
|
+
];
|
|
116
|
+
});
|
|
117
|
+
const mainThreadOptions = mergeJsOptions(jsOptions, minify.mainThreadOptions);
|
|
118
|
+
const mtInclude = [
|
|
119
|
+
MAIN_THREAD_JS_PATTERN
|
|
120
|
+
];
|
|
121
|
+
mainThreadOptions.include = mainThreadOptions.include ? Array.isArray(mainThreadOptions.include) ? [
|
|
122
|
+
...mainThreadOptions.include,
|
|
123
|
+
...mtInclude
|
|
124
|
+
] : [
|
|
125
|
+
mainThreadOptions.include,
|
|
126
|
+
...mtInclude
|
|
127
|
+
] : mtInclude;
|
|
128
|
+
chain.optimization.minimizer('js-main-thread').use(rspack.SwcJsMinimizerRspackPlugin, [
|
|
129
|
+
mainThreadOptions
|
|
130
|
+
]).end();
|
|
131
|
+
const backgroundOptions = mergeJsOptions(jsOptions, minify.backgroundOptions);
|
|
132
|
+
const bgInclude = [
|
|
133
|
+
BACKGROUND_JS_PATTERN
|
|
134
|
+
];
|
|
135
|
+
backgroundOptions.include = backgroundOptions.include ? Array.isArray(backgroundOptions.include) ? [
|
|
136
|
+
...backgroundOptions.include,
|
|
137
|
+
...bgInclude
|
|
138
|
+
] : [
|
|
139
|
+
backgroundOptions.include,
|
|
140
|
+
...bgInclude
|
|
141
|
+
] : bgInclude;
|
|
142
|
+
chain.optimization.minimizer('js-background').use(rspack.SwcJsMinimizerRspackPlugin, [
|
|
143
|
+
backgroundOptions
|
|
144
|
+
]).end();
|
|
145
|
+
});
|
|
72
146
|
}
|
|
73
147
|
};
|
|
74
148
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1914,6 +1914,55 @@ export declare interface Minify {
|
|
|
1914
1914
|
* ```
|
|
1915
1915
|
*/
|
|
1916
1916
|
jsOptions?: Rspack.SwcJsMinimizerRspackPluginOptions | undefined;
|
|
1917
|
+
/**
|
|
1918
|
+
* {@link Minify.mainThreadOptions} is used to override
|
|
1919
|
+
* {@link Minify.jsOptions} for main-thread bundles.
|
|
1920
|
+
*
|
|
1921
|
+
* @remarks
|
|
1922
|
+
*
|
|
1923
|
+
* This option is deep-merged into {@link Minify.jsOptions}.
|
|
1924
|
+
* It is mainly used together with ReactLynx dual-thread outputs so that
|
|
1925
|
+
* main-thread and background-thread bundles can use different compress rules.
|
|
1926
|
+
*
|
|
1927
|
+
* @example
|
|
1928
|
+
*
|
|
1929
|
+
* ```ts
|
|
1930
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1931
|
+
*
|
|
1932
|
+
* export default defineConfig({
|
|
1933
|
+
* output: {
|
|
1934
|
+
* minify: {
|
|
1935
|
+
* jsOptions: {
|
|
1936
|
+
* minimizerOptions: {
|
|
1937
|
+
* compress: {
|
|
1938
|
+
* pure_funcs: ['console.log'],
|
|
1939
|
+
* },
|
|
1940
|
+
* },
|
|
1941
|
+
* },
|
|
1942
|
+
* mainThreadOptions: {
|
|
1943
|
+
* minimizerOptions: {
|
|
1944
|
+
* compress: {
|
|
1945
|
+
* pure_funcs: ['NativeModules.call', 'lynx.getJSModule'],
|
|
1946
|
+
* },
|
|
1947
|
+
* },
|
|
1948
|
+
* },
|
|
1949
|
+
* },
|
|
1950
|
+
* },
|
|
1951
|
+
* })
|
|
1952
|
+
* ```
|
|
1953
|
+
*/
|
|
1954
|
+
mainThreadOptions?: Rspack.SwcJsMinimizerRspackPluginOptions | undefined;
|
|
1955
|
+
/**
|
|
1956
|
+
* {@link Minify.backgroundOptions} is used to override
|
|
1957
|
+
* {@link Minify.jsOptions} for background-thread bundles.
|
|
1958
|
+
*
|
|
1959
|
+
* @remarks
|
|
1960
|
+
*
|
|
1961
|
+
* This option is deep-merged into {@link Minify.jsOptions}.
|
|
1962
|
+
* It is mainly used together with ReactLynx dual-thread outputs so that
|
|
1963
|
+
* main-thread and background-thread bundles can use different compress rules.
|
|
1964
|
+
*/
|
|
1965
|
+
backgroundOptions?: Rspack.SwcJsMinimizerRspackPluginOptions | undefined;
|
|
1917
1966
|
}
|
|
1918
1967
|
|
|
1919
1968
|
/**
|
package/dist/src_cli_main_ts.js
CHANGED
|
@@ -192,7 +192,7 @@ async function exit_onExit(signal) {
|
|
|
192
192
|
await Promise.allSettled(exitPromises);
|
|
193
193
|
}
|
|
194
194
|
var package_namespaceObject = {
|
|
195
|
-
rE: "0.
|
|
195
|
+
rE: "0.14.0"
|
|
196
196
|
};
|
|
197
197
|
const version_version = package_namespaceObject.rE;
|
|
198
198
|
const rspackVersion = rspack.rspackVersion;
|
package/dist/src_index_ts.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/rspeedy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A webpack/rspack-based frontend toolchain for Lynx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"README.md"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@rsbuild/core": "1.7.
|
|
51
|
+
"@rsbuild/core": "1.7.4",
|
|
52
52
|
"@rsbuild/plugin-css-minimizer": "1.1.1",
|
|
53
53
|
"@rsdoctor/rspack-plugin": "1.2.3",
|
|
54
|
-
"@lynx-js/cache-events-webpack-plugin": "^0.0.
|
|
54
|
+
"@lynx-js/cache-events-webpack-plugin": "^0.0.3",
|
|
55
55
|
"@lynx-js/chunk-loading-webpack-plugin": "^0.3.3",
|
|
56
|
-
"@lynx-js/web-rsbuild-server-middleware": "0.
|
|
56
|
+
"@lynx-js/web-rsbuild-server-middleware": "0.20.0",
|
|
57
57
|
"@lynx-js/webpack-dev-transport": "^0.2.0",
|
|
58
58
|
"@lynx-js/websocket": "^0.0.4"
|
|
59
59
|
},
|