diff --git a/deps/weex-scripter/lib/require-parse.js b/deps/weex-scripter/lib/require-parse.js index 9e74eba60c9c227865d69dfa077129d42f47c7dc..20e167272077b9c3b720a9506336aa17cb985443 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 f51492922c5865ed74cb342afdda21535ab406a3..ff6d07b2db3f16f0acf25776d2b34d0b969ae91a 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}` }