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

Replace esm option with extension

Changed files
+7 -2
+7 -2
index.js
··· 1 - module.exports = function babelPluginModularGraphql({ types: t }, { esm } = { esm: false }) { 1 + module.exports = function babelPluginModularGraphql({ types: t }, options = {}) { 2 + let extension = (options.extension || '').trim(); 3 + if (extension && extension[0] !== '.') { 4 + extension = '.' + extension; 5 + } 6 + 2 7 const importMap = require('./import-map.json'); 3 8 const importMapOverrides = require('./import-map-overrides.json'); 4 9 const PKG_NAME = 'graphql'; ··· 21 26 22 27 const from = declaration ? declaration.from : PKG_NAME; 23 28 if (!acc[from]) { 24 - acc[from] = t.importDeclaration([], t.stringLiteral(from + esm ? '.mjs' : '.js')); 29 + acc[from] = t.importDeclaration([], t.stringLiteral(from + extension)); 25 30 } 26 31 27 32 const localName = specifier.local.name;