fix(vite): use pathToFileURL for externals (#819)

This commit is contained in:
pooya parsa 2021-10-12 20:01:27 +02:00 committed by GitHub
parent f0d23d13d4
commit 47ea41dadb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { builtinModules } from 'module' import { builtinModules } from 'module'
import { pathToFileURL } from 'url'
import { join } from 'pathe' import { join } from 'pathe'
import * as vite from 'vite' import * as vite from 'vite'
import { hashId, uniq } from './utils' import { hashId, uniq } from './utils'
@ -57,7 +58,7 @@ async function transformRequest (opts: TransformOptions, id: string) {
// Externals // Externals
if (isExternal(opts, id)) { if (isExternal(opts, id)) {
return { return {
code: `(global, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) => import('${id}').then(r => { ssrExportAll(r) })`, code: `(global, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) => import('${(pathToFileURL(id))}').then(r => { ssrExportAll(r) })`,
deps: [], deps: [],
dynamicDeps: [] dynamicDeps: []
} }