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

Version 6 (for Webpack 4) does not work on Node 18+ #364

Closed
renchap opened this issue Sep 6, 2023 · 10 comments
Closed

Version 6 (for Webpack 4) does not work on Node 18+ #364

renchap opened this issue Sep 6, 2023 · 10 comments

Comments

@renchap
Copy link

renchap commented Sep 6, 2023

Bug report

When running Webpack 4 with the latest version of this plugin on Node 18 (thanks to the new Webpack 4 version), it fails with this error:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at /Users/renchap/dev/mastodon/mastodon/node_modules/compression-webpack-plugin/dist/index.js:230:42
    at CompressionPlugin.compress (/Users/renchap/dev/mastodon/mastodon/node_modules/compression-webpack-plugin/dist/index.js:319:9)
    at /Users/renchap/dev/mastodon/mastodon/node_modules/compression-webpack-plugin/dist/index.js:340:12
    at _next1 (eval at create (/Users/renchap/dev/mastodon/mastodon/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:37:17)
    at eval (eval at create (/Users/renchap/dev/mastodon/mastodon/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:64:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Actual Behavior

Build fails with the error above

Expected Behavior

The build should complete without error on Node 18

How Do We Reproduce?

This can be reproduced on Mastodon with this PR: mastodon/mastodon#26830 (look at the failed github actions)

Please paste the results of npx webpack-cli info here, and mention other relevant information

Webpack version 4.47.0
compression-webpack-plugin version 6.1.1 (latest version compatible with Webpack 4)

@renchap
Copy link
Author

renchap commented Sep 6, 2023

Pinging @TheLarkInn as you merged webpack/webpack#17628

@BossMAN559
Copy link

before the precompile execute this command
export NODE_OPTIONS=--openssl-legacy-provider

@renchap
Copy link
Author

renchap commented Sep 6, 2023

Yes this kind of fixes the issue, but the intend for webpack/webpack#17628 is to avoid this and allow Webpack 4 to run on Node 18 without those changes.

I think this could be fixed by requiring Webpack 4.47.0 and using import { createHash } from "webpack/lib/util/createHash" to replace crypto.createHash, but I am not sure how to send a PR for this as there is no stable branch for version 6.

@BossMAN559
Copy link

i look forward to not needing to run the export.

@renchap
Copy link
Author

renchap commented Sep 6, 2023

I can confirm that applying this patch over the 6.1.1 version works with Node 18:

Edit: removed patch, see below

I am not sure how I can submit a PR for this, or if the maintainers can easily make a new v6 release.

I updated the peer deps to require the latest Webpack 4 version, as this is the one exporting createHash.

@renchap renchap changed the title Version 6 (for Webpack 4) does not work on Node 16 Version 6 (for Webpack 4) does not work on Node 18+ Sep 7, 2023
@renchap
Copy link
Author

renchap commented Sep 7, 2023

I forked the repository and added a commit that makes the plugin work with Webpack 4 and Node 18+ (tested with Node 18 and Node 20 on Mastodon, see mastodon/mastodon#26830).

You can find the related changes here: renchap@a98a929

The package.json has been updated to require Webpack 4.47, as this is the version including the new createHash function.

This is published on NPM as @renchap/compression-webpack-plugin

It would be very welcome for a maintainer of this package to use this patch and release an official 6.1.2 version, so people stuck on Webpack 4 can upgrade to a supported Node version.

@snitin315
Copy link
Member

We'll do a patch release.

@ClearlyClaire
Copy link

We'll do a patch release.

Thanks! Any estimate for when this will happen?

@alexander-akait
Copy link
Member

Fixed #373, release will be soon

@alexander-akait
Copy link
Member

Please try https://github.com/webpack-contrib/compression-webpack-plugin/releases/tag/v6.1.2, sorry for delay

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

No branches or pull requests

5 participants