diff --git a/package.json b/package.json index 56390b74..fb01b162 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ }, "dependencies": { "chalk": "^4.1.0", - "hash-sum": "^2.0.0", "watchpack": "^2.4.0" }, "peerDependencies": { @@ -57,7 +56,6 @@ "@intlify/vue-i18n-loader": "^3.0.0", "@types/cssesc": "^3.0.2", "@types/estree": "^0.0.45", - "@types/hash-sum": "^1.0.0", "@types/jest": "^26.0.13", "@types/jsdom": "^16.2.13", "@types/mini-css-extract-plugin": "^0.9.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ccee0cc8..06511b62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ dependencies: chalk: specifier: ^4.1.0 version: 4.1.0 - hash-sum: - specifier: ^2.0.0 - version: 2.0.0 watchpack: specifier: ^2.4.0 version: 2.4.0 @@ -31,9 +28,6 @@ devDependencies: '@types/estree': specifier: ^0.0.45 version: 0.0.45 - '@types/hash-sum': - specifier: ^1.0.0 - version: 1.0.0 '@types/jest': specifier: ^26.0.13 version: 26.0.13 @@ -1627,10 +1621,6 @@ packages: '@types/node': 14.10.1 dev: true - /@types/hash-sum@1.0.0: - resolution: {integrity: sha512-FdLBT93h3kcZ586Aee66HPCVJ6qvxVjBlDWNmxSGSbCZe9hTsjRKdSsl4y1T+3zfujxo9auykQMnFsfyHWD7wg==} - dev: true - /@types/html-minifier-terser@5.1.1: resolution: {integrity: sha512-giAlZwstKbmvMk1OO7WXSj4OZ0keXAcl2TQq4LWHiiPH2ByaH7WeUzng+Qej8UPxxv+8lRTuouo0iaNDBuzIBA==} dev: true @@ -4995,10 +4985,6 @@ packages: safe-buffer: 5.2.1 dev: true - /hash-sum@2.0.0: - resolution: {integrity: sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==} - dev: false - /hash.js@1.1.7: resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} dependencies: diff --git a/src/index.ts b/src/index.ts index 380e1246..890dc1cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,8 @@ import type { LoaderContext } from 'webpack' import * as path from 'path' +import * as crypto from 'crypto' import * as qs from 'querystring' -import hash = require('hash-sum') - import { compiler } from './compiler' import type { TemplateCompiler, @@ -66,6 +65,10 @@ let errorEmitted = false const { parse } = compiler const exportHelperPath = require.resolve('./exportHelper') +function hash(text: string): string { + return crypto.createHash('sha256').update(text).digest('hex').substring(0, 8) +} + export default function loader( this: LoaderContext, source: string diff --git a/test/utils.ts b/test/utils.ts index 51efa05f..836f4ef3 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -1,14 +1,18 @@ /* env jest */ import * as path from 'path' +import * as crypto from 'crypto' import webpack from 'webpack' import merge from 'webpack-merge' -import hash from 'hash-sum' // import MiniCssExtractPlugin from 'mini-css-extract-plugin' import { fs as mfs } from 'memfs' import { JSDOM, VirtualConsole } from 'jsdom' import { VueLoaderPlugin } from '..' import type { VueLoaderOptions } from '..' +function hash(text: string): string { + return crypto.createHash('sha256').update(text).digest('hex').substring(0, 8) +} + export const DEFAULT_VUE_USE = { loader: 'vue-loader', options: {