Repository: nuxt/nuxt
File: packages/nuxt/src/core/plugins/resolve-deep-imports.ts (TypeScript)

Code before:
const VIRTUAL_RE = /^\0?virtual:(?:nuxt:)?/

export function resolveDeepImportsPlugin (nuxt: Nuxt): Plugin {
  const exclude: string[] = ['virtual:', '\0virtual:', '/__skip_vite', '@vitest/']
  let conditions: string[]
  let external: Set<string>

  return {
    name: 'nuxt:resolve-bare-imports',
    enforce: 'post',
    async configResolved (config) {
      const resolvedConditions = new Set([nuxt.options.dev ? 'development' : 'production', ...config.resolve.conditions])
      if (resolvedConditions.has('browser')) {
        resolvedConditions.add('web')
        resolvedConditions.add('import')
        resolvedConditions.add('module')
        resolvedConditions.add('default')
      }
      if (config.mode === 'test') {
        resolvedConditions.add('import')
        resolvedConditions.add('require')
      }
      conditions = [...resolvedConditions]

      const { runtimeDependencies = [] } = await tryImportModule<typeof import('nitro/runtime/meta')>('nitro/runtime/meta', {
        url: nuxt.options.modulesDir.map(d => directoryToURL(d)),
      }) || {}

      external = new Set([
        // explicit dependencies we use in our ssr renderer - these can be inlined (if necessary) in the nitro build
        'unhead', '@unhead/vue', 'unctx', 'h3', 'devalue', '@nuxt/devalue', 'radix3', 'rou3', 'unstorage', 'hookable',
        // ensure we only have one version of vue if nitro is going to inline anyway
        ...((nuxt as any)._nitro as Nitro).options.inlineDynamicImports ? ['vue', '@vue/server-renderer', '@unhead/vue'] : [],
        // dependencies we might share with nitro - these can be inlined (if necessary) in the nitro build
        ...runtimeDependencies,
      ])
    },
    async resolveId (id, importer) {
      if (!importer || isAbsolute(id) || (!isAbsolute(importer) && !VIRTUAL_RE.test(importer)) || exclude.some(e => id.startsWith(e))) {
        return
      }

      const overrides = external.has(id) ? { external: 'absolute' } as const : {}

      const normalisedId = resolveAlias(normalize(id), nuxt.options.alias)
      const isNuxtTemplate = importer.startsWith('virtual:nuxt')
      const normalisedImporter = (isNuxtTemplate ? decodeURIComponent(importer) : importer).replace(VIRTUAL_RE, '')

      if (nuxt.options.experimental.templateImportResolution !== false && isNuxtTemplate) {
        const template = nuxt.options.build.templates.find(t => resolve(nuxt.options.buildDir, t.filename!) === normalisedImporter)
        if (template?._path) {

Review comment (suggestion):
(nitro is explicit dep, it avoid hoisting issues with nitro pkg itself)

```suggestion
        url: import.meta.url,
```

Code after:
const VIRTUAL_RE = /^\0?virtual:(?:nuxt:)?/

export function resolveDeepImportsPlugin (nuxt: Nuxt): Plugin {
  const exclude: string[] = ['virtual:', '\0virtual:', '/__skip_vite', '@vitest/']
  let conditions: string[]
  let external: Set<string>

  return {
    name: 'nuxt:resolve-bare-imports',
    enforce: 'post',
    async configResolved (config) {
      const resolvedConditions = new Set([nuxt.options.dev ? 'development' : 'production', ...config.resolve.conditions])
      if (resolvedConditions.has('browser')) {
        resolvedConditions.add('web')
        resolvedConditions.add('import')
        resolvedConditions.add('module')
        resolvedConditions.add('default')
      }
      if (config.mode === 'test') {
        resolvedConditions.add('import')
        resolvedConditions.add('require')
      }
      conditions = [...resolvedConditions]

      const { runtimeDependencies = [] } = await tryImportModule<typeof import('nitro/runtime/meta')>('nitro/runtime/meta', {
        url: new URL(import.meta.url),
      }) || {}

      external = new Set([
        // explicit dependencies we use in our ssr renderer - these can be inlined (if necessary) in the nitro build
        'unhead', '@unhead/vue', 'unctx', 'h3', 'devalue', '@nuxt/devalue', 'radix3', 'rou3', 'unstorage', 'hookable',
        // ensure we only have one version of vue if nitro is going to inline anyway
        ...((nuxt as any)._nitro as Nitro).options.inlineDynamicImports ? ['vue', '@vue/server-renderer', '@unhead/vue'] : [],
        // dependencies we might share with nitro - these can be inlined (if necessary) in the nitro build
        ...runtimeDependencies,
      ])
    },
    async resolveId (id, importer) {
      if (!importer || isAbsolute(id) || (!isAbsolute(importer) && !VIRTUAL_RE.test(importer)) || exclude.some(e => id.startsWith(e))) {
        return
      }

      const overrides = external.has(id) ? { external: 'absolute' } as const : {}

      const normalisedId = resolveAlias(normalize(id), nuxt.options.alias)
      const isNuxtTemplate = importer.startsWith('virtual:nuxt')
      const normalisedImporter = (isNuxtTemplate ? decodeURIComponent(importer) : importer).replace(VIRTUAL_RE, '')

      if (nuxt.options.experimental.templateImportResolution !== false && isNuxtTemplate) {
        const template = nuxt.options.build.templates.find(t => resolve(nuxt.options.buildDir, t.filename!) === normalisedImporter)
        if (template?._path) {