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

Collisions with case sensitivity in imports #2861

Closed
eirslett opened this issue Apr 4, 2021 · 2 comments
Closed

Collisions with case sensitivity in imports #2861

eirslett opened this issue Apr 4, 2021 · 2 comments
Labels
enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@eirslett
Copy link
Contributor

eirslett commented Apr 4, 2021

Describe the bug

The returned error message is not human-friendly when mistyping imports.

Reproduction

Create a super simple Vite app.
File a.js: import * as React from 'react'; // lower case
File b.js: import * as React from 'React'; // oops typo, used uppercase R

See "logs" below for the error message.

System Info

  System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 117.69 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node
    npm: 6.14.10 - ~/.nvm/versions/node/v14.15.4/bin/npm
  Browsers:
    Chrome: 89.0.4389.114
    Safari: 14.0.3
  npmPackages:
    vite: ^2.1.5 => 2.1.5 

Used package manager: npm

Logs

Pre-bundling dependencies:
  React
  react-dom
  react
(this will be run only when your dependencies or config have changed)
 > error: Two output files share the same path but have different contents: node_modules/.vite/react.js.map

 > error: Two output files share the same path but have different contents: node_modules/.vite/react.js

error when starting dev server:
Error: Build failed with 2 errors:
error: Two output files share the same path but have different contents: node_modules/.vite/react.js.map
error: Two output files share the same path but have different contents: node_modules/.vite/react.js
    at failureErrorWithLog (/Users/eirik/projects/vite-hmr-fails/node_modules/esbuild/lib/main.js:1224:15)
    at buildResponseToResult (/Users/eirik/projects/vite-hmr-fails/node_modules/esbuild/lib/main.js:936:32)
    at /Users/eirik/projects/vite-hmr-fails/node_modules/esbuild/lib/main.js:1035:20
    at /Users/eirik/projects/vite-hmr-fails/node_modules/esbuild/lib/main.js:568:9
    at handleIncomingPacket (/Users/eirik/projects/vite-hmr-fails/node_modules/esbuild/lib/main.js:657:9)
    at Socket.readFromStdout (/Users/eirik/projects/vite-hmr-fails/node_modules/esbuild/lib/main.js:535:7)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)

Suggested solution?

Vite could run .toLowerCase() on package import names before doing its magic. Or it could detect the problem and show a more specific message. I'm not sure how other bundlers are handling this, or how ESM modules should behave natively in the browser. Are they case sensitive?

@bluwy
Copy link
Member

bluwy commented Mar 6, 2022

The issue seems to be specific to case-insensitive filesystems. toLowerCase() might work but could be risky for case-sensitive filesystems. Overall I'm not sure if it's worth the effort for a better error message, the Pre-bundling dependencies: message already showed the incorrect casing.

@patak-dev
Copy link
Member

Agreed, there also hasn't been activity for a year. Let's close it for now

@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

No branches or pull requests

4 participants