Skip to content

Commit e3ca79f

Browse files
fix(build): correct file protocol handling for Windows in server entry path
1 parent b080ed7 commit e3ca79f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node/build.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ export async function build(ssgOptions: Partial<ViteReactSSGOptions> = {}, viteC
141141

142142
const prefix = (format === 'esm' && process.platform === 'win32') ? 'file://' : ''
143143
const ext = format === 'esm' ? '.mjs' : '.cjs'
144-
const serverEntry = join(prefix, ssgOut, parse(ssrEntry).name + ext)
144+
/**
145+
* `join('file://')` will be equal to `'file:\'`, which is not the correct file protocol and will fail to be parsed under bun.
146+
* It is changed to '+' splicing here.
147+
*/
148+
const serverEntry = prefix + join(ssgOut, parse(ssrEntry).name + ext).replace(/\\/g, '/')
145149
const serverManifest: Manifest = JSON.parse(await fs.readFile(join(ssgOut, ...dotVitedir, 'manifest.json'), 'utf-8'))
146150

147151
const _require = createRequire(import.meta.url)

0 commit comments

Comments
 (0)