scalajs-bundler
scalajs-bundler copied to clipboard
Webpack 5 Support
As expected, scalajs-bundler will throw Unsupported webpack major version 5
when trying to use any webpack
version with a major version higher than 4.
The update seems to primarily focus on better caching for better performance, deterministic builds, smaller output sizes, and better WebAssembly support.
I'm unsure about what needs to be changed here, but I assume that the changes to compiler hooks could be important.
I don't really expect support to be added until after it comes out of beta and enough plugins get up to date, but progress can be tracked here.
Migration Guide: https://webpack.js.org/migrate/5/
I have the intention to add version 5 support (Maybe we should delete support for versions 3 and older) but sure, we need to wait for a public release first.
I'm taking a look at this, the format of the stats has changed, it may take a while to get right and it maybe hard to support both webpack 4 and webpack 5
Webpack 5 was released, we should try to get this moving. Having backward compatibility is getting to be a drag, Should we consider removing support for some of the older versions?
Should we consider removing support for some of the older versions?
This is fine by me, but I would like to hear from other users of scalajs-bundler :)
So long as 5 works, I'm happy to drop 4. I do have some customizations, but they are hopefully simple enough they won't be hard to port.
yeah I say we track the latest with master, and drop support for others but keep a branch around in case. It's not like people are needing fixes that often with this since it's mainly glue code. The only exception seems to be that sjsbundler will need some changes for scala 1.3.0 to work.
Following this ticket I created https://github.com/scalacenter/scalajs-bundler/pull/390 (pretty such a PoC, still a draft). I would love to get feedbacks from you before finishing the remaining tasks.
https://github.com/scalacenter/scalajs-bundler/pull/390 has been merged. @cquiroz could you publish a RC please, so users can test & we can address issues?
Thanks @vhiairrassary for your work on #390. Do you plan to release an RC with webpack 5 support @julienrf @sjrd @cquiroz ? I'm willing to test it out.
@julienrf @sjrd @cquiroz Also happy to do any testing, or anything else needed to help get this released. Getting to the point where a number of Webpack plugins are no longer supporting V4 in their most recent iterations.
would love to test out the latest RC which contains webpack 5 support. Any instructions on how to manually build scalajs-bundler?
@evbo You can clone the repository, run sbt publishLocal
and use the produced artefact in the plugins.sbt
file from your project
I've given the v0.21.0-RC1 tag a go in our project.
I've had to change webpack's config by adding {test: /\.m?js/,resolve: {fullySpecified: false}}
to module.rules
and changing the way webpack-merge
is imported to const { merge } = require('webpack-merge');
, the upgrade was painless and the RC seems to work fine!
Would it be worth updating the documentation? For the moment it only mentions web pack 4 support. I am trying to get going...
so far for me fast optimization is working, but as @Jaystified mentioned there's some painless webpack config updates anyone using webpack needs to consider.
However, one unusual issue is after fast optimization, the dev server appears to start but with some errors:
[webpack-cli] Unable to load '@webpack-cli/serve' command [webpack-cli] TypeError: options.forEach is not a function
I'm also noticing version in webpack
appears deprecated... Some other way to set that?
UPDATE for the latest SBT version here's what I use (@bblfish):
webpack / version := "5.64.2"
// this fixes above error I was getting, per github issue in webpack repo
webpackCliVersion := "4.9.1"
startWebpackDevServer / version := "4.5.0"
We've also encountered issues which will be fixed in https://github.com/scalacenter/scalajs-bundler/pull/408:
[error] Error parsing webpack stats output
[error] /warnings(0)/moduleName: JsonValidationError(List(error.path.missing),WrappedArray())
[error] /warnings(1)/moduleName: JsonValidationError(List(error.path.missing),WrappedArray())
[error] /warnings(2)/moduleName: JsonValidationError(List(error.path.missing),WrappedArray())
[error] Error parsing webpack stats output
[error] /warnings(0)/moduleName: JsonValidationError(List(error.path.missing),WrappedArray())
[error] /warnings(1)/moduleName: JsonValidationError(List(error.path.missing),WrappedArray())
[error] /warnings(2)/moduleName: JsonValidationError(List(error.path.missing),WrappedArray())
[error] java.lang.AssertionError: assertion failed: Webpack failed to create application bundle
Since our warnings are due to the Performance Hints, we decided to use performance: { hints: false }
as a workaround for now.
Hello. Any updates here?
I think the community is moving off this plugin and towards using Vite: https://www.scala-js.org/doc/tutorial/scalajs-vite.html.
Worked for me, using scalajs-bundler 0.21.1
:
// webpack config
webpack / version := "5.88.2",
webpackCliVersion := "5.1.4",
startWebpackDevServer / version := "4.15.1",