Skip to content

Commit

Permalink
fix: wrap dynamic import in prerender to fix windows build failure (#134
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alex-key authored Apr 22, 2022
1 parent 91e717c commit 2be8aaf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/prerender.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pathToFileURL } from 'url'
import { resolve, join } from 'pathe'
import { parseURL } from 'ufo'
import chalk from 'chalk'
Expand Down Expand Up @@ -26,7 +27,8 @@ export async function prerender (nitro: Nitro) {
await build(nitroRenderer)

// Import renderer entry
const { localFetch } = await import(resolve(nitroRenderer.options.output.serverDir, 'index.mjs'))
const serverEntrypoint = resolve(nitroRenderer.options.output.serverDir, 'index.mjs')
const { localFetch } = await import(pathToFileURL(serverEntrypoint).href)

// Start prerendering
const generatedRoutes = new Set()
Expand Down
2 changes: 1 addition & 1 deletion src/rollup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export const plugins = [
// https://github.com/rollup/plugins/tree/master/packages/alias
let buildDir = nitro.options.buildDir
// Windows (native) dynamic imports should be file:// urr
if (isWindows && (nitro.options.externals.trace === false)) {
if (isWindows && (nitro.options.externals?.trace === false)) {
buildDir = pathToFileURL(buildDir).href
}
rollupConfig.plugins.push(alias({
Expand Down

0 comments on commit 2be8aaf

Please sign in to comment.