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: use file urls for auto-imports in development #733

Merged
merged 1 commit into from
Dec 6, 2022
Merged
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
12 changes: 11 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { resolve, join } from 'pathe'
import { pathToFileURL } from 'node:url'
import { resolve, join, isAbsolute } from 'pathe'
import { loadConfig } from 'c12'
import { klona } from 'klona/full'
import { camelCase } from 'scule'
Expand Down Expand Up @@ -167,6 +168,15 @@ export async function loadOptions (configOverrides: NitroConfig = {}): Promise<N
options.imports.exclude.push(options.buildDir)
}

// Normalise absolute auto-import paths for windows machines
if (options.imports && options.dev) {
for (const entry of options.imports.imports) {
if (isAbsolute(entry.from)) {
entry.from = pathToFileURL(entry.from).href
}
}
}

// Add h3 auto imports preset
if (options.imports) {
const h3Exports = await resolveModuleExportNames('h3', { url: import.meta.url })
Expand Down