digitalbazaar / forge

A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
https://digitalbazaar.com/
Other
5.09k stars 785 forks source link

Migration to webpack5 #944

Open AyoyimikaAjibade opened 2 years ago

AyoyimikaAjibade commented 2 years ago

Please update node-forge to migrate to webpack5 as maintaining it in the Debian OS environment caused a bug as we try to build the package with webpack 5.65.0 after updating node-forge webpack.config files to use webpack5 options , as you still support of webpack4.44.1 here is a link to the bug report https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1002861

The failing build output looks like this while building with webpack 5.65.0

webpack --progress
99% cache shutdownasset forge.js 662 bytes [emitted] (name: forge)

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/index.js

webpack 5.65.0 compiled with 1 error in 628 ms

assets by status 0 bytes [cached] 1 asset

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/index.js

webpack 5.65.0 compiled with 1 error in 776 ms

asset forge.all.js 662 bytes [emitted] (name: forge)

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/index.all.js

webpack 5.65.0 compiled with 1 error in 489 ms

assets by status 0 bytes [cached] 1 asset

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/index.all.js

webpack 5.65.0 compiled with 1 error in 758 ms

asset prime.worker.js 662 bytes [emitted] (name: forge)

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/forge.js

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/prime.worker.js

webpack 5.65.0 compiled with 2 errors in 440 ms

assets by status 0 bytes [cached] 1 asset

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/forge.js

ERROR in forge
Module not found: Error: Recursion in resolving
Stack:
  undefined: (/home/ayoyimika/debian-js-packaging/forge/node-node-forge) ./lib/prime.worker.js

webpack 5.65.0 compiled with 2 errors in 748 ms
make[1]: *** [debian/rules:27: debian/js/forge.min.js] Error 1
make[1]: Leaving directory '/home/ayoyimika/debian-js-packaging/forge/node-node-forge'
make: *** [debian/rules:43: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2

A simple solution i proffer is migrating to webpack5 to have access to its updated features, benefits and options https://webpack.js.org/migrate/5/

Thanks and Cheers

davidlehn commented 2 years ago

The migration to webpack 5 hasn't happened yet due to trying to keep old Node.js releases working for a while longer. Updating tools will cause code to be untestable (or at least much more difficult to do so) with old nodes. At some point everything will be upgraded and old node support dropped in favor of all the fancy new tools and ES6+ features. Any change breaking old support will be in 2.x+. 0.10.x should be upgraded to 1.2.x+. That being said, I imagine webpack changes could be made to work with 0.10.x if needed.

I've upgraded other code from 4 to 5 and we've used similar patterns in most of the setups, so I figured forge wouldn't be too bad. Most of the polyfills are shut off too so not having them in 5 should be fine.

I can't tell from the error messages what's going on. Is there a need to upgrade forge itself? Is the issue that debian packages need to use webpack 5 now? Or just that some other app pulling in forge with webpack 5 wasn't working?

Where is a branch with these webpack 5 changes to try? I didn't find it on salsa.

FYI, I'm a debian developer too so could help with the debian side of things if needed.

AyoyimikaAjibade commented 2 years ago

Thanks for your timely response and wanting to help. I truly appreciate it 🙏

i have updated node-forge to version 1.2.1 here is the salsa repo https://salsa.debian.org/Ayoyimika/node-node-forge the package needed for local build of node-forge is webpack and node-webpack-source from the experimental distribution

Yes we are transitioning all reversed dependencies of webpack including node-forge to use webpack 5 now

Here is the branch which webpack5 is used https://salsa.debian.org/js-team/node-webpack/-/tree/master-5

davidlehn commented 2 years ago
AyoyimikaAjibade commented 2 years ago

hello @davidlehn thanks a lot for the help

dlongley commented 2 years ago

@davidlehn, can this be closed? I think we use webpack 5 on the main branch now.

dlongley commented 2 years ago

Oh, no, just kidding, looks like we still haven't switched to webpack 5.