Skip to content

Commit

Permalink
fix: optimize the splicing method of serverEntry to make it compatibl…
Browse files Browse the repository at this point in the history
…e with bun (#398)
  • Loading branch information
chengzhuo5 authored Apr 25, 2024
1 parent 7ef969c commit ee56cf0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ export async function build(ssgOptions: Partial<ViteSSGOptions> = {}, viteConfig

const prefix = (format === 'esm' && process.platform === 'win32') ? 'file://' : ''
const ext = format === 'esm' ? '.mjs' : '.cjs'
const serverEntry = join(prefix, ssgOut, parse(ssrEntry).name + ext)

/**
* `join('file://')` will be equal to `'file:\'`, which is not the correct file protocol and will fail to be parsed under bun.
* It is changed to '+' splicing here.
*/
const serverEntry = prefix + join(ssgOut, parse(ssrEntry).name + ext).replace(/\\/g, '/')

const _require = createRequire(import.meta.url)

Expand Down

0 comments on commit ee56cf0

Please sign in to comment.