1
- import { addTemplate , tryResolveModule } from '@nuxt/kit'
1
+ import { addTemplate , createResolver } from '@nuxt/kit'
2
2
import { stringifyImports } from 'unimport'
3
3
import type { Import } from 'unimport'
4
4
import type { Nuxt } from '@nuxt/schema'
@@ -8,9 +8,10 @@ import type { ESLintConfigGenAddon } from '../types'
8
8
import type { NuxtESLintConfigOptions } from '@nuxt/eslint-config/flat'
9
9
import type { ConfigGenOptions , ModuleOptions } from '../module'
10
10
import { createAddonGlobals } from '../config-addons/globals'
11
- import { isAbsolute } from 'path'
12
11
import { pathToFileURL } from 'url'
13
12
13
+ const r = createResolver ( import . meta. url )
14
+
14
15
export async function setupConfigGen ( options : ModuleOptions , nuxt : Nuxt ) {
15
16
const defaultAddons = [
16
17
createAddonGlobals ( nuxt ) ,
@@ -97,16 +98,10 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
97
98
configItems . push ( ...resolved . configs )
98
99
}
99
100
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
-
106
101
const imports = await Promise . all ( importLines . map ( async ( line ) : Promise < Import > => {
107
102
return {
108
103
...line ,
109
- from : pathToFileURL ( await resolveModule ( line . from ) ) . toString ( ) ,
104
+ from : pathToFileURL ( await r . resolvePath ( line . from ) ) . toString ( ) ,
110
105
}
111
106
} ) )
112
107
0 commit comments