Skip to content

Commit

Permalink
fix: use file urls for auto-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 6, 2022
1 parent f08708d commit e1a5caf
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit e1a5caf

Please sign in to comment.