Open dsyer opened 2 years ago
The web server we use on samples are coming from https://github.com/bazelbuild/rules_closure/blob/master/closure/webfiles/web_library.bzl
I don't recall it providing a mechanism to customize address but you can dig into there and see if there is already a way, or propose change to expose it.
If this is only about ipv6 issue, I can change the default one and see if it works in all test environments.
(BTW, pls note that the web server there is quite bit hacky, unsafe and definitely not intended for complex usages even for development)
I want to be able to change the port as well, so I guess I'll have a look at that web_library definition. TBH I'd rather not use Bazel at all just for building sample apps. Is there an alternative? Like a CLI that I can use to compile the WASM and other generated code?
Bazel can produce a J2clTranspiler binary that you can run outside of bazel as a command line tool.
Running bazel build //transpiler/java/com/google/j2cl/transpiler:J2clCommandLineRunner
will produce a script bazel-bin/transpiler/java/com/google/j2cl/transpiler/J2clCommandLineRunner
which can be run from the command line
Also, running bazel build //transpiler/java/com/google/j2cl/transpiler:J2clCommandLineRunner_deploy.jar
will produce a jar bazel-bin/transpiler/java/com/google/j2cl/transpiler/J2clCommandLineRunner_deploy.jar
that can be run as java -jar J2clCommandLineRunner_deploy.jar
.
The j2cl-maven-plugin will work most of the details that were covered by j2cl_library, j2cl_application, j2cl_test and then some (tests work properly, dev mode output with BUNDLE supports sourcemaps, etc), but doesn't presently have wasm support hooked up, mostly due to our lack of familiarity with wasm.
Yes, you can use the Bazel generated compiler binary; and unlike J2CL, it is currently modeled as a monolithic compiler so you need to collect and supply all the java sources in single shot (vs. compiling independently and providing deps etc.).
Being said that; we supplied the open-source WASM samples for WASM & VM researchers. It is very experimental; the way compiler work and even the bazel rules doesn't reflect our long term design around it; and it is mostly hacked up together.
Great. That could work. You might have to help a bit to get over the initial humps:
$ bazel-bin/transpiler/java/com/google/j2cl/transpiler/J2clCommandLineRunner -classpath bazel-j2cl/bazel-out/k8-fastbuild/bin/jre/java/libjre_bootclasspath-j2wasm.jar -d tmp -backend WASM samples/wasm/src/main/java/com/google/j2cl/samples/wasm/HelloWorld.java
Exception in thread "main" java.lang.NullPointerException
at com.google.j2cl.transpiler.ast.TypeDescriptors$SingletonBuilder.addReferenceType(TypeDescriptors.java:506)
at com.google.j2cl.transpiler.frontend.jdt.JdtUtils.initWellKnownTypes(JdtUtils.java:948)
at com.google.j2cl.transpiler.frontend.jdt.CompilationUnitBuilder$ASTConverter.convert(CompilationUnitBuilder.java:142)
...
You can pass "-s" to bazel
to see the command generated by j2wasm_application
target which should be close to what you will need for J2clCommandLineRunner as well.
Related to #146. I assume it is somehow possible to ask the web server in the sample apps to bind to a different address (host and port), but I can't see how to do it. Some documentation might help? Or maybe it's actually a missing feature in the
j2cl_application.bzl
?