Skip to content

Commit

Permalink
Continue fixing compatibility with Babel 6
Browse files Browse the repository at this point in the history
  • Loading branch information
detrohutt committed Jun 8, 2018
1 parent 5e0f343 commit 2190879
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ let seenJSFiles = new Set()
export default ({ types: t, template }) => ({
manipulateOptions({ resolveModuleSource, plugins }) {
resolve = resolveModuleSource || defaultResolve

const thisPlugin = plugins.find(p => {
const key = p.key || p[0].key
return key.indexOf('babel-plugin-import-graphql') !== -1
})

const options = thisPlugin.options || thisPlugin[1]
if (options.runtime) {
try {
require('graphql-tag')
} catch (e) {
throw new Error(missingOptionalDep)
}
}
},
visitor: {
ImportDeclaration: {
Expand All @@ -33,6 +19,14 @@ export default ({ types: t, template }) => ({
const jsFilename = file.opts.filename

if (importPath.endsWith('.graphql') || importPath.endsWith('.gql')) {
if (opts.runtime) {
try {
require('graphql-tag')
} catch (e) {
throw new Error(missingOptionalDep)
}
}

// Find the file, using node resolution/NODE_PATH if necessary.
const fallbackPaths = opts.nodePath
? opts.nodePath.split(delimiter)
Expand Down

0 comments on commit 2190879

Please sign in to comment.