fix(vite): remove relative vite workaround (#1646)

This commit is contained in:
Daniel Roe 2021-11-04 11:25:46 +00:00 committed by GitHub
parent 875deefafc
commit 2166661b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)) {