Skip to content

Instantly share code, notes, and snippets.

@dfkaye
Created November 2, 2015 17:26
Show Gist options
  • Save dfkaye/b0d6d385463eced54584 to your computer and use it in GitHub Desktop.
Save dfkaye/b0d6d385463eced54584 to your computer and use it in GitHub Desktop.
Convert ES5 requires to ES6 imports in ST ( regex by Hugo Giraudel )
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;
@mladenp
Copy link

mladenp commented Nov 16, 2016

It wont work on all imports unfortunately, like this:
var Router = require('react-router').Router;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment