I just upgraded to Kotlin 1.3.70 and now when I do...
# javascript
n
I just upgraded to Kotlin 1.3.70 and now when I do a production JS build I get an 'undefined' error from Terser.
Copy code
Version: webpack 4.41.2
Time: 9419ms
Built at: 03/30/2020 3:24:01 PM
 2 assets
Entrypoint main = app-production.js app-production.js.map
 [0] ./kotlin-dce/kotlin.js 424 KiB {0} [built]
 [1] ./kotlin-dce/acornui-acornui-utils.js 695 KiB {0} [built]
 [2] ./kotlin-dce/acornui-acornui-core.js 2.35 MiB {0} [built]
 [3] ./kotlin-dce/kotlinx-coroutines-core.js 297 KiB {0} [built]
 [4] ./kotlin-dce/asdf-app-common.js 352 KiB {0} [built]
 [5] ./kotlin-dce/kotlinx-serialization-kotlinx-serialization-runtime.js 342 KiB {0} [built]
 [7] (webpack)/buildin/global.js 472 bytes {0} [built]
 [9] multi ./kotlin-dce/asdf-app.js 28 bytes {0} [built]
[10] ./kotlin-dce/asdf-app.js 136 KiB {0} [built]
[18] ./kotlin-dce/asdf-ddc.js 115 KiB {0} [built]
[19] ./kotlin-dce/asdf-demo-module.js 75.9 KiB {0} [built]
[20] ./kotlin-dce/asdf-theme-builder.js 131 KiB {0} [built]
[21] ./kotlin-dce/asdf-rich-text-editor.js 6.4 KiB {0} [built]
[22] ./kotlin-dce/asdf-timesheet.js 118 KiB {0} [built]
[23] ./kotlin-dce/acornui-acornui-webgl-backend.js 174 KiB {0} [built]
    + 9 hidden modules

ERROR in app-production.js from Terser
undefined
Any idea how I can troubleshoot this? It was working in the 1.3.70 EAP
Full conversation is in the thread in the next post, but for posterity, here were the two solutions provided by Rob Murdock and Robert Jaros: The problem is that the Terser plugin broke with 4.6.8. So the workaround is either using 4.6.7 or switching to Uglify. To use Terser 4.6.7, every JS library needs to add Terser as an NPM dependency: For a multiplatform project:
Copy code
kotlin {
	sourceSets {
		val jsMain by getting {
			dependencies {
				implementation(npm("terser", "4.6.7"))
			}
		}
	}
}
Alternatively, switch to using Uglify. (I've found this to be around 15% smaller filesizes as well) This can be done by creating a webpack.config.d folder in your application project's root and adding a minimize.js file with the contents: https://github.com/rjaros/kvision-examples/blob/master/template/webpack.config.d/minify.js Then add an npm dependency on Uglify:
Copy code
implementation(npm("uglifyjs-webpack-plugin", "2.2.0"))
🙏 1
b
JFYI @Ilya Goncharov [JB]
i
I hope, it should be fixed Seems that was problem in Terser release, they did new release
b
Also, what do you know/think about this:
Alternatively, switch to using Uglify. (I’ve found this to be around 15% smaller filesizes as well)
n
The 15% claim needs further testing, it may have just been a difference in library dependencies.
b
@Nicholas Bilyk it would be nice if you cald recheck it and let us know results.
n
@bashor Yeah I think I spoke too soon. Perhaps I was seeing a file size not yet refreshed by Windows. Results are very similar (using default settings): Uglify: 2,888,028 bytes Terser: 2,785,045 bytes
b
Thank you for measures.