Open ngbinh opened 4 years ago
just FYI, I have been using esbuild for a couple of months on both production and dev build on a very large scala.js project at work. The plugin is fairly simple, I still need scalajs bundler to pull npm dependencies but not webpack.
Interesting! Do we need to provide some sort of integration (ie, we would replace the bundling part currently done by webpack with something that uses esbuild)? Or should we remove the concern of bundling from sbt-scalajs-bundler and focus only on fetching NPM dependencies?
There are tasks that webpack
is better due to its rich ecosystem. But esbuild
kills it on js bundling. So I think it would be nice if this plugin provides a clean solution to fetch NPM dependencies. For bundling, because esbuild
can handle the whole hundred of MBs js output, you don't need something like LibOnly
mode likes in webpack for it to work. It would make the plugin much simpler and there is no need for the bundler to know anything about scalajs internal
It maybe interesting to explore this approach. scalajs-bundler
approach is nice as you only need sbt running but keeping up to date with the js tooling world takes some effort.
Given that module splitting support has landed in 1.3, I don't think we need the libraryOnly
mode. So I think "pull npm dependencies only" might be the right role for scalajs-bundler.
I wonder the impact of tests. Could we be able to write tests in sbt if there is no bundler integration. I mean tests that would use a facade
esbuild is used by Snowpack too
Also consider https://vitejs.dev/, which uses esbuild, as alternative to Webpack.
@ngbinh I agree with @mkotsbak why not consider adopting vite instead of just esbuild?
vite would give a double benefit of bringing the speed of esbuild but also enabling code-splitting (not yet supported in esbuild as I understand...), which is another hot feature: https://github.com/scalacenter/scalajs-bundler/issues/2
So maybe we get 2 birds with 1 stone adopting vite alternative to webpack?
Vitejs is great. But if you only need a bundler then using esbuild directly is simpler
Given that module splitting support has landed in 1.3, I don't think we need the
libraryOnly
mode. So I think "pull npm dependencies only" might be the right role for scalajs-bundler.
I don't understand this comment. libraryOnly mode is still useful IMO as it allows clients to cache your library's bundles which will change much less frequently than your application code. Or do I misunderstand your point?
I switched to use esbuild, an extremely fast JS bundler, instead of
webpack
recently on our big scala.js repo at work. The result is quite impressive, there are projects thatesbuild
can bundle in seconds wherewebpack
would just OOM.I still need to rely on
scalajs-bundler
to pull in npm dependencies. While I can just usescalajs-bundler
without webpack by not callingfastOptJS
/fullOptJS
, I believe it may be beneficial for scala.js ecosystem as a whole to have an official backend onesbuild
inscalajs-bundler
.I can try to give this a shot if you guys think it is the right thing for
scalajs-bundler