Skip to content

Commit

Permalink
fix: browserslist resolve is broken by prebundle (#6629)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored May 27, 2024
1 parent 78b37d3 commit 4755f5d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/rspack/prebundle.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ export default {
externals: {
"caniuse-lite": "caniuse-lite",
"/^caniuse-lite(/.*)/": "caniuse-lite$1"
},
// preserve the `require(require.resolve())`
beforeBundle(task) {
const nodeFile = join(task.depPath, "node.js");
const content = readFileSync(nodeFile, "utf-8");
writeFileSync(
nodeFile,
content.replaceAll(
"require(require.resolve",
'eval("require")(require.resolve'
)
);
}
},
{
Expand Down

2 comments on commit 4755f5d

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ✅ success
_selftest ✅ success
nx ✅ success
rspress ✅ success
rsbuild ✅ success
compat ✅ success
examples ✅ success

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-05-27 89c6913) Current Change
10000_development-mode + exec 2.6 s ± 33 ms 2.57 s ± 33 ms -0.80 %
10000_development-mode_hmr + exec 731 ms ± 9.7 ms 707 ms ± 5.1 ms -3.28 %
10000_production-mode + exec 2.53 s ± 15 ms 2.51 s ± 56 ms -1.05 %
arco-pro_development-mode + exec 2.41 s ± 46 ms 2.39 s ± 61 ms -0.80 %
arco-pro_development-mode_hmr + exec 441 ms ± 2.2 ms 441 ms ± 3.4 ms -0.11 %
arco-pro_development-mode_hmr_intercept-plugin + exec 451 ms ± 4.4 ms 452 ms ± 2.5 ms +0.15 %
arco-pro_development-mode_intercept-plugin + exec 3.19 s ± 60 ms 3.14 s ± 59 ms -1.57 %
arco-pro_production-mode + exec 3.97 s ± 74 ms 3.96 s ± 73 ms -0.48 %
arco-pro_production-mode_intercept-plugin + exec 4.75 s ± 84 ms 4.71 s ± 104 ms -0.79 %
threejs_development-mode_10x + exec 1.96 s ± 16 ms 1.96 s ± 18 ms +0.21 %
threejs_development-mode_10x_hmr + exec 760 ms ± 6.6 ms 782 ms ± 7.6 ms +2.86 %
threejs_production-mode_10x + exec 5.28 s ± 23 ms 5.26 s ± 38 ms -0.39 %

Please sign in to comment.