Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run standalone compiler from babel-core in Rhino JavaScript engine #2537

Closed
jochenberger opened this issue Oct 14, 2015 · 2 comments · Fixed by #13448
Closed

Cannot run standalone compiler from babel-core in Rhino JavaScript engine #2537

jochenberger opened this issue Oct 14, 2015 · 2 comments · Fixed by #13448
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@jochenberger
Copy link
Contributor

@Grab(group='org.mozilla', module='rhino', version='1.7.7')
import org.mozilla.javascript.Context
import org.mozilla.javascript.ContextFactory
import org.mozilla.javascript.ScriptableObject

ContextFactory contextFactory = new ContextFactory()
Context context = contextFactory.enterContext()
context.setOptimizationLevel(-1)
ScriptableObject scope = context.initStandardObjects()

new URL('https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.25/browser.js').withReader {
  context.evaluateReader(scope, it, "browser.js", 1, null)
}

leads to

org.mozilla.javascript.EcmaError: TypeError: Expected argument of type object, but instead had type object (browser.js#56462)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3951)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3929)
    at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3962)
    at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3974)
    at org.mozilla.javascript.ScriptableObject.ensureScriptable(ScriptableObject.java:2078)
    at org.mozilla.javascript.NativeObject.execIdCall(NativeObject.java:275)
    at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:101)
    at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1479)
    at script(browser.js:56462)
    at script.toType(browser.js:56399)
    at script(browser.js:56430)
    at script(browser.js:53410)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:57061)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:53038)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:53194)
    at script(browser.js:53193)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:45886)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:46294)
    at script(browser.js:46279)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:22728)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:21669)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:13974)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:5941)
    at script.s(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:5787)
    at script(browser.js:5782)
    at script.s(browser.js:2)
    at script.e(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:2)
    at script(browser.js:2)
    at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815)
    at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3282)
    at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:120)
    at org.mozilla.javascript.Context.evaluateReader(Context.java:1250)
    at org.mozilla.javascript.Context$evaluateReader$1.call(Unknown Source)
    at babel$_run_closure1.doCall(babel.groovy:13)
    at babel.run(babel.groovy:11)

If I wrap the code in fromObject in a try-catch block, it seems that the object in question is null. I'm still trying to collect more information.

@jamiebuilds
Copy link
Contributor

Babel only supports Node and the latest browsers.

@jochenberger
Copy link
Contributor Author

Just for the record, this is caused by mozilla/rhino#233.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 11, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants