Skip to content

v3.0.0

Latest
Compare
Choose a tag to compare
@lukeed lukeed released this 04 Jun 00:00

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, all import statements were rewritten so that the require() 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

  • Add TypeScript definitions: c16f09d
  • Add "exports" map for native ESM support: 1b55bb1

Patches

  • Do not match import inside string/quotes: d0af59c

    // Example:
    var text = "import { foo } from 'foobar';"
  • Respect existing quotation style: 6acd5e9
    Also allows the from "..." 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';

Chores