fix: remove regex replacement for lib mode #14091
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
Fix #14065 lib mode hanging for umd build, by removing regex replacements
Additional context
The original fix #7948 used regex for string replacement to avoid global esbuild helpers. However, it seems these can be removed now, because all the tests pass without them, probably due to updated esbuild (0.14.27 then vs 0.18.10 now).
The regex approach also doesn't completely fix the original issue, some reproductions with the latest vite (4.4.9):
Given numerous preivous attemps #8110 #8741 #10905 at fixing regex performance, I think this is an indication that regex isn't the right solution in this scenario, and we should probably remove it altogether to avoid future performance issues.
In conclusion, we need a better fix for the global esbuild helpers. Removing regex for now appears to be safe because a). all tests pass and b). the original issue is still largely unfixed (easily reproducable - probably already in many people's builds)
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).