Closed vhiairrassary closed 3 years ago
BundlingMode.LibraryOnly()
does not work
I’m not sure what we can do about that. By design, the LibraryOnly
mode can only work with a module kind that is understood by web browsers. We could just document that the LibraryOnly
mode only works with CommonJSModule
.
Any update on this?
I updated the PR 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 (learnreact, compile, fullOptJS)
is different than the one in
(learnreact, 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.
Updated PR. https://github.com/scalacenter/scalajs-bundler/pull/336
Closing in favor of https://github.com/scalacenter/scalajs-bundler/pull/336
Fixes https://github.com/scalacenter/scalajs-bundler/issues/293
Allow to use ES modules as well as CommonJS module.
WIP:
BundlingMode.LibraryOnly()
does not work yet as with:the browser will not recognize the
import
syntax in the last script.Adding the attribute
type="module"
is not enough: if[name]-fastopt.js
contains something likeimport * as $i_jquery from "jquery";
then the following error is thrown: