Skip to content

Commit 3c77f03

Browse files
authored
Merge pull request webpack#6154 from EugeneHlushko/feature/use-webpack-missing-module
Feature: Use WebpackMissingModule
2 parents d434a01 + 9355b5c commit 3c77f03

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

lib/MultiModule.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ class MultiModule extends Module {
6060
str.push(`${JSON.stringify(dep.module.id)}`);
6161
str.push(")");
6262
} else {
63-
// TODO replace with WebpackMissingModule module
64-
str.push("(function webpackMissingModule() { throw new Error(");
65-
str.push(JSON.stringify(`Cannot find module "${dep.request}"`));
66-
str.push("); }())");
63+
const content = require("./dependencies/WebpackMissingModule").module(dep.request);
64+
str.push(content);
6765
}
6866
str.push(";\n");
6967
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
it("Should use WebpackMissingModule when module is missing with multiple entry setup", function() {
2+
var fs = require("fs");
3+
var path = require("path");
4+
var source = fs.readFileSync(path.join(__dirname, "b.js"), "utf-8");
5+
source.should.containEql("!function(){var n=new Error('Cannot find module \"./intentionally-missing-module.js\"');throw n.code=\"MODULE_NOT_FOUND\",n}()}");
6+
7+
(function() {
8+
require("./intentionally-missing-module");
9+
}).should.throw("Cannot find module \"./intentionally-missing-module\"");
10+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "ignored";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const IgnorePlugin = require("../../../../lib/IgnorePlugin");
2+
module.exports = {
3+
entry: {
4+
b: ["./intentionally-missing-module.js"],
5+
bundle0: ["./index"]
6+
},
7+
output: {
8+
filename: "[name].js"
9+
},
10+
plugins: [
11+
new IgnorePlugin(new RegExp(/intentionally-missing-module/))
12+
],
13+
node: {
14+
__dirname: false
15+
}
16+
};

0 commit comments

Comments
 (0)