Created
November 2, 2015 17:26
-
-
Save dfkaye/b0d6d385463eced54584 to your computer and use it in GitHub Desktop.
Convert ES5 requires to ES6 imports in ST ( regex by Hugo Giraudel )
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
from Hugo Giraudel, https://twitter.com/HugoGiraudel/status/661147120230100992 | |
Convert ES5 requires to ES6 imports in ST: | |
Search: | |
var\s+(\w+)\s+\=\s+require\((("|')[a-zA-Z0-9\/\.-]+\3)\)\;? | |
Replace: | |
import $1 from $2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It wont work on all imports unfortunately, like this:
var Router = require('react-router').Router;