fix cache invalidation in progress plugin
This commit is contained in:
parent
a72548f970
commit
bb7ed40f46
|
@ -331,6 +331,7 @@ class ProgressPlugin {
|
||||||
.getItemCache("counts", null);
|
.getItemCache("counts", null);
|
||||||
|
|
||||||
let cacheGetPromise;
|
let cacheGetPromise;
|
||||||
|
let invalidatedCache = false;
|
||||||
|
|
||||||
compiler.hooks.beforeCompile.tap("ProgressPlugin", () => {
|
compiler.hooks.beforeCompile.tap("ProgressPlugin", () => {
|
||||||
if (!cacheGetPromise) {
|
if (!cacheGetPromise) {
|
||||||
|
@ -348,10 +349,16 @@ class ProgressPlugin {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
invalidatedCache = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
compiler.cache.hooks.store.tap("ProgressPlugin", () => {
|
||||||
|
invalidatedCache = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
compiler.hooks.afterCompile.tapPromise("ProgressPlugin", compilation => {
|
compiler.hooks.afterCompile.tapPromise("ProgressPlugin", compilation => {
|
||||||
if (compilation.compiler.isChild()) return Promise.resolve();
|
if (compilation.compiler.isChild() || !invalidatedCache)
|
||||||
|
return Promise.resolve();
|
||||||
return cacheGetPromise.then(async oldData => {
|
return cacheGetPromise.then(async oldData => {
|
||||||
if (
|
if (
|
||||||
!oldData ||
|
!oldData ||
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
data
|
|
@ -0,0 +1,5 @@
|
||||||
|
import url from "./loader!!";
|
||||||
|
|
||||||
|
it("should compile and run", () => {
|
||||||
|
expect(url).toBe("webpack:///a.txt");
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
/** @type {import("../../../../").LoaderDefinitionFunction} */
|
||||||
|
module.exports = function () {
|
||||||
|
const callback = this.async();
|
||||||
|
this.importModule("./module1", { baseUri: "webpack://" }, (err, exports) => {
|
||||||
|
if (err) return callback(err);
|
||||||
|
callback(null, `module.exports = ${JSON.stringify(exports.url)}`);
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
const url = new URL("./a.txt", import.meta.url);
|
||||||
|
|
||||||
|
export { url }
|
|
@ -0,0 +1,9 @@
|
||||||
|
const webpack = require("../../../../");
|
||||||
|
|
||||||
|
/** @type {import("../../../../").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
output: {
|
||||||
|
assetModuleFilename: "[name][ext]"
|
||||||
|
},
|
||||||
|
plugins: [new webpack.ProgressPlugin(() => {})]
|
||||||
|
};
|
Loading…
Reference in New Issue