diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 74eb872..365c1f0 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -56,7 +56,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: [12.x, 14.x, 16.x] + node-version: [12.x, 14.x, 16.x, 17.x] webpack-version: [latest] runs-on: ${{ matrix.os }} diff --git a/src/index.js b/src/index.js index 248477e..78e9aa9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,4 @@ import path from "path"; -import crypto from "crypto"; import { validate } from "schema-utils"; import pLimit from "p-limit"; @@ -476,14 +475,20 @@ class CopyPlugin { const buffer = result.source.buffer(); if (transform.cache) { + // TODO: remove in the next major release + const hasher = + compiler.webpack && + compiler.webpack.util && + compiler.webpack.util.createHash + ? compiler.webpack.util.createHash("xxhash64") + : // eslint-disable-next-line global-require + require("crypto").createHash("md4"); + const defaultCacheKeys = { version, sourceFilename, transform: transform.transformer, - contentHash: crypto - .createHash("md4") - .update(buffer) - .digest("hex"), + contentHash: hasher.update(buffer).digest("hex"), index, }; const cacheKeys = `transform|${serialize(