Skip to content

Commit

Permalink
Merge pull request #9492 from nveenjain/fix/AutomaticPrefetchPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 13, 2021
2 parents 3ef285b + 684d375 commit 9b53ae5
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/AutomaticPrefetchPlugin.js
Expand Up @@ -45,7 +45,7 @@ class AutomaticPrefetchPlugin {
(m, callback) => {
compilation.addModuleChain(
m.context || compiler.context,
new PrefetchDependency(m.request),
new PrefetchDependency(`!!${m.request}`),
callback
);
},
Expand Down
@@ -0,0 +1 @@
})]
@@ -0,0 +1 @@
module.exports = '0';
@@ -0,0 +1 @@
module.exports = "This ";
@@ -0,0 +1 @@
module.exports = "is only ";
@@ -0,0 +1 @@
module.exports = "a test";
10 changes: 10 additions & 0 deletions test/watchCases/plugins/automatic-prefetch-plugin-9485/0/index.js
@@ -0,0 +1,10 @@
it("should watch for changes", function () {
if (+WATCH_STEP !== 3) expect(require("./delayed")).toBe(WATCH_STEP);
else expect(require("./delayed")).toBe("This is only a test." + WATCH_STEP);
if (+WATCH_STEP > 0) {
for (var m of STATS_JSON.modules.filter(m =>
/(a|b|c)\.js$/.test(m.identifier)
))
expect(m.issuer).toBe(null);
}
});
@@ -0,0 +1 @@
module.exports = '1';
@@ -0,0 +1 @@
module.exports = '2';
@@ -0,0 +1,5 @@
var a = require("./a");
var b = require("./b");
var c = require("./c");

module.exports = a + b + c + '.3';
@@ -0,0 +1,9 @@
module.exports = function (source) {
expect(source).toMatch(/^\}\)\]/);
this.cacheable(false);
return new Promise(resolve => {
setTimeout(() => {
resolve("module.exports = require('./foo/' + WATCH_STEP);");
}, 500);
});
};
@@ -0,0 +1,15 @@
const path = require("path");
const webpack = require("../../../../");

/** @type {import("../../../../").Configuration} */
module.exports = {
module: {
rules: [
{
test: /delayed/,
use: path.resolve(__dirname, "./delayed")
}
]
},
plugins: [new webpack.AutomaticPrefetchPlugin()]
};

0 comments on commit 9b53ae5

Please sign in to comment.