Skip to content

Commit

Permalink
perf: simplify logic, reduce extra loops and perf (#3767)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored May 7, 2023
1 parent 10165f8 commit 6afe1d3
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 144 deletions.
4 changes: 2 additions & 2 deletions packages/serve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class ServeCommand {
for (const path in problemsByPath) {
const problems = problemsByPath[path];

problems.forEach((problem: Problem) => {
for (const problem of problems) {
cli.logger.error(
`${cli.capitalizeFirstLetter(problem.type.replace(/-/g, " "))}${
problem.value ? ` '${problem.value}'` : ""
Expand All @@ -205,7 +205,7 @@ class ServeCommand {
if (problem.expected) {
cli.logger.error(`Expected: '${problem.expected}'`);
}
});
}
}

process.exit(2);
Expand Down
8 changes: 1 addition & 7 deletions packages/webpack-cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ interface WebpackCLIConfig {
interface WebpackCLICommand extends Command {
pkg: string | undefined;
forHelp: boolean | undefined;
options: WebpackCLICommandOption[];
_args: WebpackCLICommandOption[];
}

Expand Down Expand Up @@ -187,10 +186,7 @@ type Callback<T extends unknown[]> = (...args: T) => void;
/**
* Webpack
*/
type WebpackConfiguration = Configuration & {
// TODO add extends to webpack types
extends?: string | string[];
};
type WebpackConfiguration = Configuration;
type ConfigOptions = PotentialPromise<WebpackConfiguration | CallableOption>;
type CallableOption = (env: Env | undefined, argv: Argv) => WebpackConfiguration;
type WebpackCompiler = Compiler | MultiCompiler;
Expand All @@ -209,7 +205,6 @@ type FileSystemCacheOptions = WebpackConfiguration & {

type ProcessedArguments = Record<string, BasicPrimitive | RegExp | (BasicPrimitive | RegExp)[]>;

type MultipleCompilerStatsOptions = StatsOptions & { children: StatsOptions[] };
type CommandAction = Parameters<WebpackCLICommand["action"]>[0];

interface WebpackRunOptions extends WebpackOptionsNormalized {
Expand Down Expand Up @@ -339,7 +334,6 @@ export {
Instantiable,
JsonExt,
ModuleName,
MultipleCompilerStatsOptions,
PackageInstallOptions,
PackageManager,
Path,
Expand Down
Loading

0 comments on commit 6afe1d3

Please sign in to comment.