Skip to content

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

Closed as duplicate

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

Activity

  1. edoardocavazza commented on Jan 13, 2026

    @edoardocavazza
    Author

    I think I found the "culprit":

    // strip import attributes as we can process them ourselves

    I'm not sure why the attributes are being removed here.

  2. locked and limited conversation to collaborators on Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions