-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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: sourcemapIgnoreList for optimizedDeps #12633
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of rewriting the sourcemap when serving it, wouldn't it make sense to consider the ignore list predicate when initially generating the optimized dep?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but we don't have the .map in memory to modify it. See #12622, we needed to go back to let esbuild write the files to disk directly because there was a perf regression.
We would also need to start using
sourcemapIgnoreList.toString()
in the hash key for optimization given our current architecture. That could work though.If we want to do it, I think we should still do it lazily to avoid blocking giving the optimized deps to the browser. But that means that if the process is stopped, we may end up with inconsistent results.
So I see three options:
a. Current approach in this PR, and we accept the JSON.parse/JSON.stringify cost (I think this could be fine)
b. Current approach, but we don't use JSON.parse/JSON.stringify and instead use regexes to grab the
sources
array and then inject after it theignoreSourcemapList
.c. We add
sourcemapIgnoreList
to the deps cache key, and when we do the first JSON.parse, we also add a marker like"__vite": "sourcemapIgnorList_done",
. So next time we load it, we can use a regex to know it has been processed.Leaning towards b. if there is a regression perf after this PR. cc @bluwy @sapphi-red
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion is to go with "a." for now because I guess this is not a hot path.
One more option would be to create a feature request / PR to esbuild for adding sourcemap ignore list feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. I'd also heavily lean towards "a." unless there's a serious performance problem.