Load files into memory to be parsed & traversed using Babylon/Babel
import {loadImportSync} from 'babel-file-loader';
export function plugin() {
return {
visitor: {
ImportDefaultDeclaration(path) {
let file = loadImportSync(path);
file.path.traverse({
ExportDefaultDeclaration() {
console.log('Found matching export default');
},
});
},
},
},
};
Resolve a filePath
relative to the file a path
belongs to. Returns string.
Resolve an import declaration path
to extract a file path. Returns string.
Load and parse a file from a filePath
. Returns File.
Load and parse a file from an import declaration path
. Returns File.