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

Rehome moved requests to real on-disk files #1547

Merged
merged 1 commit into from Jul 18, 2023
Merged

Rehome moved requests to real on-disk files #1547

merged 1 commit into from Jul 18, 2023

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Jul 18, 2023

When we're about to do default resolving outbound from a moved package, we need to rehome the request to the original location of the moved package. Previously, we did this by just replacing the moved package root with the original package root, leaving the within-package part of the part unchanged.

In general, this path doesn't actually exist on disk, but that didn't really matter to webpack. Unfortunately it does matter to vite, which for dubious reasons checks that the importing file actually exists before being willing to use it as the base for resolution.

So instead we need to rehome to a file that exists, so we'll use package.json like we generally do when we want to mean "from this package".

However, we also need to undo this rehoming if the request falls through to our own fallback. Previously that was easy because we still had the true within-package path in the module specifier. Now we can't do that because we threw away the within-package part and replaced it with package.json, so instead we need to introduce a general mechanism for attaching metadata to requests.

When we're about to default resolving outbound from a moved package, we need to rehome the request back to the original package. Previously, we did this by moving the fromFile into the original package, but keeping its own relative path withn the package.

This path doesn't actually exist, but that didn't matter to webpack. Unfortunately it does matter to vite, which for dubious reaons checks that the importing file actually exists before being willing to use it as the base for resolution.

So instead we need to rehome to a file that exist, so we'll use `package.json` like we generally do when we want to mean "from this package".

However, we also need to *undo* this rehoming if the request falls through to our own fallback. Previously that was easy because we still had the true within-package path in the module specifier. Now we need an additional mechanism for propagating extra metadata along with requests.
@ef4 ef4 merged commit 0c7aa66 into main Jul 18, 2023
196 checks passed
@ef4 ef4 deleted the rehome-to-real-files branch July 18, 2023 20:46
@ef4 ef4 added the bug Something isn't working label Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant