Skip to content

Dynamic imports with variables in a dependency are not processed at all #6179

@balthild

Description

@balthild

Describe the bug

Variable dynamic imports such as import(`./inc/${name}.js`) that appears in a dependency are not transpiled at all.

Maybe related to #1903.

Reproduction

https://github.com/balthild/vrt-esmdi

  • /testlib2 - The dependency that contains variable dynamic imports
  • /app - A vite app
  • /app/es - A copy of /testlib2/es

Step

  1. Clone the repo
  2. cd vrt-esmdi/app
  3. yarn && yarn build
  4. Check the build output in dist and you can find that there's nothing corresponding to /testlib2/es/inc/*.js which is dynamically imported.
  5. Edit /app/main.js and change the first line to import { testImport } from './es';
  6. yarn build
  7. Check the build output and you can find that the dynamically imported scripts are there.

Since the contents of /testlib2/es and /app/es are identical, so I think the import expressions are treated differently when they're in the app or in a dependency.

System Info

System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (4) x64 Intel(R) Xeon(R) CPU E5-2696 v2 @ 2.50GHz
    Memory: 3.38 GB / 7.79 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 16.13.1 - /usr/bin/node
    Yarn: 1.22.17 - /usr/bin/yarn
    npm: 8.1.2 - /usr/bin/npm

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type

    Projects

    Status

    Approved

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions