How to use the jscodeshift.exportSpecifier function in jscodeshift

To help you get started, we’ve selected a few jscodeshift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Polymer / tools / packages / modulizer / src / passes / rewrite-namespace-exports.ts View on Github external
// We could probably do better for referenced declarations, ie
      // move the export to the declaration
      let exportedName =
          fullyQualifiedNamePath[fullyQualifiedNamePath.length - 1];

      // Special Polymer workaround: Rename `Polymer.Element` to have the
      // es6ExportName `PolymerElement`.
      if (fullyQualifiedName === 'Polymer.Element') {
        exportedName = 'PolymerElement';
      }

      replacePreservingComments(
          assignment,
          jsc.exportNamedDeclaration(
              null,  // declaration
              [jsc.exportSpecifier(identifier, jsc.identifier(exportedName))]));
      this.exportMigrationRecords.push(
          {es6ExportName: exportedName, oldNamespacedName: fullyQualifiedName});
    }
  }
github Polymer / tools / src / passes / rewrite-namespace-exports.ts View on Github external
// We could probably do better for referenced declarations, ie
      // move the export to the declaration
      let exportedName =
          fullyQualifiedNamePath[fullyQualifiedNamePath.length - 1];

      // Special Polymer workaround: Rename `Polymer.Element` to have the
      // es6ExportName `PolymerElement`.
      if (fullyQualifiedName === 'Polymer.Element') {
        exportedName = 'PolymerElement';
      }

      replacePreservingComments(
          assignment,
          jsc.exportNamedDeclaration(
              null,  // declaration
              [jsc.exportSpecifier(identifier, jsc.identifier(exportedName))]));
      this.exportMigrationRecords.push(
          {es6ExportName: exportedName, oldNamespacedName: fullyQualifiedName});
    }
  }
github Polymer / tools / src / passes / rewrite-namespace-exports.ts View on Github external
func.params,
          func.body,
          func.generator));
      (node as NodeWithComments).comments = getCommentsFromNode(propNode);
      exportRecords.push({name, node});
    } else if (value.type === 'ArrowFunctionExpression') {
      const isMutable =
          mutableNames.has(fullName) || mutableNames.has(thisName);
      const node = jsc.exportNamedDeclaration(jsc.variableDeclaration(
          isMutable ? 'let' : 'const', [jsc.variableDeclarator(key, value)]));
      (node as NodeWithComments).comments = getCommentsFromNode(propNode);
      exportRecords.push({name, node});
    } else if (value.type === 'Identifier') {
      const node = jsc.exportNamedDeclaration(
          null,
          [jsc.exportSpecifier(jsc.identifier(name), jsc.identifier(name))]);
      (node as NodeWithComments).comments = getCommentsFromNode(propNode);
      exportRecords.push({name, node});
    } else {
      console.warn('Namespace property not handled:', name, value);
    }
  }

  return exportRecords;
}
github Polymer / tools / packages / modulizer / src / passes / rewrite-namespace-exports.ts View on Github external
func.params,
          func.body,
          func.generator));
      (node as NodeWithComments).comments = getCommentsFromNode(propNode);
      exportRecords.push({name, node});
    } else if (value.type === 'ArrowFunctionExpression') {
      const isMutable =
          mutableNames.has(fullName) || mutableNames.has(thisName);
      const node = jsc.exportNamedDeclaration(jsc.variableDeclaration(
          isMutable ? 'let' : 'const', [jsc.variableDeclarator(key, value)]));
      (node as NodeWithComments).comments = getCommentsFromNode(propNode);
      exportRecords.push({name, node});
    } else if (value.type === 'Identifier') {
      const node = jsc.exportNamedDeclaration(
          null,
          [jsc.exportSpecifier(jsc.identifier(name), jsc.identifier(name))]);
      (node as NodeWithComments).comments = getCommentsFromNode(propNode);
      exportRecords.push({name, node});
    } else {
      console.warn('Namespace property not handled:', name, value);
    }
  }

  return exportRecords;
}