-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: detect case-sensitive filesystems correctly under yarn PnP #2323
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
base: main
Are you sure you want to change the base?
Conversation
Can you link to the documentation here? This sounds like a bug in yarn PnP, to be honest; why should i add bytes to the package.json for all users, when yarn could fix it for yarn pnp users? |
Codecov Report
@@ Coverage Diff @@
## main #2323 +/- ##
==========================================
+ Coverage 94.99% 95.55% +0.55%
==========================================
Files 66 66
Lines 2699 2699
Branches 900 898 -2
==========================================
+ Hits 2564 2579 +15
+ Misses 135 120 -15
Continue to review full report at Codecov.
|
No, this is intentional in yarn: yarnpkg/berry#1762 Juat a little background: The virtual filesystem in yarn is an optimization, so when installing packages you are not creating a Also, IMO a few dozen extra bytes in the |
On the contrary; the minority of yarn users are who should pay the cost, not everyone else. |
Just out of curiosity (I’m not intending to defend yarn or fight any ideological battle here), but do you aim for this package to specifically only support If this package only supports |
There’s one package manager that is the standard and has the majority, and whose behavior is correct by definition; I’m happy to support the others when it doesn’t hurt the primary audience. If yarn’s virtual filesystem does not exactly mimic the native one, then it has a bug, and it should be fixed. |
While I can appreciate that standpoint, I’m not sure how widespread this opinion that by /definition/ every single If you take a look at the PnP page (https://yarnpkg.com/features/pnp#compatibility-table), you can see a large variety of packages like In addition, the yarn team has stated this is currently intended behavior and not a bug (yarnpkg/berry#1762) and fixing it would be a lot of effort to fix a very small amount of cases like this.
Firstly, I’m open to alternative suggestions here. For example, instead of a metadata field in Can you define what you mean by hurt? For example, would adding even a single byte to the download that would be unnecessary for a |
Certainly the mechanism in this PR is likely the least intrusive one available (altho yarn-specific metadata should really be inside a yarn object, instead of littering the top level with stuff) Some of it is philosophical - just because some major packages have been effectively strong-armed into adding this metadata, doesn't mean that endorsing this dark pattern is something I want to do as a package author. |
Okay. I'm trying to think of other ways to try to solve this, such as passing an additional explicit configuration option to tell this package whether the filesystem is case-sensitive or not (instead of having it detect it automatically), or perhaps using -const CASE_SENSITIVE_FS = !fs.existsSync(path.join(__dirname.toUpperCase(), 'reSOLVE.js'));
+const CASE_SENSITIVE_FS = !fs.existsSync(path.join(pkgDir.sync(__dirname).toUpperCase(), 'pacKAGE.json')); |
If package.json is always on the local filesystem, that seems like totally reasonable thing to check instead, if that bypasses yarn's bug. |
82a89e3
to
76fd30e
Compare
I added an extra check in case |
76fd30e
to
50fe75f
Compare
It's possible to mount the |
Absolutely, that's a really good point. Want to make that change? |
84dfa73
to
68826a0
Compare
Can you elaborate more on what you mean? There are special-cases like I'm also sure there may be operating system APIs that could do this, but does nodejs expose any of them? |
I don't think node has any API to expose that, unfortunately. One technique would be to find a filename, and a variant, that don't exist - write one, and check to see if the variant suddenly exists - but this would just be another heuristic, not a guarantee. We could use |
@charlessuh any interest in updating the check? |
Note yarn under PnP does not create a `node_modules` directory, so files like `reSOLVE.js` file is served from a virtual filesystem, which is always case sensitive and not representative of the real underlying filesystem.
68826a0
to
369ee0a
Compare
It looks like there is already logic in However, note this function returns early when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think this has evolved into a broadly useful fix - there's no reason any system's case sensitivity is constant for every file, since one file could be on a case sensitive volume and another on a case insensitive volume.
@charlessuh hm, removing the |
yarn in PnP mode uses a virtual filesystem, and adding the
preferUnplugged: true
flag forces it to write this package to the real filesystem. This is needed so the case-sensitive detection logic inresolve.js
works properly.