I'm attempting to write a plugin for babel, and am needing the filename of the current file that is being parsed. I know the lines of the code are passed in, but I haven't managed to find a reference to the filename. Any help??
For instance given this code what could I do
export default function({ types: t }) {
return {
visitor: {
Identifier(path) {
// something here??
}
}
};
}
You can you this
or use the 2nd parameter in a visitor (state
)
Identifier(path, state) {
console.log(state.file.opts.filename);
}