Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using suffix in imports fails in development. works with production build #19327

Open
7 tasks done
fernandojbf opened this issue Jan 31, 2025 · 0 comments
Open
7 tasks done

Comments

@fernandojbf
Copy link

Describe the bug

Import suffixes such as ?url and ?worker&url are not correctly applied during development builds when importing from node_modules. This causes builds to fail in dev mode, while production builds work as expected.

Reproduction

https://github.com/fernandojbf/vite-suffix-bug

Steps to reproduce

Vite Project

  1. Navigate to the vite-example folder:

    cd vite-example
  2. Install dependencies and run the project in development mode:

    yarn
    git checkout origin/main node_modules/suffix-node-modules/
    yarn dev
  3. Build will fail.

  4. Build for production and run:

    yarn build
    yarn preview

    Check logs.


React Router Project

  1. Navigate to the react-router-example folder:

    cd react-router-example
  2. Install dependencies and run in development mode:

    yarn
    git checkout origin/main node_modules/suffix-node-modules/
    yarn dev
  3. Build will fail.

  4. Build for production and run:

    yarn build
    yarn start

    Check logs.


System Info

System:
    OS: macOS 14.7.2
    CPU: (12) arm64 Apple M2 Pro
    Memory: 88.84 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.13.1 - ~/.nvm/versions/node/v22.13.1/bin/node
    Yarn: 4.4.1 - ~/.nvm/versions/node/v22.1.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.13.1/bin/npm
    bun: 1.0.3 - ~/.bun/bin/bun
    Watchman: 2024.11.11.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 132.0.6834.160
    Chrome Canary: 134.0.6990.0
    Safari: 18.1.1

Used Package Manager

yarn

Logs

✘ [ERROR] No matching export in "node_modules/suffix-node-modules/js.js?url" for import "default"

node_modules/suffix-node-modules/index.js:2:7:
  2 │ import jsFile from './js.js?url';
    ╵        ~~~~~~

✘ [ERROR] No matching export in "node_modules/suffix-node-modules/js.js?worker&url" for import "default"

node_modules/suffix-node-modules/index.js:3:7:
  3 │ import workerFile from './js.js?worker&url';
    ╵        ~~~~~~~~~~

vite-suffix-bug/vite-example/node_modules/esbuild/lib/main.js:1476
let error = new Error(text);

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant