build/babel-plugin-transform-modules-commonjs-ec.js
function nameAnonymousExports(programPath) {
    // Name anonymous exported locals.
    programPath.get('body').forEach(child => {
        if (!child.isExportDefaultDeclaration()) {
            return;
        }

        // export default foo;
        const declaration = child.get('declaration');
        if (declaration.isFunctionDeclaration()) {
            if (!declaration.node.id) {
                declaration.node.id = declaration.scope.generateUidIdentifier('default');
            }
        }
        else if (declaration.isClassDeclaration()) {
            if (!declaration.node.id) {
                declaration.node.id = declaration.scope.generateUidIdentifier('default');
            }
        }
        else {
            const id = declaration.scope.generateUidIdentifier('default');
            const namedDecl = babelTypes.exportNamedDeclaration(null, [
                babelTypes.exportSpecifier(babelTypes.identifier(id.name), babelTypes.identifier('default')),
            ]);
            namedDecl._blockHoist = child.node._blockHoist;

            const varDecl = babelTypes.variableDeclaration('var', [
                babelTypes.variableDeclarator(id, declaration.node),
            ]);
            varDecl._blockHoist = child.node._blockHoist;

            child.replaceWithMultiple([namedDecl, varDecl]);
        }
    });
}
function nameAnonymousExports(programPath) {
    // Name anonymous exported locals.
    programPath.get('body').forEach(child => {
        if (!child.isExportDefaultDeclaration()) {
            return;
        }

        // export default foo;
        const declaration = child.get('declaration');
        if (declaration.isFunctionDeclaration()) {
            if (!declaration.node.id) {
                declaration.node.id = declaration.scope.generateUidIdentifier('default');
            }
        }
        else if (declaration.isClassDeclaration()) {
            if (!declaration.node.id) {
                declaration.node.id = declaration.scope.generateUidIdentifier('default');
            }
        }
        else {
            const id = declaration.scope.generateUidIdentifier('default');
            const namedDecl = babelTypes.exportNamedDeclaration(null, [
                babelTypes.exportSpecifier(babelTypes.identifier(id.name), babelTypes.identifier('default')),
            ]);
            namedDecl._blockHoist = child.node._blockHoist;

            const varDecl = babelTypes.variableDeclaration('var', [
                babelTypes.variableDeclarator(id, declaration.node),
            ]);
            varDecl._blockHoist = child.node._blockHoist;

            child.replaceWithMultiple([namedDecl, varDecl]);
        }
    });
}
function nameAnonymousExports ( programPath ) { // Name anonymous exported locals. programPath . get ( 'body' ) . forEach ( child => { if ( ! child . isExportDefaultDeclaration ( ) ) { return ; } // export default foo; const declaration = child . get ( 'declaration' ) ; if ( declaration . isFunctionDeclaration ( ) ) { if ( ! declaration . node . id ) { declaration . node . id = declaration . scope . generateUidIdentifier ( 'default' ) ; } } else if ( declaration . isClassDeclaration ( ) ) { if ( ! declaration . node . id ) { declaration . node . id = declaration . scope . generateUidIdentifier ( 'default' ) ; } } else { const id = declaration . scope . generateUidIdentifier ( 'default' ) ; const namedDecl = babelTypes . exportNamedDeclaration ( null , [ babelTypes . exportSpecifier ( babelTypes . identifier ( id . name ) , babelTypes . identifier ( 'default' ) ) , ] ) ; namedDecl . _blockHoist = child . node . _blockHoist ; const varDecl = babelTypes . variableDeclaration ( 'var' , [ babelTypes . variableDeclarator ( id , declaration . node ) , ] ) ; varDecl . _blockHoist = child . node . _blockHoist ; child . replaceWithMultiple ( [ namedDecl , varDecl ] ) ; } } ) ; }
Ensure that all exported values have local binding names.
Ensure that all exported values have local binding names .