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

fix: skip errors that occurred on virtual lines #1226

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

EvanBacon
Copy link
Contributor

Summary

If you have a module that has import statements generated in the transformer, then it could possibly throw a resolver error on a line that won't exist in the on-disk file. Without this change, the process will throw an unhandled error. Here, we just skip the error improvement step and fallback on the default behavior.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Feb 21, 2024
@motiz88
Copy link
Contributor

motiz88 commented Feb 22, 2024

Where is the bad source location coming from? This kinda looks like it masks a genuine bug elsewhere. Do you have repro steps? Also, we have tests for this code now, might be worth adding a regression test to cover the fix.

@EvanBacon
Copy link
Contributor Author

@motiz88 If you have a babel plugin which takes an empty file like "" and injects a bunch of imports:

import "missing"
import "missing2"

Then the resolver will throw an error which breaks the formatter because it attempts to read lines that don't exist on-disk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants