Last active
November 29, 2020 17:45
-
-
Save tscpp/5390f835075bbb5907055cd153797ac3 to your computer and use it in GitHub Desktop.
Regex that can be used to replace require statements with ES6 import statements
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
Find: (^|\n)\s*(?:let|const|var)\s+(.+?)\s*=\s*require\s*\(\s*(?:'|")(.+?)(?:'|")\s*\)\s*(;(?:$|\n)|(?:$|\n)) | |
Replace: $1import * as $2 from '$3'$4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment