scalacenter / scalajs-bundler

https://scalacenter.github.io/scalajs-bundler
Other
235 stars 101 forks source link

Add support for Webpack 5 and drop previous versions #390

Closed vhiairrassary closed 3 years ago

vhiairrassary commented 3 years ago

Currently I am able to use this version to compile a small application using webpack 5 (including webpack-dev-server).

Remaining tasks for future 🚧:

Links

Raw Webpack outputs

Webpack 5 (development) ``` asset myapp-fastopt.js 1.34 MiB [emitted] (name: myapp-fastopt) asset index.html 1.72 KiB [emitted] asset icon-32.svg 180 bytes [emitted] [from: assets/icon-32.svg] ./myapp-fastopt.js 1.31 MiB [built] [code generated] webpack 5.12.0 compiled successfully in 544 ms ```
Webpack 5 (production) ``` asset myapp-opt-fe44374c39438c893626.js 258 KiB [emitted] [immutable] [minimized] (name: myapp-opt) asset index.html 1.63 KiB [emitted] asset icon-32-51fa7e7e665ad3b294fe37c44f732d62.svg 180 bytes [emitted] [immutable] [from: assets/icon-32.svg] ./myapp-opt.js 260 KiB [built] [code generated] webpack 5.12.0 compiled successfully in 3547 ms ```
Webpack 4 (development) ``` Hash: 3d2baa6a7539e076a4f3 Version: webpack 4.44.2 Time: 482ms Built at: 01/09/2021 9:50:03 PM Asset Size Chunks Chunk Names icon-32.svg 180 bytes [emitted] index.html 1.72 KiB [emitted] myapp-fastopt.js 1.34 MiB myapp-fastopt [emitted] myapp-fastopt Entrypoint myapp-fastopt = myapp-fastopt.js [0] multi ./myapp-fastopt.js 28 bytes {myapp-fastopt} [built] [./myapp-fastopt.js] 1.31 MiB {myapp-fastopt} [built] Child HtmlWebpackCompiler: Asset Size Chunks Chunk Names icon-32.svg 180 bytes [emitted] + 1 hidden asset Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0 [./assets/icon-32.svg] 55 bytes {HtmlWebpackPlugin_0} [built] [./node_modules/html-webpack-plugin/lib/loader.js!./assets/index.ejs] 2.04 KiB {HtmlWebpackPlugin_0} [built] ```
Webpack 4 (production) ``` Hash: d5a693b21ce4f40515c4 Version: webpack 4.44.2 Time: 391ms Built at: 01/09/2021 9:50:50 AM Asset Size Chunks Chunk Names icon-32-51fa7e7e665ad3b294fe37c44f732d62.svg 180 bytes [emitted] [immutable] index.html 1.76 KiB [emitted] myapp-opt-350577d29ed7f637efda.js 259 KiB 0 [emitted] [immutable] myapp-opt Entrypoint myapp-opt = myapp-opt-350577d29ed7f637efda.js [0] multi ./myapp-opt.js 28 bytes {0} [built] [1] ./myapp-opt.js 260 KiB {0} [built] Child HtmlWebpackCompiler: Asset Size Chunks Chunk Names icon-32-51fa7e7e665ad3b294fe37c44f732d62.svg 180 bytes [emitted] [immutable] + 1 hidden asset Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0 [0] ./assets/icon-32.svg 88 bytes {0} [built] [1] ./node_modules/html-webpack-plugin/lib/loader.js!./assets/index.ejs 2.04 KiB {0} [built] ```

Raw warnings

