diff --git a/packages/vite/src/dev-bundler.ts b/packages/vite/src/dev-bundler.ts index 36748427ef..6cd3db677d 100644 --- a/packages/vite/src/dev-bundler.ts +++ b/packages/vite/src/dev-bundler.ts @@ -1,4 +1,5 @@ import { builtinModules } from 'module' +import { pathToFileURL } from 'url' import { join } from 'pathe' import * as vite from 'vite' import { hashId, uniq } from './utils' @@ -57,7 +58,7 @@ async function transformRequest (opts: TransformOptions, id: string) { // Externals if (isExternal(opts, id)) { 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: [], dynamicDeps: [] }