How do we enable the experimental npm/webpack supp...
# javascript
j
How do we enable the experimental npm/webpack support on the new Kotlin/JS gradle plugin 1.3.40?
s
In fact it is enabled by default. You just need to configure test/run environment by adding this lines to your
build.gradle
file:
Copy code
kotlin {
   js { // for single platform project use "target { }" section
      nodejs()
      browser()
   }
}
Also you can add npm in dependencies section of source sets, for example:
Copy code
kotlin {
    sourceSets["main"].dependencies {
        implementation(kotlin("stdlib-js"))
        implementation(npm("react", "16.8.3"))
    }
}
j
Ah I had tried to put npm deps inside the standard Gradle
dependencies
block, but got an error about the npm function. Thanks for the tip, I'll try that.
s
Currently it is worked only inside sourceSets
dependencies
, not in project
dependencies
section.