Skip to content

import.meta.glob triggers dependency scan failure #22340

Description

@LankyMoose

Describe the bug

See here: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/optimizer/scan.ts#L399

Not sure why but we aren't passing any user/plugin-specified transform options. This has caused me to be able to reproducibly cause the following error.

(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error: The following dependencies are imported but could not be resolved:

  react/jsx-runtime (imported by C:/repos/vite-8-transform-bug-repro/src/main.tsx)

Are they installed?
    at file:///C:/repos/vite-8-transform-bug-repro/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/node.js:31398:33
    at async file:///C:/repos/vite-8-transform-bug-repro/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/node.js:23222:15

this is despite having specified the following config:

import { defineConfig } from "vite";

export default defineConfig({
  oxc: {
    jsx: {
      pragma: "_jsx",
      pragmaFrag: "_jsxFragment",
      importSource: "kiru",
      runtime: "automatic",
    },
  },
});

Issue is solved by adding the following (I'm sure this is not the correct approach, but it does work):

const result = transformSync(id, contents, {
  lang: loader,
  tsconfig: false,
  ...environment.pluginContainer._resolvedRollupOptions.transform // this
});

Reproduction

https://github.com/LankyMoose/vite-8-transform-bug-repro

Steps to reproduce

To reproduce:

  • install deps
  • run 'dev' script
  • should error. only happens once.

To repeat, delete node_modules/.vite, and run dev again.

System Info

System:
    OS: Windows 11 10.0.26200
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz
    Memory: 2.36 GB / 15.79 GB
  Binaries:
    Node: 22.20.0 - C:\Users\rob\AppData\Local\pnpm\node.EXE
    npm: 10.9.3 - C:\Users\rob\AppData\Local\pnpm\npm.CMD
    pnpm: 10.28.0 - C:\Users\rob\AppData\Local\pnpm\pnpm.CMD
    bun: 1.3.5 - C:\Users\rob\.bun\bin\bun.EXE
  Browsers:
    Chrome: 147.0.7727.103
    Edge: Chromium (140.0.3485.54)
  npmPackages:
    vite: ^8.0.10 => 8.0.10

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: deps optimizerDependencies Optimizationp2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions