visitors.js
function visitImportDeclaration(traverse, node, path, state) {
  var specifier, name;
  utils.catchup(node.range[0], state);

  switch (node.kind) {

    // import "module"
    case undefined:
      utils.append('require(' + node.source.raw + ');', state);
      break;

    // import name from "module"
    case "default":
      specifier = node.specifiers[0];
      assert(specifier, "default import without specifier: " + node);
      name = specifier.name ? specifier.name.name : specifier.id.name;
      utils.append('var ' + name + ' = require(' + node.source.raw + ');', state);
      break;

    // import {name, one as other} from "module"
    case "named":
      var modID;

      if (node.specifiers.length === 1) {
        modID = 'require(' + node.source.raw + ')';
      } else {
        modID = genID('mod');
        utils.append('var ' + modID + ' = require(' + node.source.raw + ');', state);
      }

      for (var i = 0, len = node.specifiers.length; i < len; i++) {
        specifier = node.specifiers[i];
        utils.catchupNewlines(specifier.range[0], state);
        name = specifier.name ? specifier.name.name : specifier.id.name;
        utils.append('var ' + name + ' = ' + modID + '.' + specifier.id.name + ';', state);
      }

      break;

    default:
      assert(false, "don't know how to transform: " + node.kind);
  }

  utils.catchupNewlines(node.range[1], state);
  utils.move(node.range[1], state);
  return false;
}
function visitImportDeclaration(traverse, node, path, state) {
  var specifier, name;
  utils.catchup(node.range[0], state);

  switch (node.kind) {

    // import "module"
    case undefined:
      utils.append('require(' + node.source.raw + ');', state);
      break;

    // import name from "module"
    case "default":
      specifier = node.specifiers[0];
      assert(specifier, "default import without specifier: " + node);
      name = specifier.name ? specifier.name.name : specifier.id.name;
      utils.append('var ' + name + ' = require(' + node.source.raw + ');', state);
      break;

    // import {name, one as other} from "module"
    case "named":
      var modID;

      if (node.specifiers.length === 1) {
        modID = 'require(' + node.source.raw + ')';
      } else {
        modID = genID('mod');
        utils.append('var ' + modID + ' = require(' + node.source.raw + ');', state);
      }

      for (var i = 0, len = node.specifiers.length; i < len; i++) {
        specifier = node.specifiers[i];
        utils.catchupNewlines(specifier.range[0], state);
        name = specifier.name ? specifier.name.name : specifier.id.name;
        utils.append('var ' + name + ' = ' + modID + '.' + specifier.id.name + ';', state);
      }

      break;

    default:
      assert(false, "don't know how to transform: " + node.kind);
  }

  utils.catchupNewlines(node.range[1], state);
  utils.move(node.range[1], state);
  return false;
}
function visitImportDeclaration ( traverse , node , path , state ) { var specifier , name ; utils . catchup ( node . range [ 0 ] , state ) ; switch ( node . kind ) { // import "module" case undefined : utils . append ( 'require(' + node . source . raw + ');' , state ) ; break ; // import name from "module" case "default" : specifier = node . specifiers [ 0 ] ; assert ( specifier , "default import without specifier: " + node ) ; name = specifier . name ? specifier . name . name : specifier . id . name ; utils . append ( 'var ' + name + ' = require(' + node . source . raw + ');' , state ) ; break ; // import {name, one as other} from "module" case "named" : var modID ; if ( node . specifiers . length === 1 ) { modID = 'require(' + node . source . raw + ')' ; } else { modID = genID ( 'mod' ) ; utils . append ( 'var ' + modID + ' = require(' + node . source . raw + ');' , state ) ; } for ( var i = 0 , len = node . specifiers . length ; i < len ; i ++ ) { specifier = node . specifiers [ i ] ; utils . catchupNewlines ( specifier . range [ 0 ] , state ) ; name = specifier . name ? specifier . name . name : specifier . id . name ; utils . append ( 'var ' + name + ' = ' + modID + '.' + specifier . id . name + ';' , state ) ; } break ; default : assert ( false , "don't know how to transform: " + node . kind ) ; } utils . catchupNewlines ( node . range [ 1 ] , state ) ; utils . move ( node . range [ 1 ] , state ) ; return false ; }
Visit ImportDeclaration.

Examples:

import "module"
import name from "module"
import { name, one as other } from "module"
Visit ImportDeclaration .