From 2166661b1781a98dcc736a8b3262704d18b89655 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 4 Nov 2021 11:25:46 +0000 Subject: [PATCH] fix(vite): remove relative vite workaround (#1646) --- packages/vite/src/dev-bundler.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/dev-bundler.ts b/packages/vite/src/dev-bundler.ts index fbc53ceb75..fc2e47a6ae 100644 --- a/packages/vite/src/dev-bundler.ts +++ b/packages/vite/src/dev-bundler.ts @@ -1,4 +1,6 @@ import { pathToFileURL } from 'url' +import { existsSync } from 'fs' +import { resolve } from 'pathe' import * as vite from 'vite' import { ExternalsOptions, isExternal as _isExternal, ExternalsDefaults } from 'externality' import { hashId, uniq } from './utils' @@ -61,7 +63,10 @@ async function transformRequest (opts: TransformOptions, id: string) { } } else if (!id.includes('entry') && id.startsWith('/')) { // Relative to the root directory - id = '.' + id + const resolvedPath = resolve(opts.viteServer.config.root, '.' + id) + if (existsSync(resolvedPath)) { + id = resolvedPath + } } if (await isExternal(opts, id)) {