You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you try to use Browserify to build a javascript bundle that calls require() to include a JSON file that contains a U+2028 (line separator) or U+2029 (paragraph separator) character, then Browserify throws an exception.
U+2028 and U+2029 characters are both valid inside strings in JSON, but not in javascript. JSON is not perfectly a Javascript subset. When Browserify transforms JSON files to javascript by prepending module.exports=, it also needs to transform all U+2028/9 characters (which would only be present inside strings) to \u2028 and \u2029. A well-placed .replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029'); should do the trick.
If you try to use Browserify to build a javascript bundle that calls require() to include a JSON file that contains a U+2028 (line separator) or U+2029 (paragraph separator) character, then Browserify throws an exception.
U+2028 and U+2029 characters are both valid inside strings in JSON, but not in javascript. JSON is not perfectly a Javascript subset. When Browserify transforms JSON files to javascript by prepending
module.exports=
, it also needs to transform all U+2028/9 characters (which would only be present inside strings) to\u2028
and\u2029
. A well-placed.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
should do the trick.Here's an example repo showing the issue: https://github.com/AgentME/br-json-test
The text was updated successfully, but these errors were encountered: