Skip to content

Commit a1c4cc1

Browse files
committed
refactor: align hash() with vite plugin
1 parent fb9656c commit a1c4cc1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { LoaderContext } from 'webpack'
22
import * as path from 'path'
3+
import * as crypto from 'crypto'
34
import * as qs from 'querystring'
45

5-
import hash = require('hash-sum')
6-
76
import { compiler } from './compiler'
87
import type {
98
TemplateCompiler,
@@ -66,6 +65,10 @@ let errorEmitted = false
6665
const { parse } = compiler
6766
const exportHelperPath = require.resolve('./exportHelper')
6867

68+
function hash(text: string): string {
69+
return crypto.createHash('sha256').update(text).digest('hex').substring(0, 8)
70+
}
71+
6972
export default function loader(
7073
this: LoaderContext<VueLoaderOptions>,
7174
source: string

test/utils.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
/* env jest */
22
import * as path from 'path'
3+
import * as crypto from 'crypto'
34
import webpack from 'webpack'
45
import merge from 'webpack-merge'
5-
import hash from 'hash-sum'
66
// import MiniCssExtractPlugin from 'mini-css-extract-plugin'
77
import { fs as mfs } from 'memfs'
88
import { JSDOM, VirtualConsole } from 'jsdom'
99
import { VueLoaderPlugin } from '..'
1010
import type { VueLoaderOptions } from '..'
1111

12+
function hash(text: string): string {
13+
return crypto.createHash('sha256').update(text).digest('hex').substring(0, 8)
14+
}
15+
1216
export const DEFAULT_VUE_USE = {
1317
loader: 'vue-loader',
1418
options: {

0 commit comments

Comments
 (0)