Skip to content

Import attributes are not passed to resolveId if dynamic import regex matches #21394

@edoardocavazza

Description

@edoardocavazza

Describe the bug

I am authoring a plugin for constructable CSS modules but I've encountered this problem with sources that include dynamic imports (even when part of a comment). In this case, Vite doesn't pass the attributes to the resolveId hook.

Reproduction

https://stackblitz.com/edit/stackblitz-starters-e5w5q9xi?file=src%2Fdynamic.js

Steps to reproduce

  • Run npm install
  • Run node index.js
  • The run fails.
  • Remove both comments in the dynamic.js file
  • Run node index.js again
  • The run succeed.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @rollup/wasm-node:  4.55.1 
    vite: ^7.3.1 => 7.3.1

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions