Skip to content

Commit 00347ed

Browse files
perf(webpack-cli): allocate Levenshtein buffer lazily (#4765)
1 parent 1b40b72 commit 00347ed

5 files changed

Lines changed: 289 additions & 235 deletions

File tree

.changeset/cli-performance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-cli": patch
3+
---
4+
5+
Improved CLI startup performance and reduced memory usage.

packages/webpack-cli/bin/cli.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
"use strict";
44

5-
const importLocal = require("import-local");
5+
// Prefer the local installation of `webpack-cli` when one exists. Run this
6+
// before requiring the (heavier) CLI implementation: a delegated run then never
7+
// loads it, and `WEBPACK_CLI_SKIP_IMPORT_LOCAL` skips loading `import-local` too.
8+
if (!process.env.WEBPACK_CLI_SKIP_IMPORT_LOCAL && require("import-local")(__filename)) {
9+
return;
10+
}
11+
12+
process.title = "webpack";
13+
614
const WebpackCLI = require("../lib/webpack-cli").default;
715

816
const runCLI = async (args) => {
@@ -16,14 +24,5 @@ const runCLI = async (args) => {
1624
}
1725
};
1826

19-
if (
20-
!process.env.WEBPACK_CLI_SKIP_IMPORT_LOCAL && // Prefer the local installation of `webpack-cli`
21-
importLocal(__filename)
22-
) {
23-
return;
24-
}
25-
26-
process.title = "webpack";
27-
2827
// eslint-disable-next-line unicorn/prefer-top-level-await
2928
runCLI(process.argv);

packages/webpack-cli/src/levenshtein.ts

Lines changed: 0 additions & 165 deletions
This file was deleted.

0 commit comments

Comments
 (0)