Skip to content

Commit

Permalink
Revert "Remove SafeJSON."
Browse files Browse the repository at this point in the history
This reverts commit 713171e.
  • Loading branch information
jdalton committed Mar 15, 2019
1 parent c0aad80 commit 5947eb4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 42 deletions.
10 changes: 3 additions & 7 deletions src/module/esm/extensions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import SafeJSON from "../../safe/json.js"

import { dlopen } from "../../safe/process.js"
import { readFileSync } from "../../safe/fs.js"
import stripBOM from "../../util/strip-bom.js"
import toExternalError from "../../util/to-external-error.js"
import toExternalObject from "../../util/to-external-object.js"
import toNamespacedPath from "../../path/to-namespaced-path.js"

const extensions = { __proto__: null }
Expand All @@ -17,17 +17,13 @@ extensions[".json"] = function (mod, filename) {
let exported

try {
exported = JSON.parse(content)
exported = SafeJSON.parse(content)
} catch (e) {
e.message = filename + ": " + e.message

toExternalError(e)

throw e
}

toExternalObject(exported)

mod.exports = exported
}

Expand Down
6 changes: 2 additions & 4 deletions src/module/internal/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Entry from "../../entry.js"
import GenericObject from "../../generic/object.js"
import Loader from "../../loader.js"
import Runtime from "../../runtime.js"
import SafeJSON from "../../safe/json.js"

import assign from "../../util/assign.js"
import captureStackTrace from "../../error/capture-stack-trace.js"
Expand All @@ -36,7 +37,6 @@ import shared from "../../shared.js"
import stripBOM from "../../util/strip-bom.js"
import toExternalError from "../../util/to-external-error.js"
import toExternalFunction from "../../util/to-external-function.js"
import toExternalObject from "../../util/to-external-object.js"
import toString from "../../util/to-string.js"

const {
Expand Down Expand Up @@ -596,8 +596,7 @@ function jsonParse(entry, filename, fallback) {
fallback()
parsed = mod.exports
} else {
parsed = JSON.parse(content)
toExternalObject(parsed)
parsed = SafeJSON.parse(content)
}

threw = false
Expand All @@ -606,7 +605,6 @@ function jsonParse(entry, filename, fallback) {

if (! useFallback) {
error.message = filename + ": " + error.message
toExternalError(error)
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/safe/json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import safe from "../util/safe.js"
import shared from "../shared.js"

export default shared.inited
? shared.module.safeJSON
: shared.module.safeJSON = safe(shared.external.JSON)
28 changes: 0 additions & 28 deletions src/util/to-external-object.js

This file was deleted.

6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ const isProd = /production/.test(ESM_ENV)
const isTest = /test/.test(ESM_ENV)

const externals = [
"Array", "Buffer", "Error", "EvalError", "Function", "Object", "Promise",
"RangeError", "ReferenceError", "Reflect", "SyntaxError", "TypeError",
"URIError", "eval"
"Array", "Buffer", "Error", "EvalError", "Function", "JSON", "Object",
"Promise", "RangeError", "ReferenceError", "Reflect", "SyntaxError",
"TypeError", "URIError", "eval"
]

const hosted = [
Expand Down

0 comments on commit 5947eb4

Please sign in to comment.