Skip to content

Commit

Permalink
fix(module): don't resolve path for native modules
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 29, 2024
1 parent 3aec602 commit 5715ea2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/module/src/modules/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { addTemplate, createResolver } from '@nuxt/kit'
import { pathToFileURL } from 'node:url'
import { builtinModules } from 'node:module'
import { stringifyImports } from 'unimport'
import type { Import } from 'unimport'
import type { Nuxt } from '@nuxt/schema'
Expand All @@ -8,7 +10,6 @@ import type { ESLintConfigGenAddon } from '../types'
import type { NuxtESLintConfigOptions } from '@nuxt/eslint-config/flat'
import type { ConfigGenOptions, ModuleOptions } from '../module'
import { createAddonGlobals } from '../config-addons/globals'
import { pathToFileURL } from 'url'

const r = createResolver(import.meta.url)

Expand Down Expand Up @@ -101,7 +102,9 @@ async function generateESLintConfig(options: ModuleOptions, nuxt: Nuxt, addons:
const imports = await Promise.all(importLines.map(async (line): Promise<Import> => {
return {
...line,
from: pathToFileURL(await r.resolvePath(line.from)).toString(),
from: (line.from.match(/^\w+:/) || builtinModules.includes(line.from))
? line.from
: pathToFileURL(await r.resolvePath(line.from)).toString(),
}
}))

Expand Down

0 comments on commit 5715ea2

Please sign in to comment.