fix(dev): fix import failure on filenames with hashes#4817
fix(dev): fix import failure on filenames with hashes#4817davidwallacejackson wants to merge 2 commits into
Conversation
| async load(id) { | ||
| try { | ||
| return fs.readFile(cleanUrl(id), 'utf-8') | ||
| return await fs.readFile(cleanUrl(id), 'utf-8') |
There was a problem hiding this comment.
needed to do this because errors in a returned promise in async aren't caught by try unless the promise is awaited -- so files with # still failed even though resolve.ts now handles them
|
Looking at the test failures and could use a little help: I see that the problem comes when we're trying to serve the file inside of a I'm not sure what I should do about that, though. I noticed that the functions in ...but that seems very complicated. Maybe there's an easier way I'm missing? |
|
when can this bug fix : ( |
|
I am still working on this, but it's proving really tough: there are many places in the code where it's necessary to encode/decode URLs to deal with hashes, and some places where the hash character has a separate established use (as an alternate indicator for queries). The latter means that there are situations in which it's impossible to determine the correct way to parse a URL without just presenting multiple options and trying all of them -- something that doesn't always fit into the way the code is currently structured. For an example, see Would appreciate some input from maintainers on this -- I suspect strongly that there's a less troublesome way to do this if I hook into the right parts of the URL-processing pipeline, but it's hard to figure out what those are without context. |
|
@davidwallacejackson we just merged #4703, which fixes part of this issue. I don't know if a more complete solution is going to be needed here but if someone wants to continue exploring it we can review it. Encoding and decoding URLs as we discussed because of this PR for example. We could leave this PR open or closed it now that at least #4703 makes this problem a bit less prominent. |
|
some context. Yes, if the code is using cjs, writing something like We could see whatwg/html#5162 to get more context. It seems improper to fix in Vite. The issue consider So, even the bug was fixed. For |
close #2346
Description
Credit to @iheyunfei, who took a crack at this first in #4703 -- I started with their work. If it'd be more appropriate to merge this into that PR somehow, just let me know!
Right now, all imports of files with a # character in their path fail because the hash is interpreted as a denoting a postfix. To support hashes in file paths without breaking support for postfix hashes, I'm just trying both -- postfix interpretation first, then file path interpretation. This still won't work for hash postfixes on files that also have hashes in their names, but I'm not sure how common that is.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).