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

gulp: Inline regex source #1537

Merged
merged 4 commits into from
Jan 23, 2019

Conversation

RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Aug 22, 2018

This PR lets gulp inline the source of inline regular expressions without flags in minified files.

This means that gulp will replace /regex/.source with 'regex'.

Motivation

Most IDEs support syntax highlighting and checking of JS inline regular expressions. This makes them easier to work with and less error-prone than having a string hold the expression.
Inline regexes are also usually shorter than their string counterparts because you don't have to escape backslashes.
There are also some linters (e.g. ESLint) for JS regular expression which (of course) won't work on strings.

This PR lets you enjoy the advantages of inline regexes without worrying about the additional overhead of compiling another regular expression on the client side.

@RunDevelopment RunDevelopment mentioned this pull request Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants