Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrap dynamic import in prerender to fix windows build failure #134

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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