From 8cf45249bdd12eacf0cfa72c4baf2afc8a849727 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 23 Apr 2024 12:01:53 +0800 Subject: [PATCH] refactor(plugin-vue): use vite's normalizePath for path consistency --- packages/plugin-vue/src/utils/descriptorCache.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugin-vue/src/utils/descriptorCache.ts b/packages/plugin-vue/src/utils/descriptorCache.ts index 8637430b..7f643d1b 100644 --- a/packages/plugin-vue/src/utils/descriptorCache.ts +++ b/packages/plugin-vue/src/utils/descriptorCache.ts @@ -1,8 +1,8 @@ import fs from 'node:fs' import path from 'node:path' import { createHash } from 'node:crypto' -import slash from 'slash' import type { CompilerError, SFCDescriptor } from 'vue/compiler-sfc' +import { normalizePath } from 'vite' import type { ResolvedOptions, VueQuery } from '..' // compiler-sfc should be exported so it can be re-used @@ -33,7 +33,7 @@ export function createDescriptor( // ensure the path is normalized in a way that is consistent inside // project (relative to root) and on different systems. - const normalizedPath = slash(path.normalize(path.relative(root, filename))) + const normalizedPath = normalizePath(path.relative(root, filename)) descriptor.id = getHash(normalizedPath + (isProduction ? source : '')) ;(hmr ? hmrCache : cache).set(filename, descriptor) return { descriptor, errors }