Fix Compiler.hooks.make callbacks

This commit is contained in:
Florent Cailhol 2018-12-17 21:35:39 +01:00 committed by Tobias Koppers
parent 9d4d2bfde8
commit f860c870ac
4 changed files with 16 additions and 6 deletions

View File

@ -528,9 +528,10 @@ class Chunk {
/**
* @param {ChunkGraph} chunkGraph the chunk graph
* @returns {Record<string, Set<TODO>[]>} a record object of names to lists of child ids(?)
* @returns {Record<string, Set<string | number>[]>} a record object of names to lists of child ids(?)
*/
getChildIdsByOrders(chunkGraph) {
/** @type {Map<string, {order: number, group: ChunkGroup}[]>} */
const lists = new Map();
for (const group of this.groupsIterable) {
if (group.chunks[group.chunks.length - 1] === this) {
@ -539,7 +540,10 @@ class Chunk {
if (key.endsWith("Order")) {
const name = key.substr(0, key.length - "Order".length);
let list = lists.get(name);
if (list === undefined) lists.set(name, (list = []));
if (list === undefined) {
list = [];
lists.set(name, list);
}
list.push({
order: childGroup.options[key],
group: childGroup
@ -571,7 +575,7 @@ class Chunk {
/**
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {boolean=} includeDirectChildren include direct children (by default only children of async children are included)
* @returns {Record<string|number, Record<string, Set<TODO>[]>>} a record object of names to lists of child ids(?) by chunk id
* @returns {Record<string|number, Record<string, Set<string | number>[]>>} a record object of names to lists of child ids(?) by chunk id
*/
getChildIdsByOrdersMap(chunkGraph, includeDirectChildren) {
const chunkMaps = Object.create(null);

View File

@ -55,6 +55,7 @@ const createHash = require("./util/createHash");
const { arrayToSetDeprecation } = require("./util/deprecation");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").OutputOptions} OutputOptions */
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
@ -2531,7 +2532,7 @@ class Compilation {
* from parent (or top level compiler) and creates a child Compilation
*
* @param {string} name name of the child compiler
* @param {TODO} outputOptions // Need to convert config schema to types for this
* @param {OutputOptions} outputOptions // Need to convert config schema to types for this
* @param {Plugin[]} plugins webpack plugins that will be applied
* @returns {Compiler} creates a child Compiler instance
*/

View File

@ -43,7 +43,9 @@ class EntryPlugin {
const { entry, name, context } = this;
const dep = EntryPlugin.createDependency(entry, name);
compilation.addEntry(context, dep, name, callback);
compilation.addEntry(context, dep, name, err => {
callback(err);
});
});
}

View File

@ -39,9 +39,12 @@ class PrefetchPlugin {
compilation.addModuleChain(
this.context || compiler.context,
new PrefetchDependency(this.request),
callback
err => {
callback(err);
}
);
});
}
}
module.exports = PrefetchPlugin;