From a1301d885e68da4d495283b492c2ab227ba7c91a Mon Sep 17 00:00:00 2001 From: bojiang Date: Wed, 24 May 2023 16:22:35 +0800 Subject: [PATCH] jiangbo91@huawei.com Signed-off-by: bojiang Change-Id: Ibd686b8e9ce6b3ef1dc58c0ddeac85debe4f1090 --- deps/weex-scripter/lib/require-parse.js | 6 ++++-- src/util.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deps/weex-scripter/lib/require-parse.js b/deps/weex-scripter/lib/require-parse.js index 9e74eba..20e1672 100644 --- a/deps/weex-scripter/lib/require-parse.js +++ b/deps/weex-scripter/lib/require-parse.js @@ -1,6 +1,6 @@ var path = require('path') var fs = require('fs') -var md5 = require('md5') +const crypto = require("crypto") var existsSync = fs.existsSync || path.existsSync var nodePaths = process.env.NODE_PATH ? process.env.NODE_PATH.split(':') : [] @@ -83,7 +83,9 @@ function parseAndReplaceRequire(code, curPath) { return $0 } else { - var md5Path = md5(subModulePath) + const hash = crypto.createHash('sha256') + hash.update(subModulePath.toString()) + var md5Path = hash.digest('hex') requires[md5Path] = subModulePath return 'browserifyRequire("' + md5Path + '")' } diff --git a/src/util.js b/src/util.js index f514929..ff6d07b 100644 --- a/src/util.js +++ b/src/util.js @@ -20,7 +20,7 @@ import path from 'path' import fs from 'fs' import loaderUtils from 'loader-utils' -import hash from 'hash-sum' +const crypto = require("crypto") import { SourceMapGenerator, SourceMapConsumer @@ -37,7 +37,9 @@ export function getNameByPath (resourcePath) { export function getFileNameWithHash (resourcePath, content) { const filename = path.relative('.', resourcePath) - const cacheKey = hash(filename + content) + const hash = crypto.createHash('sha256') + hash.update((filename + content).toString()) + const cacheKey = hash.digest('hex') return `./${filename}?${cacheKey}` } -- Gitee