fix: handle non-existing files in sourcemap #4328
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
If a source map contains a file in
source
section without uploading the referenced file, Vite will complain about ENOENT.This fix makes Vite more lenient with npm ecosystem's misdemeanor.
Additional context
When a npm package's source map has a source field, Vite will resolve the referenced file. However, not all packages will upload the source to npm registry, which makes such error. For example, the package
compute-scroll-into-view
does have such sources field.And vite throws an error.
Instead of throwing an error, this fix makes Vite ignore the missing source file.
To make the output less noisy and make the build successful, a comment is added for possible suggestion in the emitted source map. This supersedes #2904.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).