Skip to content

Commit 32cc67c

Browse files
authored
Merge branch 'main' into renovate/npm-serve-static-vulnerability
2 parents cca8b26 + 9265388 commit 32cc67c

File tree

6 files changed

+160
-101
lines changed

6 files changed

+160
-101
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"picocolors": "^1.0.1",
5757
"playwright-chromium": "^1.46.1",
5858
"prettier": "3.3.3",
59-
"rollup": "^4.21.3",
59+
"rollup": "^4.24.0",
6060
"simple-git-hooks": "^2.11.1",
6161
"tsx": "^4.19.0",
6262
"typescript": "^5.5.4",

packages/plugin-vue-jsx/src/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createHash } from 'node:crypto'
1+
import crypto from 'node:crypto'
22
import path from 'node:path'
33
import type { types } from '@babel/core'
44
import * as babel from '@babel/core'
@@ -293,8 +293,17 @@ function isDefineComponentCall(
293293
)
294294
}
295295

296+
const hash =
297+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- crypto.hash is supported in Node 21.7.0+, 20.12.0+
298+
crypto.hash ??
299+
((
300+
algorithm: string,
301+
data: crypto.BinaryLike,
302+
outputEncoding: crypto.BinaryToTextEncoding,
303+
) => crypto.createHash(algorithm).update(data).digest(outputEncoding))
304+
296305
function getHash(text: string) {
297-
return createHash('sha256').update(text).digest('hex').substring(0, 8)
306+
return hash('sha256', text, 'hex').substring(0, 8)
298307
}
299308

300309
export default vueJsxPlugin

packages/plugin-vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@jridgewell/gen-mapping": "^0.3.5",
4343
"@jridgewell/trace-mapping": "^0.3.25",
4444
"debug": "^4.3.6",
45-
"rollup": "^4.21.3",
45+
"rollup": "^4.24.0",
4646
"slash": "^5.1.0",
4747
"source-map-js": "^1.2.0",
4848
"vite": "catalog:",

packages/plugin-vue/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function transformMain(
5050
// for vue files, create descriptor from fs read to be consistent with
5151
// logic in handleHotUpdate()
5252
// for non vue files, e.g. md files in vitepress, we assume
53-
// `hmrContext.read` is overwriten so handleHotUpdate() is dealing with
53+
// `hmrContext.read` is overwritten so handleHotUpdate() is dealing with
5454
// post-transform code, so we populate the descriptor with post-transform
5555
// code here as well.
5656
filename.endsWith('.vue') ? undefined : code,

packages/plugin-vue/src/utils/descriptorCache.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
3-
import { createHash } from 'node:crypto'
3+
import crypto from 'node:crypto'
44
import type { CompilerError, SFCDescriptor } from 'vue/compiler-sfc'
55
import { normalizePath } from 'vite'
66
import type { ResolvedOptions, VueQuery } from '../index'
@@ -120,6 +120,15 @@ export function setSrcDescriptor(
120120
cache.set(filename, entry)
121121
}
122122

123+
const hash =
124+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- crypto.hash is supported in Node 21.7.0+, 20.12.0+
125+
crypto.hash ??
126+
((
127+
algorithm: string,
128+
data: crypto.BinaryLike,
129+
outputEncoding: crypto.BinaryToTextEncoding,
130+
) => crypto.createHash(algorithm).update(data).digest(outputEncoding))
131+
123132
function getHash(text: string): string {
124-
return createHash('sha256').update(text).digest('hex').substring(0, 8)
133+
return hash('sha256', text, 'hex').substring(0, 8)
125134
}

0 commit comments

Comments
 (0)