diff --git a/examples/simple/build.gradle.kts b/examples/simple/build.gradle.kts index 56f6f35..414bae4 100644 --- a/examples/simple/build.gradle.kts +++ b/examples/simple/build.gradle.kts @@ -13,6 +13,7 @@ kotlin { js(IR) { browser() binaries.executable() + useEsModules() } } diff --git a/examples/simple/src/jsMain/resources/index.html b/examples/simple/src/jsMain/resources/index.html index 0480cec..ff4ba07 100644 --- a/examples/simple/src/jsMain/resources/index.html +++ b/examples/simple/src/jsMain/resources/index.html @@ -9,6 +9,6 @@
- + diff --git a/vite-kotlin/README.md b/vite-kotlin/README.md index 4767b38..07374be 100644 --- a/vite-kotlin/README.md +++ b/vite-kotlin/README.md @@ -40,6 +40,29 @@ To learn more about why this is necessary, see the [official documentation](http To configure the plugin, see [the vite block][opensavvy.gradle.vite.base.config.ViteConfig]. +### ESM + +ESM is a more modern module system natively supported by Vite. Using it may make the build faster, especially during development. + +To use ESM, you must add `useEsModules()` in the `js {}` block: +```kotlin +// … + +kotlin { + js(IR) { + browser() + binaries.executable() + useEsModules() + } +} +``` + +Additionally, you must edit your `index.html` file to use the extension `.mjs` instead of `.js`. +For example: +```html +