Breaking
-
Migrate to named
rewrite
export: 3f29fc2--const rewrite = require('rewrite-imports'); ++const { rewrite } = require('rewrite-imports'); // or --import rewrite from 'rewrite-imports'; ++import { rewrite } from 'rewrite-imports';
-
No longer forces semicolon termination: bb06a96
Previously, allimport
statements were rewritten so that therequire()
statement always ended in a semicolon. Now, the conversion will respect the source code style & will only include a semicolon if absolutely necessary.import { foo, bar } from "foobar" // Before: const { foo, bar } = require('foobar'); // After: const { foo, bar } = require("foobar")
Note: Original quotation style is also preserved.
Features
Patches
-
Do not match
import
inside string/quotes: d0af59c// Example: var text = "import { foo } from 'foobar';"
-
Respect existing quotation style: 6acd5e9
Also allows thefrom "..."
aspect to use"
,'
or ``` quote style. -
Allow non-alphanum named identifiers: 1b8dbd6
Previously these statements were ignored because of the$
character.import * as $ from './utils'; import { $foo, $bar } from 'foobar';