mirror of https://github.com/webpack/webpack.git
Merge fad1bc1f32
into 8804459884
This commit is contained in:
commit
886ce7106e
|
@ -376,7 +376,9 @@ class LazyCompilationPlugin {
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
/** @type {BackendApi} */
|
/** @type {BackendApi} */
|
||||||
let backend;
|
let backend;
|
||||||
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, (params, callback) => {
|
compiler.hooks.beforeCompile.tapAsync(
|
||||||
|
PLUGIN_NAME,
|
||||||
|
(/** @type {any} */ params, /** @type {(err?: Error | null) => void} */ callback) => {
|
||||||
if (backend !== undefined) return callback();
|
if (backend !== undefined) return callback();
|
||||||
const promise = this.backend(compiler, (err, result) => {
|
const promise = this.backend(compiler, (err, result) => {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
@ -389,15 +391,25 @@ class LazyCompilationPlugin {
|
||||||
callback();
|
callback();
|
||||||
}, callback);
|
}, callback);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
compiler.hooks.thisCompilation.tap(
|
compiler.hooks.thisCompilation.tap(
|
||||||
PLUGIN_NAME,
|
PLUGIN_NAME,
|
||||||
|
/**
|
||||||
|
* @param {import("../Compilation")} compilation
|
||||||
|
* @param {{ normalModuleFactory: import("../NormalModuleFactory") }} param1
|
||||||
|
*/
|
||||||
(compilation, { normalModuleFactory }) => {
|
(compilation, { normalModuleFactory }) => {
|
||||||
normalModuleFactory.hooks.module.tap(
|
normalModuleFactory.hooks.module.tap(
|
||||||
PLUGIN_NAME,
|
PLUGIN_NAME,
|
||||||
|
/**
|
||||||
|
* @param {Module} module
|
||||||
|
* @param {*} createData
|
||||||
|
* @param {*} resolveData
|
||||||
|
*/
|
||||||
(module, createData, resolveData) => {
|
(module, createData, resolveData) => {
|
||||||
if (
|
if (
|
||||||
resolveData.dependencies.every((dep) =>
|
resolveData.dependencies.every((dep: any) =>
|
||||||
HMR_DEPENDENCY_TYPES.has(dep.type)
|
HMR_DEPENDENCY_TYPES.has(dep.type)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@ -457,7 +469,7 @@ class LazyCompilationPlugin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
compiler.hooks.shutdown.tapAsync(PLUGIN_NAME, (callback) => {
|
compiler.hooks.shutdown.tapAsync(PLUGIN_NAME, (callback: (...args: any[]) => void) => {
|
||||||
backend.dispose(callback);
|
backend.dispose(callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue