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

Import statement casing should be case insensitive ? #7336

Closed
tonyhallett opened this issue Nov 20, 2021 · 3 comments
Closed

Import statement casing should be case insensitive ? #7336

tonyhallett opened this issue Nov 20, 2021 · 3 comments

Comments

@tonyhallett
Copy link
Contributor

🐛 bug report

Imports have to match the casing of the file name for subsequent builds to work. Which affects hrm too.
See comment

package.json

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "parcel",
    "prebuild": "rimraf public",
    "build": "parcel build",
    "check": "tsc --noEmit"
  },
  "source": "src/index.html",
  "targets": {
    "default": {
      "distDir": "./public"
    }
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/react": "^17.0.35",
    "@types/react-dom": "^17.0.11",
    "parcel": "^2.0.1",
    "rimraf": "^3.0.2",
    "typescript": "^4.5.2"
  },
  "dependencies": {
    "firebase": "^9.5.0",
    "install": "^0.13.0",
    "npm": "^8.1.4",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

🤔 Expected Behavior

Although I should have matched the import casing it is allowed in windows. I expected the build to include my most recent changes.

😯 Current Behavior

The change is ignored and the transpilation does not occur.

💁 Possible Solution

Do case insensitive lookup.

🔦 Context

Just trying to rebuild.

🌍 Your Environment

Software Version(s)
Parcel 2.01
Node 16.7.0
npm/Yarn 7.21
Operating System Windows 10
@devongovett
Copy link
Member

This depends on the operating system and even the file system you are using. For example, macOS can have either a case insensitive or case sensitive file system. I don't think we should do case insensitive matching because it would not be consistent across systems. Builds should be reproducible e.g. on local development environments and in CI, which could be on different OSes. Perhaps we could add an error message if you used the wrong case in an import...

@tonyhallett
Copy link
Contributor Author

Perhaps we could add an error message if you used the wrong case in an import...

That would be useful. Perhaps you could fail the initial build if is the wrong case.
I personally think that you shouldn't have closed this until there has been a pr. Successful first build, second reported successful build that does not reflect ( permitted ) changes seems like an issue to me.

@mischnic
Copy link
Member

So a situation like this?

// index.js
console.log(require("./a.js"));

// A.js
module.exports = 4;

Changing A.js correctly causes rebuilds and updates the output bundle on macOS, but it might behave differently on Windows

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

No branches or pull requests

3 participants