Skip to content

Commit

Permalink
perf: lazy require browserslist package (#7963)
Browse files Browse the repository at this point in the history
perf: lazy require browserslist package
  • Loading branch information
chenjiahan authored Sep 24, 2024
1 parent 23d6bf3 commit b1e8ecd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/rspack/src/config/browserslistTargetHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

import path from "node:path";
import browserslist from "browserslist";
import type {
ApiTargetProperties,
EcmaTargetProperties,
Expand Down Expand Up @@ -43,6 +42,8 @@ const parse = (
return { configPath, env };
}

const browserslist = require("browserslist");

const config = browserslist.findConfig(context);

if (config && Object.keys(config).includes(input)) {
Expand All @@ -61,6 +62,7 @@ export const load = (
input: string | null | undefined,
context: string
): string[] | undefined => {
const browserslist = require("browserslist");
const { configPath, env, query } = parse(input, context);

// if a query is specified, then use it, else
Expand Down

2 comments on commit b1e8ecd

@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-09-24 ce775cc) Current Change
10000_development-mode + exec 2.22 s ± 47 ms 2.27 s ± 25 ms +1.93 %
10000_development-mode_hmr + exec 687 ms ± 7.8 ms 707 ms ± 16 ms +2.88 %
10000_production-mode + exec 2.8 s ± 38 ms 2.91 s ± 23 ms +3.71 %
arco-pro_development-mode + exec 1.84 s ± 83 ms 1.83 s ± 85 ms -0.38 %
arco-pro_development-mode_hmr + exec 434 ms ± 1.9 ms 437 ms ± 1.1 ms +0.81 %
arco-pro_production-mode + exec 3.25 s ± 61 ms 3.31 s ± 81 ms +1.82 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.32 s ± 67 ms 3.36 s ± 53 ms +1.35 %
threejs_development-mode_10x + exec 1.68 s ± 21 ms 1.71 s ± 16 ms +1.31 %
threejs_development-mode_10x_hmr + exec 781 ms ± 7.9 ms 795 ms ± 15 ms +1.75 %
threejs_production-mode_10x + exec 5.11 s ± 31 ms 5.27 s ± 19 ms +3.06 %

@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 ❌ failure
rspress ✅ success
rslib ✅ success
rsbuild ✅ success
examples ✅ success
devserver ✅ success

Please sign in to comment.