@nodesecure/js-x-ray
Version:
JavaScript AST XRay analysis
30 lines • 746 B
JavaScript
// Import Internal Dependencies
import { SourceFile } from "../SourceFile.js";
/**
* @description Search for ESM Export
*
* @example
* export { bar } from "./foo.js";
* export * from "./bar.js";
*/
function validateNode(node) {
if (node.type !== "ExportNamedDeclaration" &&
node.type !== "ExportAllDeclaration") {
return [false];
}
return [
node.source !== null &&
node.source.type === "Literal" &&
typeof node.source.value === "string"
];
}
function main(node, { sourceFile }) {
sourceFile.addDependency(node.source.value, node.loc);
}
export default {
name: "isESMExport",
validateNode,
main,
breakOnMatch: true
};
//# sourceMappingURL=isESMExport.js.map