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

Append extension to filename to prevent issue with webpack5 (#1)

* Append filename to prevent issue with webpack5

* Add option to switch between mjs and js

Changed files
+2 -2
+2 -2
index.js
···
-
module.exports = function babelPluginModularGraphql({ types: t }) {
+
module.exports = function babelPluginModularGraphql({ types: t }, { esm } = { esm: false }) {
const importMap = require('./import-map.json');
const importMapOverrides = require('./import-map-overrides.json');
const PKG_NAME = 'graphql';
···
const from = declaration ? declaration.from : PKG_NAME;
if (!acc[from]) {
-
acc[from] = t.importDeclaration([], t.stringLiteral(from));
+
acc[from] = t.importDeclaration([], t.stringLiteral(from + esm ? '.mjs' : '.js'));
}
const localName = specifier.local.name;