Skip to content

Commit 2403a36

Browse files
authored
Merge pull request #16345 from ahabhgk/fix-eval-nosources
fix: `devtool: 'eval-nosources-*'` still contains sourcesContent
2 parents fcccd19 + 1fd8bc5 commit 2403a36

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

lib/EvalSourceMapDevToolPlugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ class EvalSourceMapDevToolPlugin {
153153
}
154154
);
155155
sourceMap.sources = moduleFilenames;
156+
if (options.noSources) {
157+
sourceMap.sourcesContent = undefined;
158+
}
156159
sourceMap.sourceRoot = options.sourceRoot || "";
157160
const moduleId = chunkGraph.getModuleId(m);
158161
sourceMap.file = `${moduleId}.js`;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
it("should not include sourcesContent if noSources option is used", function() {
2+
var fs = require("fs");
3+
var source = fs.readFileSync(__filename, "utf-8");
4+
var match = /\/\/# sourceMappingURL\s*=\s*data:application\/json;charset=utf-8;base64,(.*)\\n\/\/#/.exec(source);
5+
var mapString = Buffer.from(match[1], 'base64').toString('utf-8');
6+
var map = JSON.parse(mapString);
7+
expect(map).not.toHaveProperty("sourcesContent");
8+
});
9+
10+
if (Math.random() < 0) require("./test.js");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var foo = {};
2+
3+
module.exports = foo;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import("../../../../").Configuration} */
2+
module.exports = {
3+
devtool: "eval-nosources-source-map"
4+
};

0 commit comments

Comments
 (0)