Can we do the same thing as Node with Java 8 and Nashorn?
The answer is yes. Let’s see how it works.
Here’s what it does in details:
- It loads coffee-script.min.js from the classpath. Here, I used a WebJar to import the script into my project
- Then it create a Nashorn script engine
- It compiles the coffee-script.min.js once
- It executes the compile code on the provided coffee script source