Quick question when I build a kotlinjs project and...
# javascript
f
Quick question when I build a kotlinjs project and include a external dependency (for example from NPM) does kotlinjs compiler support tree shaking or will it always include the full external dependency in the final generated code?
r
Kotlin compiler doesn't care about external JS dependencies. And it doesn't include any external JS code. The final bundle is generated by webpack.
t
At current time optimal tree shaking (created by Webpack) blocked by Kotlin/JS: 1. No ES6 modules support => full module imported (not recommended by Google) 2. Redundant package information block tree shaking too 2 steps required for optimal tree shaking: 1. ES6 modules support (partial export/import) 2. Change contract of
@JsExport
- ignore Kotlin package in JS export by default.
a
Are there any plans for kotlin/js to support ES6?
t
cc @bashor, @anton.bannykh
b
Yes, we are going to use ES2015 features in near future in the new compiler. Firstly ES2015 classes and modules.
😊 1
To get updates you can watch (by star or vote) this umbrella issue and/or other issues mentioned there as related.
f
So if I understand it correctly if kotlinJS starts outputting proper ES6 code webpacks treeshaking should be able todo its work and external dependencies could be reduced as well?
👌 1
t
proper ES6 code
ES6 modules with “granular” import
f
Haha which probably gonna take a long time since all bindings would have to be updated to mark for each reference which file that reference is included in…
t
No panic! Check required 🙂
n
Is the ES2015 support likely to appear in a future Kotlin 1.4 release?
👆 1