Move default setJSRunner from mjs to index
This commit is contained in:
parent
6823b23ac4
commit
70db60a360
|
@ -1,3 +1,4 @@
|
|||
const vm = require("vm")
|
||||
const handlebars = require("handlebars")
|
||||
const { registerAll, registerMinimum } = require("./helpers/index")
|
||||
const processors = require("./processors")
|
||||
|
@ -402,3 +403,19 @@ const errors = require("./errors")
|
|||
module.exports.JsErrorTimeout = errors.JsErrorTimeout
|
||||
|
||||
module.exports.helpersToRemoveForJs = helpersToRemoveForJs
|
||||
|
||||
if (process && !process.env.NO_JS) {
|
||||
/**
|
||||
* Use polyfilled vm to run JS scripts in a browser Env
|
||||
*/
|
||||
javascript.setJSRunner((js, context) => {
|
||||
context = {
|
||||
...context,
|
||||
alert: undefined,
|
||||
setInterval: undefined,
|
||||
setTimeout: undefined,
|
||||
}
|
||||
vm.createContext(context)
|
||||
return vm.runInNewContext(js, context, { timeout: 1000 })
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import vm from "vm"
|
||||
import templates from "./index.js"
|
||||
|
||||
/**
|
||||
|
@ -24,20 +23,4 @@ export const setOnErrorLog = templates.setOnErrorLog
|
|||
export const FIND_ANY_HBS_REGEX = templates.FIND_ANY_HBS_REGEX
|
||||
export const helpersToRemoveForJs = templates.helpersToRemoveForJs
|
||||
|
||||
if (process && !process.env.NO_JS) {
|
||||
/**
|
||||
* Use polyfilled vm to run JS scripts in a browser Env
|
||||
*/
|
||||
setJSRunner((js, context) => {
|
||||
context = {
|
||||
...context,
|
||||
alert: undefined,
|
||||
setInterval: undefined,
|
||||
setTimeout: undefined,
|
||||
}
|
||||
vm.createContext(context)
|
||||
return vm.runInNewContext(js, context, { timeout: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
export * from "./errors.js"
|
||||
|
|
Loading…
Reference in New Issue