I am currently maintaining https://github.com/mobily-enterprises/js-interpreter. It's available on npm as js-interpreter-npm. All it does, it repackage acorn.js and js-interpreter.js, but adding this at the BEGINNING of js-interpreter.js:
var globalThis
if (typeof exports === 'undefined') {
globalThis = window
} else {
globalThis = exports
globalThis.acorn = require('./acorn.js')
// This is important as JS-Interpreter assumes that the "global" scope
// includes primitive variable types
globalThis.String = String
globalThis.Date = Date
globalThis.Boolean = Boolean
globalThis.Number = Number
globalThis.RegExp = RegExp
}
This essentially makes sure that the module works 100% both when loaded in the browser, and when it's "required" by node.
Please note that I had to add those primitive data types to the "global scope" for node.
It is a bit of a hack, but it works. Please note that I carefully avoided complex "building" steps with webpack, etc.
I would love some input on this. Really, I just have a question:
-
are you guys willing to include some changes so that js-interpreter is ready for node, rather than people using my silly wrapper that becomes outdated as you go further with development?
-
are you guys willing and happy to publish to NPM, if you do go with (1)?
I am currently maintaining https://github.com/mobily-enterprises/js-interpreter. It's available on npm as
js-interpreter-npm. All it does, it repackage acorn.js andjs-interpreter.js, but adding this at the BEGINNING ofjs-interpreter.js:This essentially makes sure that the module works 100% both when loaded in the browser, and when it's "required" by node.
Please note that I had to add those primitive data types to the "global scope" for node.
It is a bit of a hack, but it works. Please note that I carefully avoided complex "building" steps with webpack, etc.
I would love some input on this. Really, I just have a question:
are you guys willing to include some changes so that js-interpreter is ready for node, rather than people using my silly wrapper that becomes outdated as you go further with development?
are you guys willing and happy to publish to NPM, if you do go with (1)?