Closed moksamedia closed 3 years ago
Just noticed I got issue 666. Whoa. The demon issue. Haha.
Hello @moksamedia Did you take a look at https://github.com/lgrignon/j4ts-example ?
There are two ways to generate usable JavaScript code with JSweet.
bundle=true
, module=none
. This way you should be able to use it from a node project as a non-node bundle. Apparently that how Louis is doing in the j4ts example. @lgrignon btw, I am not sur how your example finds the j4ts runtime? Is it bundled altogether in the final bundle?bundle=false
, module=ES6
. It is supposed to work, but it is complicated because you need to configure your modules. I plan to work again on this feature soon, since I have an ongoing project that requests it. @renaudpawlak Do you mean module=ES6 or targetVersion=ES6?
@lgrignon I've looked at a number of different examples. All of them show how to build an entire Java application and transpile it into Javascript. I just want to build a self-contained API that I can use in an existing Node/Javascript codebase. How to do that is not super clear from that example.
If either of you have the time, I'd appreciate you looking at the project I'm working on to see if you see something obvious that needs to be fixed. I updated the j4ts.js
and myCandy.js
files to work more appropriately as modules (exporting the java object from the j4ts.js
file and passing it into the myCandy.js
file) and I'm on longer getting the java is not found
error, but now I get a new error: TypeError.
Here is the project: https://github.com/moksamedia/ewts-jsweet
I'm using a relatively older version of JSweet with Java 8 because when I tried to update it to the latest version, I was unable to get it to transpile without errors (EwtsConverter.java(32,53)[ts] 'const' declarations must be initialized
). Not sure why it worked with the older version and not the newer version.
This is the error:
TypeError: o1.compareTo is not a function
at NaturalComparator.compare (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/j4ts.js:2419:31)
at TreeMap.insert (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/j4ts.js:23838:38)
at TreeMap.put$java_lang_Object$java_lang_Object (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/j4ts.js:23524:34)
at TreeMap.put (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/j4ts.js:23516:33)
at Function.TransConverter.addMapping (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/myCandy.js:45:57)
at Function.TransConverter.init (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/myCandy.js:57:29)
at Function.TransConverter.__static_initializer_0 (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/myCandy.js:41:29)
at Function.TransConverter.__static_initialize (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/myCandy.js:17:29)
at Function.TransConverter.replMapEwtsToAlalc_$LI$ (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/myCandy.js:37:80)
at module.exports (/home/andrewcarterhughes/Development/jsweet-candy-quickstart/node/myCandy.js:2714:25)
I actually think I got it working. But I would love to figure out how to fix the error that crops up when I try and use the updated version of the transpiler. This error: EwtsConverter.java(32,53)[ts] 'const' declarations must be initialized
Hello,
I am trying to transpile a Java API (from this page) to a Javascript module that I can use in Node.
I've managed to get it to transpile without errors. However, when I import the module into a Node script, I keep getting
ReferenceError: java is not defined
errors.I tried manually requiring the
e4ts.js
distribution, but this doesn't seem to work. I also tried using the NPM dependency.What is the correct way to go about this?
My goal is to transpile the Java APIs to Javascript APIs that I can use in a node project and Vue.js client.
Thanks for your time.
Java version 1.8 Node version 12.14
Here is my
pom.xml