Code coverage report for 6to5/lib/6to5/transformation/transformers/es6-modules.js

Statements: 100% (22 / 22)      Branches: 100% (10 / 10)      Functions: 100% (3 / 3)      Lines: 100% (22 / 22)      Ignored: none     

All files » 6to5/lib/6to5/transformation/transformers/ » es6-modules.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 491   1   389       1 159   159 111 135     48     159     89     159     1 274   274     178 80 80     178   96 128       274    
var t = require("../../types");
 
exports.ast = {
  before: function (ast, file) {
    ast.program.body = file.dynamicImports.concat(ast.program.body);
  }
};
 
exports.ImportDeclaration = function (node, parent, file) {
  var nodes = [];
 
  if (node.specifiers.length) {
    for (var i in node.specifiers) {
      file.moduleFormatter.importSpecifier(node.specifiers[i], node, nodes, parent);
    }
  } else {
    file.moduleFormatter.importDeclaration(node, nodes, parent);
  }
 
  if (nodes.length === 1) {
    // inherit `_blockHoist`
    // this for `_blockHoist` in File.prototype.addImport
    nodes[0]._blockHoist = node._blockHoist;
  }
 
  return nodes;
};
 
exports.ExportDeclaration = function (node, parent, file) {
  var nodes = [];
 
  if (node.declaration) {
    // make sure variable exports have an initialiser
    // this is done here to avoid duplicating it in the module formatters
    if (t.isVariableDeclaration(node.declaration)) {
      var declar = node.declaration.declarations[0];
      declar.init = declar.init || t.identifier("undefined");
    }
 
    file.moduleFormatter.exportDeclaration(node, nodes, parent);
  } else {
    for (var i in node.specifiers) {
      file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);
    }
  }
 
  return nodes;
};