Merge pull request #11133 from webpack/bugfix/missing-snapshot
handle case when no snapshot can be created in ResolverCachePlugin
This commit is contained in:
commit
c1c4b47e73
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import value from "package";
|
||||
|
||||
it("should not crash", () => {
|
||||
expect(value).toBe(42 + WATCH_STEP);
|
||||
});
|
1
test/watchCases/snapshot/unable-to-snapshot/0/node_modules/package/changing-file.js
generated
vendored
Normal file
1
test/watchCases/snapshot/unable-to-snapshot/0/node_modules/package/changing-file.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = "0";
|
2
test/watchCases/snapshot/unable-to-snapshot/0/node_modules/package/index.js
generated
vendored
Normal file
2
test/watchCases/snapshot/unable-to-snapshot/0/node_modules/package/index.js
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
import other from "./changing-file";
|
||||
export default 42 + other;
|
1
test/watchCases/snapshot/unable-to-snapshot/1/node_modules/package/changing-file.js
generated
vendored
Normal file
1
test/watchCases/snapshot/unable-to-snapshot/1/node_modules/package/changing-file.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = "1";
|
1
test/watchCases/snapshot/unable-to-snapshot/2/node_modules/package/changing-file.js
generated
vendored
Normal file
1
test/watchCases/snapshot/unable-to-snapshot/2/node_modules/package/changing-file.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = "2";
|
|
@ -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")]
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue