babel-plugin-modular-graphql
Advanced tools
Comparing version 0.1.0 to 0.1.1
16
index.js
@@ -1,2 +0,2 @@ | ||
export default function({ types: t }) { | ||
module.exports = function babelPluginModularGraphql({ types: t }) { | ||
const importMap = require('./import-map.json'); | ||
@@ -25,6 +25,3 @@ const PKG_NAME = 'graphql'; | ||
acc[from].specifiers.push( | ||
t.importSpecifier( | ||
t.identifier(localName), | ||
t.identifier(newImportedName) | ||
) | ||
t.importSpecifier(t.identifier(localName), t.identifier(newImportedName)) | ||
); | ||
@@ -37,7 +34,4 @@ } | ||
const importFiles = Object.keys(imports); | ||
if ( | ||
importFiles.length && | ||
(importFiles.length !== 1 || importFiles[0] !== PKG_NAME) | ||
) { | ||
path.replaceWithMultiple(importFiles.map(key => imports[key])); | ||
if (importFiles.length && (importFiles.length !== 1 || importFiles[0] !== PKG_NAME)) { | ||
path.replaceWithMultiple(importFiles.map((key) => imports[key])); | ||
} | ||
@@ -48,2 +42,2 @@ }, | ||
}; | ||
} | ||
}; |
{ | ||
"name": "babel-plugin-modular-graphql", | ||
"description": "Modular GraphQL.js import paths without the hassle", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "author": "Phil Pluckthun <phil@kitten.sh>", |
# babel-plugin-modular-graphql | ||
A small transform plugin to cherry-pick GraphQL modules so you don’t have to. | ||
Basicaly [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash) for [graphql](https://github.com/graphql/graphql-js). | ||
Basically [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash) for [graphql](https://github.com/graphql/graphql-js). | ||
@@ -30,1 +30,6 @@ ## Getting Started | ||
``` | ||
## Limitations | ||
- The plugin currently does not support `require()` | ||
- The plugin automatically generates an import-map that drills down into `graphql`'s files. This may break if files at a depth of 1–2 change their names. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24912
35
799