Webpack 5 ``` WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map from '/Users/lihaoyi/Github/scalatags/scalatags/src/scalatags/text/Builder.scala' file: Error: ENOENT: no such file or directory, open '/Users/lihaoyi/Github/scalatags/scalatags/src/scalatags/text/Builder.scala' WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map from '/Users/lihaoyi/Github/sourcecode/sourcecode/src/sourcecode/SourceContext.scala' file: Error: ENOENT: no such file or directory, open '/Users/lihaoyi/Github/sourcecode/sourcecode/src/sourcecode/SourceContext.scala' WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map: 'https://raw.githubusercontent.com/scala-js/scala-js-dom/v1.1.0/src/main/scala/org/scalajs/dom/package.scala' URL is not supported WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map: 'https://raw.githubusercontent.com/scala-js/scala-js/v1.4.0/javalanglib/src/main/scala/java/lang/Boolean.scala' URL is not supported ```
Webpack 5 ``` WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/index.js): (Emitted value instead of an instance of Error) Cannot find source file '../../../../../../../../../lihaoyi/Github/scalatags/scalatags/src/scalatags/text/Builder.scala': Error: Can't resolve '../../../../../../../../../lihaoyi/Github/scalatags/scalatags/src/scalatags/text/Builder.scala' in '/Users/vhiairrassary/Code/test/test/app/target/scala-2.13/scalajs-bundler/main' @ multi ./app-fastopt.js app-fastopt[0] WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/index.js): (Emitted value instead of an instance of Error) Cannot find source file '../../../../../../../../../lihaoyi/Github/sourcecode/sourcecode/src/sourcecode/SourceContext.scala': Error: Can't resolve '../../../../../../../../../lihaoyi/Github/sourcecode/sourcecode/src/sourcecode/SourceContext.scala' in '/Users/vhiairrassary/Code/test/test/app/target/scala-2.13/scalajs-bundler/main' @ multi ./app-fastopt.js app-fastopt[0] WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/index.js): (Emitted value instead of an instance of Error) Cannot find source file 'https://raw.githubusercontent.com/scala-js/scala-js-dom/v1.1.0/src/main/scala/org/scalajs/dom/package.scala': Error: Can't resolve './https://raw.githubusercontent.com/scala-js/scala-js-dom/v1.1.0/src/main/scala/org/scalajs/dom/package.scala' in '/Users/vhiairrassary/Code/test/test/app/target/scala-2.13/scalajs-bundler/main' @ multi ./app-fastopt.js app-fastopt[0] WARNING in ./app-fastopt.js Module Warning (from ./node_modules/source-map-loader/index.js): (Emitted value instead of an instance of Error) Cannot find source file 'https://raw.githubusercontent.com/scala-js/scala-js/v1.4.0/javalanglib/src/main/scala/java/lang/Boolean.scala': Error: Can't resolve './https://raw.githubusercontent.com/scala-js/scala-js/v1.4.0/javalanglib/src/main/scala/java/lang/Boolean.scala' in '/Users/vhiairrassary/Code/test/test/app/target/scala-2.13/scalajs-bundler/main' @ multi ./app-fastopt.js app-fastopt[0] ```
vhiairrassary commented 3 years ago

The PR now contains changes to parse warning and errors (I removed the --bail option as it prevents the plugin to parse the errors: when using it then there is no JSON available on stdout, the only error is directly written to stderr by Webpack).

julienrf commented 3 years ago

Thanks a lot for opening this PR @vhiairrassary!

Is anyone watching this repository interested in helping?

cquiroz commented 3 years ago

I could review it as I did webpack 4 but I,m a bit stretched on time

cquiroz commented 3 years ago

@vhiairrassary Do you think this needs more work? There are a few checkboxes on the description as "pending"

vhiairrassary commented 3 years ago

@cquiroz Thank for the review. I just rebased the PR and I think it is good enough for now. If maintainers agree to merge (it means we drop support for webpack < 5, on master at least) we can:

Toughts? On my side I don't have the permission to publish, can you do it please?

cquiroz commented 3 years ago

I think we should do an RC for testers, it would be great to have a sort of migration guide but I don’t know how feasible is that considering how different webpack configurations are

I can produce releases but not update the documentation site

vhiairrassary commented 3 years ago

I rebased the PR to verify tests are still ✅ with GitHub Actions. Can I ask you to produce a release for this PR, without merging it, so interested users can test it? It would allow to get feedbacks, find bugs, help us to write a migration guide, etc.

Also, if we merge it it will require a bump of the major version due to the breaking changes. It might be a good idea to tackle the migration from fastOptJS to fastLinkJS.

cquiroz commented 3 years ago

I'm not sure I can make a release only for test, I could do 0.21.0-RC1 though. I'm not sure if that will trigger scala-steward updates

cquiroz commented 3 years ago

It seems this is ready for testing

viktor-podzigun commented 1 year ago

Since it was released in v0.21.0 already, could we have ChangeLog page updated with the notes, please?