Skip to content

Commit 2efd732

Browse files
richard-dpantfuautofix-ci[bot]
authoredMar 29, 2024
fix: windows path resolution (#369)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent e6dd7b2 commit 2efd732

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed
 

‎packages/module/src/modules/config.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addTemplate, tryResolveModule } from '@nuxt/kit'
1+
import { addTemplate, createResolver } from '@nuxt/kit'
22
import { stringifyImports } from 'unimport'
33
import type { Import } from 'unimport'
44
import type { Nuxt } from '@nuxt/schema'
@@ -8,9 +8,10 @@ import type { ESLintConfigGenAddon } from '../types'
88
import type { NuxtESLintConfigOptions } from '@nuxt/eslint-config/flat'
99
import type { ConfigGenOptions, ModuleOptions } from '../module'
1010
import { createAddonGlobals } from '../config-addons/globals'
11-
import { isAbsolute } from 'path'
1211
import { pathToFileURL } from 'url'
1312

13+
const r = createResolver(import.meta.url)
14+
1415
export async function setupConfigGen(options: ModuleOptions, nuxt: Nuxt) {
1516
const defaultAddons = [
1617
createAddonGlobals(nuxt),
@@ -97,16 +98,10 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
9798
configItems.push(...resolved.configs)
9899
}
99100

100-
async function resolveModule(id: string) {
101-
if (id && (id.includes('://') || isAbsolute(id)))
102-
return id
103-
return await tryResolveModule(id, import.meta.url) || id
104-
}
105-
106101
const imports = await Promise.all(importLines.map(async (line): Promise<Import> => {
107102
return {
108103
...line,
109-
from: pathToFileURL(await resolveModule(line.from)).toString(),
104+
from: pathToFileURL(await r.resolvePath(line.from)).toString(),
110105
}
111106
}))
112107

0 commit comments

Comments
 (0)