mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-25 10:08:29 +00:00
chore(deps): update dependency ohash to v2 (3.x) (#31051)
This commit is contained in:
parent
4d010c30de
commit
f709e5730b
@ -57,7 +57,6 @@
|
||||
"magic-string": "^0.30.17",
|
||||
"memfs": "4.14.1",
|
||||
"nuxt": "workspace:*",
|
||||
"ohash": "1.1.4",
|
||||
"postcss": "8.5.3",
|
||||
"rollup": "4.34.8",
|
||||
"send": ">=1.1.0",
|
||||
|
@ -37,7 +37,7 @@
|
||||
"klona": "^2.0.6",
|
||||
"knitwork": "^1.2.0",
|
||||
"mlly": "^1.7.4",
|
||||
"ohash": "^1.1.4",
|
||||
"ohash": "^2.0.4",
|
||||
"pathe": "^2.0.3",
|
||||
"pkg-types": "^1.3.1",
|
||||
"scule": "^1.3.0",
|
||||
|
@ -108,7 +108,7 @@
|
||||
"nitropack": "^2.10.4",
|
||||
"nypm": "^0.5.4",
|
||||
"ofetch": "^1.4.1",
|
||||
"ohash": "^1.1.4",
|
||||
"ohash": "^2.0.4",
|
||||
"on-change": "^5.0.1",
|
||||
"pathe": "^2.0.3",
|
||||
"perfect-debounce": "^1.0.0",
|
||||
|
@ -86,7 +86,7 @@ export default defineComponent({
|
||||
const config = useRuntimeConfig()
|
||||
const nuxtApp = useNuxtApp()
|
||||
const filteredProps = computed(() => props.props ? Object.fromEntries(Object.entries(props.props).filter(([key]) => !key.startsWith('data-v-'))) : {})
|
||||
const hashId = computed(() => hash([props.name, filteredProps.value, props.context, props.source]))
|
||||
const hashId = computed(() => hash([props.name, filteredProps.value, props.context, props.source]).replace(/[-_]/g, ''))
|
||||
const instance = getCurrentInstance()!
|
||||
const event = useRequestEvent()
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { parse, serialize } from 'cookie-es'
|
||||
import { deleteCookie, getCookie, getRequestHeader, setCookie } from 'h3'
|
||||
import type { H3Event } from 'h3'
|
||||
import destr from 'destr'
|
||||
import { isEqual } from 'ohash'
|
||||
import { hash } from 'ohash'
|
||||
import { klona } from 'klona'
|
||||
import { useNuxtApp } from '../nuxt'
|
||||
import { useRequestEvent } from './ssr'
|
||||
@ -75,7 +75,7 @@ export function useCookie<T = string | null | undefined> (name: string, _opts?:
|
||||
// or running in an iframe: see https://github.com/nuxt/nuxt/issues/26338
|
||||
}
|
||||
const callback = () => {
|
||||
if (opts.readonly || isEqual(cookie.value, cookies[name])) { return }
|
||||
if (opts.readonly || hash(cookie.value) === hash(cookies[name])) { return }
|
||||
writeClientCookie(name, cookie.value, opts as CookieSerializeOptions)
|
||||
|
||||
cookies[name] = klona(cookie.value)
|
||||
@ -136,11 +136,11 @@ export function useCookie<T = string | null | undefined> (name: string, _opts?:
|
||||
} else if (import.meta.server) {
|
||||
const nuxtApp = useNuxtApp()
|
||||
const writeFinalCookieValue = () => {
|
||||
if (opts.readonly || isEqual(cookie.value, cookies[name])) { return }
|
||||
if (opts.readonly || hash(cookie.value) === hash(cookies[name])) { return }
|
||||
nuxtApp._cookies ||= {}
|
||||
if (name in nuxtApp._cookies) {
|
||||
// do not append a second `set-cookie` header
|
||||
if (isEqual(cookie.value, nuxtApp._cookies[name])) { return }
|
||||
if (hash(cookie.value) === hash(nuxtApp._cookies[name])) { return }
|
||||
// warn in dev mode
|
||||
if (import.meta.dev) {
|
||||
console.warn(`[nuxt] cookie \`${name}\` was previously set to \`${opts.encode(nuxtApp._cookies[name] as any)}\` and is being overridden to \`${opts.encode(cookie.value as any)}\`. This may cause unexpected issues.`)
|
||||
|
@ -4,7 +4,7 @@ import { resolve } from 'node:path'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { createIsIgnored } from '@nuxt/kit'
|
||||
import type { Nuxt, NuxtConfig, NuxtConfigLayer } from '@nuxt/schema'
|
||||
import { hash, murmurHash, objectHash } from 'ohash'
|
||||
import { hash, serialize } from 'ohash'
|
||||
import { glob } from 'tinyglobby'
|
||||
import { consola } from 'consola'
|
||||
import { dirname, join, relative } from 'pathe'
|
||||
@ -107,7 +107,7 @@ async function getHashes (nuxt: Nuxt, options: GetHashOptions): Promise<Hashes>
|
||||
const layerName = `layer#${layerCtr++}`
|
||||
hashSources.push({
|
||||
name: `${layerName}:config`,
|
||||
data: objectHash({
|
||||
data: serialize({
|
||||
...layer.config,
|
||||
...options.configOverrides || {},
|
||||
}),
|
||||
@ -115,8 +115,8 @@ async function getHashes (nuxt: Nuxt, options: GetHashOptions): Promise<Hashes>
|
||||
|
||||
const normalizeFiles = (files: Awaited<ReturnType<typeof readFilesRecursive>>) => files.map(f => ({
|
||||
name: f.name,
|
||||
size: (f.attrs as any)?.size,
|
||||
data: murmurHash(f.data as any /* ArrayBuffer */),
|
||||
size: f.attrs?.size,
|
||||
data: hash(f.data),
|
||||
}))
|
||||
|
||||
const isIgnored = createIsIgnored(nuxt)
|
||||
|
@ -108,7 +108,7 @@ export const ComposableKeysPlugin = (options: ComposableKeysOptions) => createUn
|
||||
|
||||
s.appendLeft(
|
||||
codeIndex + (node as any).end - 1,
|
||||
(node.arguments.length && !endsWithComma ? ', ' : '') + '\'$' + hash(`${relativeID}-${++count}`) + '\'',
|
||||
(node.arguments.length && !endsWithComma ? ', ' : '') + '\'$' + hash(`${relativeID}-${++count}`).slice(0, 10) + '\'',
|
||||
)
|
||||
},
|
||||
})
|
||||
|
@ -33,7 +33,7 @@ export function PrehydrateTransformPlugin (options: { sourcemap?: boolean } = {}
|
||||
const cleaned = result.slice('forEach'.length).replace(/;\s+$/, '')
|
||||
const args = [JSON.stringify(cleaned)]
|
||||
if (needsAttr) {
|
||||
args.push(JSON.stringify(hash(result)))
|
||||
args.push(JSON.stringify(hash(result).slice(0, 10)))
|
||||
}
|
||||
s.overwrite(callback.start, callback.end, args.join(', '))
|
||||
}))
|
||||
|
@ -68,7 +68,7 @@ export const clientPluginTemplate: NuxtTemplate = {
|
||||
const imports: string[] = []
|
||||
for (const plugin of clientPlugins) {
|
||||
const path = relative(ctx.nuxt.options.rootDir, plugin.src)
|
||||
const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path)
|
||||
const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path).replace(/-/g, '_')
|
||||
exports.push(variable)
|
||||
imports.push(genImport(plugin.src, variable))
|
||||
}
|
||||
@ -88,7 +88,7 @@ export const serverPluginTemplate: NuxtTemplate = {
|
||||
const imports: string[] = []
|
||||
for (const plugin of serverPlugins) {
|
||||
const path = relative(ctx.nuxt.options.rootDir, plugin.src)
|
||||
const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path)
|
||||
const variable = genSafeVariableName(filename(plugin.src) || path).replace(PLUGIN_TEMPLATE_RE, '_') + '_' + hash(path).replace(/-/g, '_')
|
||||
exports.push(variable)
|
||||
imports.push(genImport(plugin.src, variable))
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ useAsyncData(() => {})
|
||||
}),
|
||||
}, code, 'plugin.ts')?.code.trim()).toMatchInlineSnapshot(`
|
||||
"import { useAsyncData } from '#app'
|
||||
useAsyncData(() => {}, '$yXewDLZblH')"
|
||||
useAsyncData(() => {}, '$HJiaryoL2y')"
|
||||
`)
|
||||
})
|
||||
|
||||
|
@ -280,13 +280,13 @@ describe('normalizeRoutes', () => {
|
||||
expect({ routes, imports }).toMatchInlineSnapshot(`
|
||||
{
|
||||
"imports": Set {
|
||||
"import { default as indexN6pT4Un8hYMeta } from "/app/pages/index.vue?macro=true";",
|
||||
"import { default as indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta } from "/app/pages/index.vue?macro=true";",
|
||||
},
|
||||
"routes": "[
|
||||
{
|
||||
name: "some-custom-name",
|
||||
path: indexN6pT4Un8hYMeta?.path ?? "/",
|
||||
meta: { ...(indexN6pT4Un8hYMeta || {}), ...{"layout":"test","foo":"bar"} },
|
||||
path: indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta?.path ?? "/",
|
||||
meta: { ...(indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta || {}), ...{"layout":"test","foo":"bar"} },
|
||||
redirect: "/",
|
||||
component: () => import("/app/pages/index.vue")
|
||||
}
|
||||
@ -309,16 +309,16 @@ describe('normalizeRoutes', () => {
|
||||
expect({ routes, imports }).toMatchInlineSnapshot(`
|
||||
{
|
||||
"imports": Set {
|
||||
"import { default as indexN6pT4Un8hYMeta } from "/app/pages/index.vue?macro=true";",
|
||||
"import { default as indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta } from "/app/pages/index.vue?macro=true";",
|
||||
},
|
||||
"routes": "[
|
||||
{
|
||||
name: indexN6pT4Un8hYMeta?.name ?? undefined,
|
||||
path: indexN6pT4Un8hYMeta?.path ?? "/",
|
||||
props: indexN6pT4Un8hYMeta?.props ?? false,
|
||||
meta: { ...(indexN6pT4Un8hYMeta || {}), ...{"layout":"test","foo":"bar"} },
|
||||
alias: indexN6pT4Un8hYMeta?.alias || [],
|
||||
redirect: indexN6pT4Un8hYMeta?.redirect,
|
||||
name: indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta?.name ?? undefined,
|
||||
path: indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta?.path ?? "/",
|
||||
props: indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta?.props ?? false,
|
||||
meta: { ...(indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta || {}), ...{"layout":"test","foo":"bar"} },
|
||||
alias: indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta?.alias || [],
|
||||
redirect: indexndqPXFtP262szLmLJV4PriPTgAg5k_457f05QyTfosBXQMeta?.redirect,
|
||||
component: () => import("/app/pages/index.vue")
|
||||
}
|
||||
]",
|
||||
|
@ -35,6 +35,6 @@ onPrehydrate((attr) => {
|
||||
`
|
||||
|
||||
const { code } = await transformPlugin.transform(snippet, 'test.ts') ?? {}
|
||||
expect(code?.trim()).toMatchInlineSnapshot(`"onPrehydrate("(o=>{console.log(\\"hello world\\")})", "rifMBArY0d")"`)
|
||||
expect(code?.trim()).toMatchInlineSnapshot(`"onPrehydrate("(o=>{console.log(\\"hello world\\")})", "mcDYwfgR1x")"`)
|
||||
})
|
||||
})
|
||||
|
@ -48,7 +48,7 @@
|
||||
"knitwork": "^1.2.0",
|
||||
"magic-string": "^0.30.17",
|
||||
"memfs": "^4.14.1",
|
||||
"ohash": "^1.1.4",
|
||||
"ohash": "^2.0.4",
|
||||
"pathe": "^2.0.3",
|
||||
"pify": "^6.1.0",
|
||||
"postcss": "^8.5.3",
|
||||
|
@ -48,7 +48,7 @@
|
||||
"knitwork": "^1.2.0",
|
||||
"magic-string": "^0.30.17",
|
||||
"mlly": "^1.7.4",
|
||||
"ohash": "^1.1.4",
|
||||
"ohash": "^2.0.4",
|
||||
"pathe": "^2.0.3",
|
||||
"perfect-debounce": "^1.0.0",
|
||||
"pkg-types": "^1.3.1",
|
||||
|
@ -46,7 +46,7 @@
|
||||
"magic-string": "^0.30.17",
|
||||
"memfs": "^4.14.1",
|
||||
"mini-css-extract-plugin": "^2.9.2",
|
||||
"ohash": "^1.1.4",
|
||||
"ohash": "^2.0.4",
|
||||
"pathe": "^2.0.3",
|
||||
"pify": "^6.1.0",
|
||||
"postcss": "^8.5.3",
|
||||
|
@ -25,7 +25,6 @@ overrides:
|
||||
magic-string: ^0.30.17
|
||||
memfs: 4.14.1
|
||||
nuxt: workspace:*
|
||||
ohash: 1.1.4
|
||||
postcss: 8.5.3
|
||||
rollup: 4.34.8
|
||||
send: '>=1.1.0'
|
||||
@ -261,8 +260,8 @@ importers:
|
||||
specifier: ^1.7.4
|
||||
version: 1.7.4
|
||||
ohash:
|
||||
specifier: 1.1.4
|
||||
version: 1.1.4
|
||||
specifier: ^2.0.4
|
||||
version: 2.0.4
|
||||
pathe:
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
@ -445,8 +444,8 @@ importers:
|
||||
specifier: ^1.4.1
|
||||
version: 1.4.1
|
||||
ohash:
|
||||
specifier: 1.1.4
|
||||
version: 1.1.4
|
||||
specifier: ^2.0.4
|
||||
version: 2.0.4
|
||||
on-change:
|
||||
specifier: ^5.0.1
|
||||
version: 5.0.1
|
||||
@ -605,8 +604,8 @@ importers:
|
||||
specifier: 4.14.1
|
||||
version: 4.14.1
|
||||
ohash:
|
||||
specifier: 1.1.4
|
||||
version: 1.1.4
|
||||
specifier: ^2.0.4
|
||||
version: 2.0.4
|
||||
pathe:
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
@ -925,8 +924,8 @@ importers:
|
||||
specifier: ^1.7.4
|
||||
version: 1.7.4
|
||||
ohash:
|
||||
specifier: 1.1.4
|
||||
version: 1.1.4
|
||||
specifier: ^2.0.4
|
||||
version: 2.0.4
|
||||
pathe:
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
@ -959,7 +958,7 @@ importers:
|
||||
version: 6.1.1(@types/node@22.13.5)(jiti@2.4.2)(sass@1.78.0)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)
|
||||
vite-node:
|
||||
specifier: ^3.0.6
|
||||
version: 3.0.6(@types/node@22.13.5)(jiti@2.4.2)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)
|
||||
version: 3.0.7(@types/node@22.13.5)(jiti@2.4.2)(sass@1.78.0)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0)
|
||||
vite-plugin-checker:
|
||||
specifier: ^0.9.0
|
||||
version: 0.9.0(eslint@9.21.0(jiti@2.4.2))(optionator@0.9.4)(typescript@5.7.3)(vite@6.1.1(@types/node@22.13.5)(jiti@2.4.2)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0))(vue-tsc@2.2.4(typescript@5.7.3))
|
||||
@ -1031,8 +1030,8 @@ importers:
|
||||
specifier: ^2.9.2
|
||||
version: 2.9.2(webpack@5.96.1)
|
||||
ohash:
|
||||
specifier: 1.1.4
|
||||
version: 1.1.4
|
||||
specifier: ^2.0.4
|
||||
version: 2.0.4
|
||||
pathe:
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
@ -5881,6 +5880,9 @@ packages:
|
||||
ohash@1.1.4:
|
||||
resolution: {integrity: sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==}
|
||||
|
||||
ohash@2.0.4:
|
||||
resolution: {integrity: sha512-ac+SFwzhdHb0hp48/dbR7Jta39qfbuj7t3hApd9uyHS8bisHTfVzSEvjOVgV0L3zG7VR2/7JjkSGimP75D+hOQ==}
|
||||
|
||||
on-change@5.0.1:
|
||||
resolution: {integrity: sha512-n7THCP7RkyReRSLkJb8kUWoNsxUIBxTkIp3JKno+sEz6o/9AJ3w3P9fzQkITEkMwyTKJjZciF3v/pVoouxZZMg==}
|
||||
engines: {node: '>=18'}
|
||||
@ -8698,7 +8700,7 @@ snapshots:
|
||||
listhen: 1.9.0
|
||||
nypm: 0.5.4
|
||||
ofetch: 1.4.1
|
||||
ohash: 1.1.4
|
||||
ohash: 2.0.4
|
||||
pathe: 2.0.3
|
||||
perfect-debounce: 1.0.0
|
||||
pkg-types: 1.3.1
|
||||
@ -10618,7 +10620,7 @@ snapshots:
|
||||
giget: 1.2.4
|
||||
jiti: 2.4.2
|
||||
mlly: 1.7.4
|
||||
ohash: 1.1.4
|
||||
ohash: 2.0.4
|
||||
pathe: 2.0.3
|
||||
perfect-debounce: 1.0.0
|
||||
pkg-types: 1.3.1
|
||||
@ -13481,6 +13483,8 @@ snapshots:
|
||||
|
||||
ohash@1.1.4: {}
|
||||
|
||||
ohash@2.0.4: {}
|
||||
|
||||
on-change@5.0.1: {}
|
||||
|
||||
on-finished@2.4.1:
|
||||
@ -15384,7 +15388,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@vitest/expect': 3.0.6
|
||||
'@vitest/mocker': 3.0.6(vite@6.1.1(@types/node@22.13.5)(jiti@2.4.2)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0))
|
||||
'@vitest/pretty-format': 3.0.6
|
||||
'@vitest/pretty-format': 3.0.7
|
||||
'@vitest/runner': 3.0.6
|
||||
'@vitest/snapshot': 3.0.6
|
||||
'@vitest/spy': 3.0.6
|
||||
|
@ -79,7 +79,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
||||
const serverDir = join(rootDir, '.output-inline/server')
|
||||
|
||||
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"566k"`)
|
||||
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"567k"`)
|
||||
|
||||
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
|
||||
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"101k"`)
|
||||
|
Loading…
Reference in New Issue
Block a user