Created
December 1, 2016 13:33
-
-
Save m-allanson/c1b3d031f3833bbf1a86f1ffcc0cc495 to your computer and use it in GitHub Desktop.
Regex find & replace to convert ES6 imports to CommonJS requires
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
// matches: | |
// import foo from "../foo" | |
(import )((\w)+)( from )"((.|\/)*\w)" | |
// replaces with: | |
// const foo = require("../foo") | |
const $2 = require("$5") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment