[Gradle, JS] Filter DCE candidates
We should process DCE only for: - JARs - JSs with neighbors meta.js
This commit is contained in:
+15
-1
@@ -67,7 +67,9 @@ open class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), KotlinJs
|
||||
|
||||
@TaskAction
|
||||
fun performDce() {
|
||||
val inputFiles = (listOf(source) + classpath.map { project.fileTree(it) })
|
||||
val inputFiles = (listOf(source) + classpath
|
||||
.filter { isDceCandidate(it) }
|
||||
.map { project.fileTree(it) })
|
||||
.reduce(FileTree::plus)
|
||||
.files.map { it.path }
|
||||
|
||||
@@ -83,4 +85,16 @@ open class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), KotlinJs
|
||||
)
|
||||
throwGradleExceptionIfError(exitCode)
|
||||
}
|
||||
|
||||
private fun isDceCandidate(file: File): Boolean {
|
||||
if (file.extension == "jar") {
|
||||
return true
|
||||
}
|
||||
|
||||
if (file.extension != "js" || file.name.endsWith(".meta.js")) {
|
||||
return false
|
||||
}
|
||||
|
||||
return File("${file.nameWithoutExtension}.meta.js").exists()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user