Skip to content

Commit

Permalink
chrome workaround for eval-source-maps
Browse files Browse the repository at this point in the history
breakpoints now work fine
  • Loading branch information
sokra committed Jul 12, 2017
1 parent 2b26cbb commit ab9f6ee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/EvalSourceMapDevToolModuleTemplatePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
class EvalSourceMapDevToolModuleTemplatePlugin {
constructor(compilation, options) {
this.compilation = compilation;
this.sourceMapComment = options.append || "//# sourceMappingURL=[url]";
this.sourceMapComment = options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resource-path]?[hash]";
this.options = options;
}
Expand Down Expand Up @@ -61,13 +61,14 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
sourceMap.sourceRoot = options.sourceRoot || "";
sourceMap.file = `${module.id}.js`;

const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`); //eslint-disable-line
const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`) + //eslint-disable-line
`\n//# sourceURL=webpack-internal:///${module.id}\n`; // workaround for chrome bug
source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`);
return source.__EvalSourceMapDevToolData;
});
moduleTemplate.plugin("hash", function(hash) {
hash.update("eval-source-map");
hash.update("1");
hash.update("2");
});
}
}
Expand Down

0 comments on commit ab9f6ee

Please sign in to comment.