Skip to content

Commit

Permalink
Merge pull request #8639 from webpack/memory/limit-parallelism
Browse files Browse the repository at this point in the history
Change forEach to forEachLimit when emitting assets
  • Loading branch information
sokra committed Jan 16, 2019
2 parents 2b2c17f + 80514cc commit 03ffa48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ declare module "neo-async" {
callback?: ErrorCallback<E>
): void;

export function eachLimit<T, E>(
arr: IterableCollection<T>,
limit: number,
iterator: AsyncIterator<T, E>,
callback?: ErrorCallback<E>
): void;

export function map<T, R, E>(
arr: T[] | IterableIterator<T>,
iterator: AsyncResultIterator<T, R, E>,
Expand All @@ -98,6 +105,7 @@ declare module "neo-async" {
): void;

export const forEach: typeof each;
export const forEachLimit: typeof eachLimit;
}

// There are no typings for @webassemblyjs/ast
Expand Down
3 changes: 2 additions & 1 deletion lib/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ class Compiler extends Tapable {
const emitFiles = err => {
if (err) return callback(err);

asyncLib.forEach(
asyncLib.forEachLimit(
compilation.assets,
15,
(source, file, callback) => {
let targetFile = file;
const queryStringIdx = targetFile.indexOf("?");
Expand Down

0 comments on commit 03ffa48

Please sign in to comment.