From 21908798243f43f5713ada1fe749741d3db9113c Mon Sep 17 00:00:00 2001 From: Alexander Roberts Date: Fri, 8 Jun 2018 05:51:50 -0500 Subject: [PATCH] Continue fixing compatibility with Babel 6 --- plugin/index.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/plugin/index.js b/plugin/index.js index ed99d1b..2361ebd 100644 --- a/plugin/index.js +++ b/plugin/index.js @@ -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: { @@ -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)