scalajs-bundler
scalajs-bundler copied to clipboard
Vhiairrassary/es modules support
I updated the previous PR https://github.com/scalacenter/scalajs-bundler/pull/312 against current master. It seems to work fine except for this warning when trying to configure ES modules in fullOptJS ):
"The module kind in scalaJSLinkerConfig in (myProject, compile, fullOptJS) is different than the one in (myProject, compile)`. Some things will go wrong."
In build.sbt I used: scalaJSLinkerConfig in fullOptJS ~= (_.withModuleKind(ModuleKind.ESModule))
Not sure what to do about that. We should be able to configure ES modules in fullOptJS only i guess as it does not work will BundlingMode.LibraryOnly()
My reason to enable this is fullOptJS is the smaller bundler size. It generates a 25% smaller output file. Probably because of the better DCE for ES modules in webpack.
The warning is legitimate, and you should heed it. You'll run into all sorts of issues if you set the module kind in fullOptJS differently from not in fullOptJS (same with in fastOptJS). sbt-scalajs assumes that they are not overridden per task, which is why it emits that warning.
Thanks. I already assumed you put that warning there for a reason :) This workaround works for me:
sbt "set scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.ESModule))" clean fullOptJS::webpack
If i update the documentation would you / @julienrf be willing to merge this?
I'd like to see this as well, we get a major size reduction with es6 too
Actually that is incorrect, I don't get any savings. I must have been mixing something up in my head with 0.6... Sorry for the noise, but fullOpt shouldn't get any savings because of this. https://github.com/scala-js/scala-js/issues/3893
Any news on this?