Remap source maps in JS DCE. Improve JS DCE error logging
See KT-19821
This commit is contained in:
+3
@@ -225,6 +225,9 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
||||
project.build("runRhino") {
|
||||
println(output)
|
||||
assertSuccessful()
|
||||
val pathPrefix = "mainProject/build/min"
|
||||
assertFileExists("$pathPrefix/exampleapp.js.map")
|
||||
assertFileExists("$pathPrefix/examplelib.js.map")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -18,10 +18,12 @@ dependencies {
|
||||
}
|
||||
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/examplelib.js"
|
||||
compileKotlin2Js.kotlinOptions.sourceMap = true
|
||||
|
||||
jar {
|
||||
from buildDir
|
||||
include "**/*.js"
|
||||
include "**/*.js.map"
|
||||
}
|
||||
|
||||
jar.dependsOn(compileKotlin2Js)
|
||||
|
||||
+3
-2
@@ -68,8 +68,8 @@ class KotlinJsDcePlugin : Plugin<Project> {
|
||||
|
||||
val zippedFiles = UnionFileCollection(configuration.map { project.zipTree(it) })
|
||||
val files = project.fileTree(tmpDir)
|
||||
.filter { it.path.endsWith(".js") }
|
||||
.filter { File(it.path.removeSuffix(".js") + ".meta.js").exists() }
|
||||
.filter { file -> SUFFIXES.any { file.path.endsWith(it) } }
|
||||
.filter { file -> SUFFIXES.any { File(file.path.removeSuffix(it) + ".meta.js").exists() } }
|
||||
|
||||
// This intermediate task is needed due to bug in Gradle that causes infinite loops in continuous build mode
|
||||
val unpackName = sourceSet.getTaskName(UNPACK_DEPENDENCIES_TASK_PREFIX, TASK_SUFFIX)
|
||||
@@ -93,5 +93,6 @@ class KotlinJsDcePlugin : Plugin<Project> {
|
||||
private const val UNPACK_DEPENDENCIES_TASK_PREFIX = "unpackDependencies"
|
||||
private const val DEPENDENCIES_TASK_PREFIX = "copyDependencies"
|
||||
private const val DCE_TASK_PREFIX = "runDce"
|
||||
private val SUFFIXES = listOf(".js", ".js.map")
|
||||
}
|
||||
}
|
||||
@@ -43,14 +43,14 @@ fun main(args: Array<String>) {
|
||||
fun File.relativizeIfNecessary(): String = baseDir.relativize(canonicalFile.toPath()).toString()
|
||||
|
||||
val wrapperFile = File(args[2])
|
||||
val wrapper = parse(wrapperFile.readText(), ThrowExceptionOnErrorReporter, program.scope, wrapperFile.relativizeIfNecessary())
|
||||
val wrapper = parse(wrapperFile.readText(), ThrowExceptionOnErrorReporter, program.scope, wrapperFile.relativizeIfNecessary())!!
|
||||
val insertionPlace = wrapper.createInsertionPlace()
|
||||
|
||||
val allFiles = mutableListOf<File>()
|
||||
args.drop(3).map { File(it) }.forEach { collectFiles(it, allFiles) }
|
||||
|
||||
for (file in allFiles) {
|
||||
val statements = parse(file.readText(), ThrowExceptionOnErrorReporter, program.scope, file.relativizeIfNecessary())
|
||||
val statements = parse(file.readText(), ThrowExceptionOnErrorReporter, program.scope, file.relativizeIfNecessary())!!
|
||||
val block = JsBlock(statements)
|
||||
block.fixForwardNameReferences()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user