Mirror: Modular GraphQL.js import paths without the hassle.

Replace ES export with module.exports

Changed files
+5 -11
+5 -11
index.js
···
-
export default function({ types: t }) {
const importMap = require('./import-map.json');
const PKG_NAME = 'graphql';
···
const newImportedName = declaration ? declaration.local : imported;
acc[from].specifiers.push(
-
t.importSpecifier(
-
t.identifier(localName),
-
t.identifier(newImportedName)
-
)
);
}
···
}, {});
const importFiles = Object.keys(imports);
-
if (
-
importFiles.length &&
-
(importFiles.length !== 1 || importFiles[0] !== PKG_NAME)
-
) {
-
path.replaceWithMultiple(importFiles.map(key => imports[key]));
}
},
},
},
};
-
}
···
+
module.exports = function babelPluginModularGraphql({ types: t }) {
const importMap = require('./import-map.json');
const PKG_NAME = 'graphql';
···
const newImportedName = declaration ? declaration.local : imported;
acc[from].specifiers.push(
+
t.importSpecifier(t.identifier(localName), t.identifier(newImportedName))
);
}
···
}, {});
const importFiles = Object.keys(imports);
+
if (importFiles.length && (importFiles.length !== 1 || importFiles[0] !== PKG_NAME)) {
+
path.replaceWithMultiple(importFiles.map((key) => imports[key]));
}
},
},
},
};
+
};