我試圖使用babel.transform
而不是JSXTranformer
作出反應。如何運行babel.transform與Nashorn進行反應?
...
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine nashorn = mgr.getEngineByName("nashorn");
nashorn.eval("var process = {env:{}}"); // node-modules expect that
nashorn.eval(getScript("com/facebook/babel/jvm-npm.js"));
babel = (JSObject) nashorn.eval("require('babel');");
...
巴別通天塔和核心安裝爲全球節點模塊,並且我得到了一個錯誤:
Testsuite: com.my.app.BabelTransformerTest
Cannot find module ./lib/api/node.js
Cannot load module babel-core LOAD_ERROR
Cannot load module babel LOAD_ERROR
Cannot load module babel-core LOAD_ERROR
Cannot load module babel LOAD_ERROR
Cannot find module ./lib/api/node.js
Cannot load module babel-core LOAD_ERROR
Cannot load module babel LOAD_ERROR
的./lib/api/node.js
是那裏的C:\Users\***\AppData\Roaming\npm\node_modules
我聽說,這是可能從Nashorn運行babel.transform
?
也許有隻加載某個babel模塊作爲JavaScript文件的方法嗎?
只是好奇,爲什麼你用nashorn而不是常規的Node.js? –
這是一個圖書館。爲更大的Java項目。我認爲是這樣的...... –