From 28481748a63cc229ebb4442979198cad43d2670e Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 31 May 2024 02:11:27 +0800 Subject: [PATCH] refactor(plugin-vue): use normalizePath from vite (#395) --- 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 }