ES6 imports to require

JavaScript pattern

Converts ES6-style import to require statements.


Apply with the Grit CLI
grit apply es6_imports_to_require

Transform standard require statements

BEFORE
import { something, another } from './lib';
import { assert } from 'chai';
import { config as conf } from 'chai';
import { mixed as mixie, foo } from 'life';
import starImport from 'star';

// no special handling for default. Also, comments get removed.
import defaultImport from '../../shared/default';
AFTER
const { something, another } = require("./lib")
const { assert } = require("chai")
const { config: conf } = require("chai")
const { mixed: mixie, foo } = require("life")
const starImport = require("star")

// no special handling for default. Also, comments get removed.
const defaultImport = require("../../shared/default")