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: use string manipulation instead of regex to inject esbuild helpers #14094

Merged
merged 4 commits into from Aug 25, 2023

Conversation

fnlctrl
Copy link
Contributor

@fnlctrl fnlctrl commented Aug 14, 2023

Description

Fix #14065 lib mode hanging for umd build, by using string manipulation instead of regex

Additional context

The original fix #7948 used regex for string replacement to avoid global esbuild helpers.

It has since caused multiple performance issues #8738 #8099 #10900 #14065, and received numerous attempts #8110 #8741 #10905 at fixing it, but there're still unhandled cases:

I think this shows that regex isn't the right solution in this scenario. It's easier to manipulate the string directly, at the cost of a few extra lines.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Aug 14, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@fnlctrl
Copy link
Contributor Author

fnlctrl commented Aug 16, 2023

@patak-dev @sapphi-red @bluwy would you please review this? We're currently blocked on webpack-to-vite switch due to umd build hanging caused by regex. Let me know if I got anything wrong and I'll fix. Thank you!

bluwy
bluwy previously approved these changes Aug 18, 2023
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me and looks more performant too. Thanks for the PR!

Will wait for another eye on this before merging.

@bluwy bluwy added the p3-significant High priority enhancement (priority) label Aug 18, 2023
playground/lib/__tests__/lib.spec.ts Outdated Show resolved Hide resolved
playground/lib/__tests__/lib.spec.ts Outdated Show resolved Hide resolved
@sapphi-red sapphi-red merged commit 91a18c2 into vitejs:main Aug 25, 2023
11 checks passed
@fnlctrl fnlctrl deleted the remove-lib-regex branch August 26, 2023 07:31
@Penguinlay
Copy link

evanw/esbuild#3322 has been fixed.
CC @sapphi-red @fnlctrl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-significant High priority enhancement (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library mode umd build hangs
4 participants