Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vhiairrassary/es modules support #336

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jeroentervoorde
Copy link

@jeroentervoorde jeroentervoorde commented Apr 6, 2020

I updated the previous PR #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.

@sjrd
Copy link
Collaborator

sjrd commented Apr 6, 2020

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.

@jeroentervoorde
Copy link
Author

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?

@dispalt
Copy link
Contributor

dispalt commented May 15, 2020

I'd like to see this as well, we get a major size reduction with es6 too

@dispalt
Copy link
Contributor

dispalt commented May 19, 2020

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. scala-js/scala-js#3893

@nightscape
Copy link

Any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants