Geeks With Blogs
AngelEyes on .Net Tips, tricks and WTFs about Asp .Net, SQL Server and the likes. November 2015 Entries
(JS) Regular Expression to replace "require" statements with "import statements"
Having dabbled a bit with React / Redux, and while doing so used both the Import statement from ES6 and the Require function of Browserify, I decided I needed a RegEx to replace all "require" lines to "import" lines.
This is what I came up wit, so far:

const\s+(\w+)\s+=\s+require\('([^']+)'\);?

and replace  with;

import $1 from '$2';

Posted On Monday, November 23, 2015 1:15 PM

Copyright © AngelEyes | Powered by: GeeksWithBlogs.net