JavaScript modules

Edit pageLast modified: 25 September 2024

You can compile your Kotlin projects to JavaScript modules for various popular module systems. We currently support the following configurations for JavaScript modules:

  • Unified Module Definitions (UMD), which is compatible with both AMD and CommonJS. UMD modules are also able to be executed without being imported or when no module system is present. This is the default option for the browser and nodejs targets.

  • Asynchronous Module Definitions (AMD), which is in particular used by the RequireJS library.

  • CommonJS, widely used by Node.js/npm (require function and module.exports object).

  • Plain. Don't compile for any module system. You can access a module by its name in the global scope.