Skip to content

Commit

Permalink
perf: lazy require browserslist package
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Sep 24, 2024
1 parent ac92769 commit fdc4fdc
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

0 comments on commit fdc4fdc

Please sign in to comment.