Skip to content

Instantly share code, notes, and snippets.

View mlrawlings's full-sized avatar

Michael Rawlings mlrawlings

View GitHub Profile
const path = require('path');
const { createMacro } = require("babel-plugin-macros");
const objectToAST = require("babel-plugin-preval/src/object-to-ast"); // https://github.com/kentcdodds/babel-plugin-preval/blob/b6eeba02ee93d425cc673ffc23dc62375d0416e5/src/object-to-ast.js
export default fn =>
createMacro(({ references, state, babel }) => {
references.default.forEach(referencePath => {
if (referencePath.parentPath.type === "CallExpression") {
const __filename = state.file.opts.filename;
const __dirname = path.dirname(__filename);