-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Case-insensitive filesystem issue (macOS): Fraction.js
/Complex.js
files vs. fraction.js
/complex.js
NPM packages
#2870
Comments
hanks for the clear error report Ryan. I've run your demo on Windows (which is case-insensitive) and it works just fine there, but I don't have a Mac to try this out. In the mathjs code base, there are the following files with similar naming: 'complex.js' // npm package
'src/type/complex/type/Complex.js'
'src/type/complex/function/complex.js'
'src/utils/complex.js'
'src/expression/embeddedDocs/construction/complex.js' From a human point of view, it may be good to rename these files somehow to make this less confusing. However from a technical point of view, all files do have a unique path, so there is no conflict at all. I do not understand why you get these warnings and errors. It sounds like a bug in the tool that generates this error. As if it interprets importing the npm library I expect the following minimal example to also throw an exception on Mac, maybe interesting to try out?
|
I've created a PR with a workaround for this (I think) bug in Next.js: #2872. Do you think that will solve the issue? |
Thanks for this @josdejong! I agree with everything you've said. Updated+Renamed repro repo: ryan-williams/next.js-import-bugInspired by your suggested minimal example, I have a repro that now only involves
|
I don't know if it helps, but TypeScript (just use it via https://www.typescriptlang.org/tsconfig#forceConsistentCasingInFileNames
That should help to detect this bug. |
Interesting, thanks @kungfooman! @benjamn also pointed out that adding a trailing slash to potentially ambiguous imports (e.g. NPM package names that could conceivably also be local file paths) seems to force importing from the package, as intended, e.g. -import Complex from 'complex.js'
+import Complex from 'complex.js/' // prevent erroneous circular import of ./Complex.js on case-insensitive filesystems; see https://github.com/vercel/next.js/issues/44603 at -import Fraction from 'fraction.js'
+import Fraction from 'fraction.js/' // prevent erroneous circular import of ./Fraction.js on case-insensitive filesystems; see https://github.com/vercel/next.js/issues/44603 It still seems better to identify/fix the bundler configs that are performing this incorrect optimization/resolution; I filed vercel/next.js#44603 about it. Maybe I can test those trailing slashes and see if it fixes the issue here though. |
Thanks @ryan-williams for working out a bug report and minimal example! Let's await the response on your bug report at next.js and see if it can be fixed in short term. If not, let's just merge my PR #2872 (we should be pragmatic). |
@ryan-williams shall we just merge my PR #2872 ? I do not see the issue being fixed at next.js soon. |
Thanks for following up @josdejong; I feel like the "trailing slash" work-around I sketched above is a bit more direct than renaming the classes as in #2872. If it's ok with you, I am fine to wait and try test and PR that, for comparison. The fact that no one else seems to be running into this or able to reproduce it also makes me want to wait and try to understand what's really happening… |
Ahh, yes, your workaround with the trailing slash is much better, I forgot about that 👍 . I've committed your fix straight into the |
o wow, I was too quick. The trailing slash gives problems with some of the build scripts: "Error Directory import '...\mathjs\node_modules\complex.js' is not supported resolving ES modules". And trying 'complex.js/complex.min.js' for example gives problems too when building. This needs some more investigation, help would be welcome. And if it's too much work I suggest we go for #2872 2872 anyway, it is straightforward and works. I'll revert the commit for now. |
Describe the bug
On a case-insensitive filesystem (I'm using macOS 12.1 with an APFS volume), something in
node
orwebpack
seems to get confused betweenComplex.js
in this repo and thecomplex.js
NPM package, and similarlyFraction.js
vs.fraction.js
on NPM.The warnings in the console above seem most relevant; more info below.
To Reproduce
On macOS (APFS Data Volume, case-insensitive)…
Clone ryan-williams/mathjs-test:
git clone https://github.com/ryan-williams/mathjs-test cd mathjs-test npm i
Or create repro from scratch:
Run
next dev
server, open in browserDev console shows warnings
…and corresponding error
Works on Linux / in Docker
Running the same thing in Docker, on a Linux base image (with case-sensitive filesystem), works without these warnings or errors:
Build, run, open:
docker build -t mathjs-test . docker run --rm -d -p 3001:3000 mathjs-test open http://127.0.0.1:3001
Page loads+renders without errors or warnings:
Notes
Relevant versions
The text was updated successfully, but these errors were encountered: