Skip to content

Commit

Permalink
Merge pull request #16345 from ahabhgk/fix-eval-nosources
Browse files Browse the repository at this point in the history
fix: `devtool: 'eval-nosources-*'` still contains sourcesContent
  • Loading branch information
sokra committed Nov 9, 2022
2 parents fcccd19 + 1fd8bc5 commit 2403a36
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/EvalSourceMapDevToolPlugin.js
Expand Up @@ -153,6 +153,9 @@ class EvalSourceMapDevToolPlugin {
}
);
sourceMap.sources = moduleFilenames;
if (options.noSources) {
sourceMap.sourcesContent = undefined;
}
sourceMap.sourceRoot = options.sourceRoot || "";
const moduleId = chunkGraph.getModuleId(m);
sourceMap.file = `${moduleId}.js`;
Expand Down
10 changes: 10 additions & 0 deletions test/configCases/devtools/eval-nosources-source-map/index.js
@@ -0,0 +1,10 @@
it("should not include sourcesContent if noSources option is used", function() {
var fs = require("fs");
var source = fs.readFileSync(__filename, "utf-8");
var match = /\/\/# sourceMappingURL\s*=\s*data:application\/json;charset=utf-8;base64,(.*)\\n\/\/#/.exec(source);
var mapString = Buffer.from(match[1], 'base64').toString('utf-8');
var map = JSON.parse(mapString);
expect(map).not.toHaveProperty("sourcesContent");
});

if (Math.random() < 0) require("./test.js");
3 changes: 3 additions & 0 deletions test/configCases/devtools/eval-nosources-source-map/test.js
@@ -0,0 +1,3 @@
var foo = {};

module.exports = foo;
@@ -0,0 +1,4 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
devtool: "eval-nosources-source-map"
};

0 comments on commit 2403a36

Please sign in to comment.