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
fix(typescript): normalize emittedFiles to prevent unrecoginized token #1377
Conversation
The `id` passed to `async load(id)` has certain edge cases when drives letters can de different cases or file**names** can have different cases. By normalising the `emittedFiles` we will always find the `code` we need and, as such, will not throw
It's such an edge case and I don't know the reason/case in order to force it
I'd like to get some clarity about what causes this edge case - why |
Accidentally left in a code tweak from earlier tests - reverted
This was my suspicion based on the original description of the problem. I'd like to get this addressed in Rollup core before we make concessions for that in plugins. |
I do not think this is the case. Rollup core does not change imported ids. It does not change slashes and it definitely does not do anything with drive letters. Between emission and I remember having some older issue around TypeScript normalizing slashes while Rollup does not. |
Thanks for the reply. Sorry, I'm not too familiar with the rollup structure/architecture. So I've found the actual cause of the issue. In my config, I have I tested with In regards to the drive letter changing randomly. There are some inconsistencies in npm's path resolutions - like nodejs/node#37307. Again, in my opinion, comparisons of any form should be case normalized too. |
So case sensitivity is ignored by node (yes, I know there's more to it). Below is an article touching on the (not-so)random case changes in paths and drive letters: Basically, I think it's now at the point of doing any I'll take a look and see if there are any other |
Don't think there is any, checked the cache version (right after my change) and that does file checks rather than string comparisons - so I left it alone. |
Hey @shellscape / @lukastaegert, sorry to pester but have you any thoughts/progress on this? Would you like me to create a PR for some insensitive comparison utility tool(s)? Would you like two types - as I mentioned above (copied below)?
|
I read through the Node core issue and have read all of the info you've dropped here. Thanks for putting all of this together.
Yes. It's a legacy issue that they really should have fixed by now, but the rate of error is still considered an edge case. They could sneak a fix into a major since the release schedule is so much more frequent now, but not sure why they don't. This is precisely why tools like ESLint have plugins like
This is really the crux; user error. (should not be read as an insult) My thoughts are that this isn't really something that I'm keen on merging, because I think that case sensitivity is a good thing in the majority of cases. Paths are only normalized based on separator (
That said, this might also be a cause of woe in the scenario for this PR plugins/packages/typescript/src/diagnostics/host.ts Lines 36 to 38 in 1a4f2bd
|
Sorry for the delay. Not a problem @shellscape, thanks for considering & no insult taken 😉 - we are all custom to user error (ESPECIALLY MINE!) I needed it for a typescript extension I've been working on but since the issue has gone 🤷♂️ |
Rollup Plugin Name:
typescript
This PR contains:
Are tests included?
NOTE: Though I don't know the source of the issue - in order to force/replicate it - so the test succeeds pre and post change
Breaking Changes?
List any relevant issue numbers: #892 #1083 #1238
Description
The
id
passed toasync load(id)
has certain edge cases when drives letters can de different cases or filenames can have its case changed. By normalising theemittedFiles
we will always find thecode
we need and, as such, will not throwProof of issue/concept
Machine1: Windows 10.0.19044
I was able to compile TopMarksDevelopment/JavaScript.Autocomplete, but not TopMarksDevelopment/JavaScript.HoverBox. The only difference was that the index file was named
Index
instead ofindex
. Changed that and then it compiled.Rather than trudging on - because I was to improve open source, when I can 😁 - I started tinkering. When debugging I noticed that the
code
wasn't being returned as there was this name inconsistency between that inemittedFiles
and theid
received inload(id)
.Applied the change replaced the compiled code in my project's
node_modules
and it compiled, whilst keeping the file name asIndex
.Machine 2: Windows Server 2019 10.0.17763
I have a server that was having the same issue - this time attempting with
gulp
.Debugging this time showed me that the drive letter character case was being changed for some reason - and not on every file that it was working on at the time.
Again, replaced the source with the changed compile code and it once again compiled. YAY!