mirror of https://github.com/webpack/webpack.git
Fix - Exits abruptly when invalid JSON
This commit is contained in:
parent
e5ee3be827
commit
ab1d79bda2
|
|
@ -6,11 +6,17 @@
|
|||
|
||||
const { ConcatSource } = require("webpack-sources");
|
||||
|
||||
const stringifySafe = data =>
|
||||
JSON.stringify(data).replace(
|
||||
const stringifySafe = data => {
|
||||
const stringified = JSON.stringify(data);
|
||||
if (!stringified) {
|
||||
return undefined; // Invalid JSON
|
||||
}
|
||||
|
||||
return stringified.replace(
|
||||
/\u2028|\u2029/g,
|
||||
str => (str === "\u2029" ? "\\u2029" : "\\u2028")
|
||||
); // invalid in JavaScript but valid JSON
|
||||
};
|
||||
|
||||
class JsonGenerator {
|
||||
generate(module, dependencyTemplates, runtimeTemplate) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue