index.js
function(nodePath, state) {
        var replacements = [];
        var node = nodePath.node;
        if (node.declaration) {
          replacements.push(node.declaration);
          if (t.isVariableDeclaration(node.declaration)) {
            node.declaration.declarations.forEach(assignDeclarationToGlobal.bind(null, state, replacements));
          } else {
            assignDeclarationToGlobal(state, replacements, node.declaration);
          }
        } else {
          node.specifiers.forEach(function(specifier) {
            var exprToAssign = specifier.local;
            if (node.source) {
              var specifierName = specifier.local ? specifier.local.name : null;
              exprToAssign = getGlobalExpression(state, node.source.value, specifierName);
            }

            var filenameNoExt = getFilenameNoExt(state.file.opts.filename);
            var expr = getGlobalExpression(state, filenameNoExt, specifier.exported.name);
            assignToGlobal(expr, replacements, exprToAssign);
          });
        }

        nodePath.replaceWithMultiple(replacements);
      }
function(nodePath, state) {
        var replacements = [];
        var node = nodePath.node;
        if (node.declaration) {
          replacements.push(node.declaration);
          if (t.isVariableDeclaration(node.declaration)) {
            node.declaration.declarations.forEach(assignDeclarationToGlobal.bind(null, state, replacements));
          } else {
            assignDeclarationToGlobal(state, replacements, node.declaration);
          }
        } else {
          node.specifiers.forEach(function(specifier) {
            var exprToAssign = specifier.local;
            if (node.source) {
              var specifierName = specifier.local ? specifier.local.name : null;
              exprToAssign = getGlobalExpression(state, node.source.value, specifierName);
            }

            var filenameNoExt = getFilenameNoExt(state.file.opts.filename);
            var expr = getGlobalExpression(state, filenameNoExt, specifier.exported.name);
            assignToGlobal(expr, replacements, exprToAssign);
          });
        }

        nodePath.replaceWithMultiple(replacements);
      }
function ( nodePath , state ) { var replacements = [ ] ; var node = nodePath . node ; if ( node . declaration ) { replacements . push ( node . declaration ) ; if ( t . isVariableDeclaration ( node . declaration ) ) { node . declaration . declarations . forEach ( assignDeclarationToGlobal . bind ( null , state , replacements ) ) ; } else { assignDeclarationToGlobal ( state , replacements , node . declaration ) ; } } else { node . specifiers . forEach ( function ( specifier ) { var exprToAssign = specifier . local ; if ( node . source ) { var specifierName = specifier . local ? specifier . local . name : null ; exprToAssign = getGlobalExpression ( state , node . source . value , specifierName ) ; } var filenameNoExt = getFilenameNoExt ( state . file . opts . filename ) ; var expr = getGlobalExpression ( state , filenameNoExt , specifier . exported . name ) ; assignToGlobal ( expr , replacements , exprToAssign ) ; } ) ; } nodePath . replaceWithMultiple ( replacements ) ; }
Replaces named export declarations with assignments to global variables.
@param {!NodePath} nodePath
@param {!Object} state
Replaces named export declarations with assignments to global variables .