Monday, July 6, 2020

Running Kotlin Node JS projects outside Gradle

It's pretty easy to set up a Kotlin JS project targeting Node JS using the Kotlin JS Gradle plugin, but it's less easy to figure out how to actually run it on a server. The build/js folder contains the compiled JavaScript code, but accompanied by a ton of unnecessary stuff like copies of artifacts that are available on NPM. The compiled version of just the project under development is in a subdirectory of build/js/packages named for the project. Though that folder contains a package.json file that npm install can use, there is no clear way to start the app. For it to work with environments like Passenger, I amended the build process to write an app.js file there containing only:

require('./kotlin/the-project.js'); 

Then only the directory containing that new app.js has to be deployed.

No comments:

Post a Comment