Skip to content

Commit 59d9b9f

Browse files
committed
EvalSourceMapDevToolPlugin: add ability to filter which modules get sourcemapped
see: webpack#6450 This is useful to filter out stuff you don't care about or stuff that's very large and screws up with devtools.
1 parent 6056775 commit 59d9b9f

5 files changed

Lines changed: 41 additions & 0 deletions

File tree

lib/EvalSourceMapDevToolModuleTemplatePlugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
1919
apply(moduleTemplate) {
2020
const self = this;
2121
const options = this.options;
22+
const matchModule = ModuleFilenameHelpers.matchObject.bind(ModuleFilenameHelpers, options);
2223
moduleTemplate.hooks.module.tap("EvalSourceMapDevToolModuleTemplatePlugin", (source, module) => {
2324
if(source.__EvalSourceMapDevToolData)
2425
return source.__EvalSourceMapDevToolData;
26+
if(!matchModule(module.resource)) {
27+
return source;
28+
}
29+
2530
let sourceMap;
2631
let content;
2732
if(source.sourceAndMap) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
it("bundle1 should include eval sourcemapped test1.js and test2.js as is", function() {
2+
var fs = require("fs");
3+
var path = require("path");
4+
var bundle1 = fs.readFileSync(path.join(__dirname, "bundle1.js"), "utf-8");
5+
bundle1.should.containEql("eval(\"var test1marker");
6+
bundle1.should.containEql("var test2marker");
7+
bundle1.should.not.containEql("eval(\"var test2marker");
8+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var test1marker = {};
2+
3+
module.exports = test1marker;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var test2marker = {};
2+
3+
module.exports = test2marker;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var webpack = require("../../../../");
2+
module.exports = {
3+
node: {
4+
__dirname: false,
5+
__filename: false
6+
},
7+
entry: {
8+
bundle0: ["./index.js"],
9+
bundle1: ["./test1.js", "./test2.js"]
10+
},
11+
output: {
12+
filename: "[name].js"
13+
},
14+
plugins: [
15+
new webpack.EvalSourceMapDevToolPlugin({
16+
include: /\.js$/,
17+
exclude: /test2\.js/,
18+
module: true,
19+
columns: false
20+
})
21+
]
22+
};

0 commit comments

Comments
 (0)