rewrite-imports
Rewrite import
statements as require()
s; via RegExp
Quickly transforms various import
statements into ES5-compatible require()
statements.
Note: This module returns a String and does not provide a runtime nor does it evaluate the output.
:bulb: For this behavior, visit rewrite-module
or check out @taskr/esnext
for an example!
Install
$ npm install --save rewrite-imports
Usage
const rewriteImports = require('rewrite-imports');
rewriteImports(`import foo from '../bar'`);
rewriteImports(`import { foo } from 'bar'`);
rewriteImports(`import * as path from 'path';`);
rewriteImports(`import { foo as bar, baz as bat, lol } from 'quz';`);
API
rewriteImports(input)
input
Type: String
An import
statement. See MDN for valid Syntax.
License
MIT © Luke Edwards