@xh/hoist-dev-utils 16.4.0 → 16.4.2
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/configureRsbuild.js +8 -11
- package/lib/common.js +14 -8
- package/lib/hoistCompile.js +17 -0
- package/package.json +2 -2
package/configureRsbuild.js
CHANGED
|
@@ -39,7 +39,13 @@ const {
|
|
|
39
39
|
logMsg
|
|
40
40
|
} = require('./lib/common');
|
|
41
41
|
|
|
42
|
-
const {
|
|
42
|
+
const {
|
|
43
|
+
HOIST_SWC,
|
|
44
|
+
hoistMinifyOptions,
|
|
45
|
+
resolveAppIdentity,
|
|
46
|
+
resolveHoistPath,
|
|
47
|
+
xhDefines
|
|
48
|
+
} = require('./lib/hoistCompile');
|
|
43
49
|
|
|
44
50
|
const {
|
|
45
51
|
INLINE_PACKAGES_VAR,
|
|
@@ -550,16 +556,7 @@ async function configureRsbuild(env) {
|
|
|
550
556
|
js: prodBuild && minify,
|
|
551
557
|
css: prodBuild && minify,
|
|
552
558
|
jsOptions: {
|
|
553
|
-
minimizerOptions: _.merge(
|
|
554
|
-
{
|
|
555
|
-
// Mangling renames local identifiers for meaningfully smaller bundles.
|
|
556
|
-
// Function and class names are kept - relied upon for error messages,
|
|
557
|
-
// logging, and debugging of deployed builds.
|
|
558
|
-
compress: {keep_classnames: true, keep_fnames: true},
|
|
559
|
-
mangle: {keep_classnames: true, keep_fnames: true}
|
|
560
|
-
},
|
|
561
|
-
minifyOptions
|
|
562
|
-
)
|
|
559
|
+
minimizerOptions: _.merge(hoistMinifyOptions(), minifyOptions)
|
|
563
560
|
}
|
|
564
561
|
}
|
|
565
562
|
},
|
package/lib/common.js
CHANGED
|
@@ -68,16 +68,22 @@ function checkHoistReactVersion(hoistReactPkg, inlineHoist) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// Rspack releases that break Hoist builds, each with the reason
|
|
72
|
-
//
|
|
71
|
+
// Rspack releases that break Hoist builds, each with the reason. A published version never
|
|
72
|
+
// changes, so blocking an exact version is permanent and safe. Both bugs come from the SWC
|
|
73
|
+
// minifier with keep_classnames set, and production builds crash on load.
|
|
73
74
|
const BLOCKED_RSPACK_VERSIONS = {
|
|
74
75
|
'2.3.2':
|
|
75
|
-
'Its minifier breaks classes that reference themselves in a static initializer
|
|
76
|
-
'
|
|
77
|
-
|
|
78
|
-
'
|
|
76
|
+
'Its minifier breaks classes that reference themselves in a static initializer ' +
|
|
77
|
+
'(web-infra-dev/rspack#16586, xh/hoist-dev-utils#85).',
|
|
78
|
+
'2.3.3':
|
|
79
|
+
'Its minifier can give a local variable the same name as a kept class name, so code ' +
|
|
80
|
+
'inside the class reads the wrong value. Highcharts fails to render charts ' +
|
|
81
|
+
'(web-infra-dev/rspack#16695, swc-project/swc#12770).'
|
|
79
82
|
};
|
|
80
83
|
|
|
84
|
+
// Newest Rspack release known to minify Hoist builds correctly, named in the blocked-version error.
|
|
85
|
+
const SAFE_RSPACK_VERSION = '2.3.1';
|
|
86
|
+
|
|
81
87
|
/**
|
|
82
88
|
* Fail the build, or the dev server, on an Rspack release known to break Hoist builds. The dev
|
|
83
89
|
* server fails too, even where it would run, so the problem shows up on the first local run rather
|
|
@@ -87,8 +93,8 @@ function checkRspackVersion(rspackVersion) {
|
|
|
87
93
|
const detail = BLOCKED_RSPACK_VERSIONS[rspackVersion];
|
|
88
94
|
if (detail) {
|
|
89
95
|
throw (
|
|
90
|
-
`@rspack/core v${rspackVersion} is not supported by hoist-dev-utils
|
|
91
|
-
`
|
|
96
|
+
`@rspack/core v${rspackVersion} is not supported by hoist-dev-utils. ${detail} ` +
|
|
97
|
+
`Pin "@rspack/core": "${SAFE_RSPACK_VERSION}" with a pnpm override in the app.`
|
|
92
98
|
);
|
|
93
99
|
}
|
|
94
100
|
}
|
package/lib/hoistCompile.js
CHANGED
|
@@ -37,6 +37,22 @@ function hoistSwcTransform() {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* SWC minifier options for production builds, before any `minifyOptions` from the app. Mangling
|
|
42
|
+
* renames locals for smaller bundles. Class names must be kept: Hoist installs and looks up
|
|
43
|
+
* services, and matches model selectors, by class name. Function names are kept for readable
|
|
44
|
+
* errors and stack traces in deployed builds. Returns a new object, safe to merge into.
|
|
45
|
+
*
|
|
46
|
+
* Two Rspack releases mangle wrongly with these options: see `BLOCKED_RSPACK_VERSIONS` in
|
|
47
|
+
* `lib/common.js`. `test/minify.test.js` runs both bugs against the installed Rspack.
|
|
48
|
+
*/
|
|
49
|
+
function hoistMinifyOptions() {
|
|
50
|
+
return {
|
|
51
|
+
compress: {keep_classnames: true, keep_fnames: true},
|
|
52
|
+
mangle: {keep_classnames: true, keep_fnames: true}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
40
56
|
/** App identity from `env`, with the `configureRsbuild()` defaults. `appCode` is required. */
|
|
41
57
|
function resolveAppIdentity(env) {
|
|
42
58
|
const {appCode} = env;
|
|
@@ -134,6 +150,7 @@ function readPackageName(dir) {
|
|
|
134
150
|
module.exports = {
|
|
135
151
|
HOIST_SWC,
|
|
136
152
|
hoistSwcTransform,
|
|
153
|
+
hoistMinifyOptions,
|
|
137
154
|
resolveAppIdentity,
|
|
138
155
|
xhDefines,
|
|
139
156
|
INLINE_HOIST_SINGLETONS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist-dev-utils",
|
|
3
|
-
"version": "16.4.
|
|
3
|
+
"version": "16.4.2",
|
|
4
4
|
"description": "Rsbuild (Rspack + SWC) build configuration and shared dev dependencies for Hoist React applications.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"node": ">=22.15.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@rsbuild/core": "
|
|
28
|
+
"@rsbuild/core": "2.3.1",
|
|
29
29
|
"@rsbuild/plugin-basic-ssl": "~2.0.0",
|
|
30
30
|
"@rsbuild/plugin-react": "~2.1.1",
|
|
31
31
|
"@rsbuild/plugin-sass": "~2.0.1",
|