handle case when no snapshot can be created in ResolverCachePlugin

This commit is contained in:
Tobias Koppers 2020-07-07 17:38:03 +02:00
parent 20ba3c0780
commit cfb52451d4
8 changed files with 29 additions and 1 deletions

View File

@ -170,6 +170,10 @@ class ResolverCachePlugin {
null,
(err, snapshot) => {
if (err) return callback(err);
if (!snapshot) {
if (result) return callback(null, result);
return callback();
}
cache.store(
identifier,
null,

View File

@ -7,6 +7,7 @@ const rimraf = require("rimraf");
const checkArrayExpectation = require("./checkArrayExpectation");
const createLazyTestEnv = require("./helpers/createLazyTestEnv");
const { remove } = require("./helpers/remove");
const prepareOptions = require("./helpers/prepareOptions");
const webpack = require("..");
@ -114,7 +115,12 @@ describe("WatchTestCases", () => {
let options = {};
const configPath = path.join(testDirectory, "webpack.config.js");
if (fs.existsSync(configPath)) options = require(configPath);
if (fs.existsSync(configPath)) {
options = prepareOptions(require(configPath), {
testPath: outputDirectory,
srcPath: tempDirectory
});
}
const applyConfig = options => {
if (!options.mode) options.mode = "development";
if (!options.context) options.context = tempDirectory;

View File

@ -0,0 +1,5 @@
import value from "package";
it("should not crash", () => {
expect(value).toBe(42 + WATCH_STEP);
});

View File

@ -0,0 +1 @@
module.exports = "0";

View File

@ -0,0 +1,2 @@
import other from "./changing-file";
export default 42 + other;

View File

@ -0,0 +1 @@
module.exports = "1";

View File

@ -0,0 +1 @@
module.exports = "2";

View File

@ -0,0 +1,8 @@
const path = require("path");
/** @type {function(any, any): import("../../../../").Configuration} */
module.exports = (env, { srcPath }) => ({
cache: {
type: "memory",
managedPaths: [path.resolve(srcPath, "node_modules")]
}
});