Skip to content

Commit e961eb1

Browse files
committed
Enable JS IR backend
1 parent 21bb6fb commit e961eb1

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ robolectric_version=4.0.2
2929
baksmali_version=2.2.7
3030

3131
# JS
32+
kotlin.js.compiler=both
3233
gradle_node_version=1.2.0
3334
node_version=8.9.3
3435
npm_version=5.7.1
@@ -43,3 +44,6 @@ kotlin.native.ignoreDisabledTargets=true
4344

4445
# Site deneration
4546
jekyll_version=4.0
47+
48+
# JS IR baceknd sometimes crashes with out-of-memory
49+
org.gradle.jvmargs=-Xmx2g

gradle/compile-js-multiplatform.gradle

+21-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ apply from: rootProject.file('gradle/node-js.gradle')
66

77
kotlin {
88
targets {
9-
fromPreset(presets.js, 'js')
9+
fromPreset(presets.js, 'js') {
10+
// Enable built-in test runner only for IR target.
11+
// These runners don't support changing js module name change.
12+
if (js.hasProperty("irTarget")) {
13+
irTarget.browser()
14+
irTarget.nodejs()
15+
}
16+
}
1017
}
1118

1219
sourceSets {
1320
jsMain.dependencies {
1421
api "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
22+
api "org.jetbrains.kotlinx:atomicfu-js:$atomicfu_version"
1523
}
1624

1725
jsTest.dependencies {
@@ -39,14 +47,25 @@ compileTestKotlinJs {
3947
kotlinOptions.metaInfo = true
4048
kotlinOptions.sourceMap = true
4149
kotlinOptions.moduleKind = 'umd'
50+
kotlinOptions.freeCompilerArgs += "-XXLanguage:-NewInference"
51+
}
52+
53+
if (project.tasks.findByName('compileKotlinJsIr')) {
54+
compileKotlinJsIr {
55+
kotlinOptions.freeCompilerArgs += "-XXLanguage:-NewInference"
56+
}
4257
}
4358

59+
4460
task populateNodeModules(type: Copy, dependsOn: compileTestKotlinJs) {
4561
// we must copy output that is transformed by atomicfu
4662
from(kotlin.targets.js.compilations.main.output.allOutputs)
4763
into "$node.nodeModulesDir/node_modules"
4864

49-
def configuration = configurations.jsTestRuntimeClasspath
65+
def configuration = configurations.hasProperty("legacyjsTestRuntimeClasspath")
66+
? configurations.legacyjsTestRuntimeClasspath
67+
: configurations.jsTestRuntimeClasspath
68+
5069
from(files {
5170
configuration.collect { File file ->
5271
file.name.endsWith(".jar") ?

gradle/publish-bintray.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ publishing {
8989
break
9090
}
9191

92-
// disable metadata everywhere, but in native modules
93-
if (type == 'maven' || type == 'metadata' || type == 'jvm' || type == 'js') {
92+
// disable metadata everywhere, but in native and js modules
93+
if (type == 'maven' || type == 'metadata' || type == 'jvm') {
9494
moduleDescriptorGenerator = null
9595
}
9696
}

gradle/test-mocha-js.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ task testMochaNode(type: NodeTask, dependsOn: [compileTestKotlinJs, installDepen
1919
if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter']
2020
}
2121

22-
jsTest.dependsOn testMochaNode
22+
def legacyjsTestTask = project.tasks.findByName('legacyjsTest') ? legacyjsTest : jsTest
23+
24+
legacyjsTestTask.dependsOn testMochaNode
2325

2426
// -- Testing with Mocha under headless Chrome
2527

@@ -89,5 +91,5 @@ task testMochaJsdom(type: NodeTask, dependsOn: [compileTestKotlinJs, installDepe
8991
if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter']
9092
}
9193

92-
jsTest.dependsOn testMochaJsdom
94+
legacyjsTestTask.dependsOn testMochaJsdom
9395

0 commit comments

Comments
 (0)