kotlin-node
Kotlin Node.JS compiler installer and wrapper
It downloads and installs kotlinc-js compiler for Кotlin language. This module simplifies usage of Kotlin from Command Line. Please refer to official documentation on how to configure your project correctly.
Prerequisites
Kotlin Compiler requires Java 6 or higher installed
Installation:
To install compiler itself, pleas use:
npm i kotlin-node -DE
To add Kotlin JavaScript Runtime to your project use:
npm i kotlin -SE
Usage:
CLI usage example:
kotlinc-js -module-kind commonjs -output out/server.js -meta-info src/**/*.kt src/*.kt
Also it can accept source directory
kotlinc-js -module-kind commonjs -output out/server.js -meta-info ./src
JavaScript module usages:
As parameters array:
const kotlinc = require(`kotlin-node`);
kotlinc([
`-module-kind commonjs`,
`-output out/server.js`,
`-meta-info`
], [`src/**/*.kt`, `src/*.kt`]).catch(console.error);
As parameters JSON:
const kotlinc = require(`kotlin-node`);
kotlinc({
'module-kind': `commonjs`,
'output': `out/server.js`,
'meta-info': true
}, [`src/**/*.kt`, `src/*.kt`]).catch(console.error);
Some of available CLI keys are available in documentation. Kotlin Compiler Usage Help:
Usage: kotlinc-js <options> <source files>
where possible options include:
-output <path> Output file path
-no-stdlib Don't use bundled Kotlin stdlib
-libraries <path> Paths to Kotlin libraries with .meta.js and .kjsm files, separated by system file separator
-source-map Generate source map
-meta-info Generate .meta.js and .kjsm files with metadata. Use to create a library
-target { v5 } Generate JS files for specific ECMA version
-module-kind { plain, amd, commonjs, umd }
Kind of a module generated by compiler
-main {call,noCall} Whether a main function should be called
-output-prefix <path> Path to file which will be added to the beginning of output file
-output-postfix <path> Path to file which will be added to the end of output file
-language-version <version> Provide source compatibility with specified language version
-api-version <version> Allow to use declarations only from the specified version of bundled libraries
-nowarn Generate no warnings
-verbose Enable verbose logging output
-version Display compiler version
-help (-h) Print a synopsis of standard options
-X Print a synopsis of advanced options
-P plugin:<pluginId>:<optionName>=<value>
Pass an option to a plugin