+5
-11
index.js
+5
-11
index.js
···
1
-
export default function({ types: t }) {
1
+
module.exports = function babelPluginModularGraphql({ types: t }) {
2
2
const importMap = require('./import-map.json');
3
3
const PKG_NAME = 'graphql';
4
4
···
22
22
const newImportedName = declaration ? declaration.local : imported;
23
23
24
24
acc[from].specifiers.push(
25
-
t.importSpecifier(
26
-
t.identifier(localName),
27
-
t.identifier(newImportedName)
28
-
)
25
+
t.importSpecifier(t.identifier(localName), t.identifier(newImportedName))
29
26
);
30
27
}
31
28
···
33
30
}, {});
34
31
35
32
const importFiles = Object.keys(imports);
36
-
if (
37
-
importFiles.length &&
38
-
(importFiles.length !== 1 || importFiles[0] !== PKG_NAME)
39
-
) {
40
-
path.replaceWithMultiple(importFiles.map(key => imports[key]));
33
+
if (importFiles.length && (importFiles.length !== 1 || importFiles[0] !== PKG_NAME)) {
34
+
path.replaceWithMultiple(importFiles.map((key) => imports[key]));
41
35
}
42
36
},
43
37
},
44
38
},
45
39
};
46
-
}
40
+
};