[Gradle][K/JS] Add a generic target for projects not specific to node but are also not meant for browser environments #5652
+139
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Kotlin/JS currently only supports 2 execution environments, node and browser. The former is for execution as an application on node, and the latter is for browser scripting on the client. To develop an application in Kotlin that compiles to JS, one needs to use the nodejs option in build.gradle.kts, but this has the caveat that it is very specific to node, building the application as an npm package and pulling in npm + npm dependencies and node itself, among other things. It comes with a lot of extra features and things that may not be desired if the goal is to compile Kotlin to plain JS that can work in a generic environment. To remedy this, I suggest adding a generic target for JS, which will build the project directly into plain, simple executable JS with nothing else included and which is not specific to node or npm. This of course comes with the downside that you can't really use npm with a generic target, but for applications where a minimal build output is desired, it is expected that dependencies would be other libraries written in Kotlin that will be built to yield JS, so this hopefully shouldn't be an issue.
This is a work in progress, and has not been completed yet, don't try to review it because it is not finished!