Node.JS migration to 18.14.1 version issue: error:0308010C:digital envelope routines::unsupported

I have migrated from node.js 16.15.0 to 18.14.1.

Right now, I am having an error coming from babel-loader.js in a custom framework (just FYI for the react based advice) :

enter image description here

This is what I am having in the place where issue is coming:

var filename = function filename(source, identifier, options) {
  var hash = crypto.createHash("md4");
  var contents = JSON.stringify({
    source: source,
    options: options,
    identifier: identifier
  });

  hash.update(contents);

  return hash.digest("hex") + ".json.gz";
 };

As I understand, the origin of the issue comes from Webpack using the MD4 algorithm in its build process, which is no longer supported in the latest Node.js version. So I have updated the webpack version to 5.75.0 (doesn’t help at all) and also I decided to patch the babel-loader dependency, by switching the algorithm from md4 to md5:

var filename = function filename(source, identifier, options) {
  var hash;
  try {
    hash = crypto.createHash("md4");
  } catch (e) {
    console.warn('Crypto "md4" is not supported anymore by this Node version');
    hash = crypto.createHash("md5");
  }
  var contents = JSON.stringify({
    source: source,
    options: options,
    identifier: identifier
  });

  hash.update(contents);

  return hash.digest("hex") + ".json.gz";
};

I am not having this error anymore, BUT the content is not being rendered and I am having a lot of issues in the console. I believe it’s because I changed the way of hashing, but I also have to do the proper un-hashing in babel-loader.js. Will be super grateful for any advices on it

p.s.: please don’t advise to downgrade the node.js version