Apollo-client: React Native bundling error because of babel plugin in graphql package

Created on 2 May 2016  路  8Comments  路  Source: apollographql/apollo-client

Hi, I installed the apollo-client on react-native and got this error:

transformed 1390/1392 (100%)[node-haste] Encountered an error while persisting cache:
ReferenceError: Unknown plugin "transform-runtime" specified in "/Users/9_Semester/node_modules/graphql/package.json" at 5, attempted to resolve relative to "/Users/9_Semester/node_modules/graphql"
at /Users/9_Semester/node_modules/babel-core/lib/transformation/file/options/option-manager.js:179:17
at Array.map (native)
at Function.normalisePlugins (/Users/9_Semester/node_modules/babel-core/lib/transformation/file/options/option-manager.js:155:20)
at OptionManager.mergeOptions (/Users/9_Semester/node_modules/babel-core/lib/transformation/file/options/option-manager.js:277:36)
at OptionManager.addConfig (/Users/9_Semester/node_modules/babel-core/lib/transformation/file/options/option-manager.js:207:10)
at OptionManager.findConfigs (/Users/9_Semester/node_modules/babel-core/lib/transformation/file/options/option-manager.js:419:30)
at OptionManager.init (/Users/9_Semester/node_modules/babel-core/lib/transformation/file/options/option-manager.js:461:12)
at File.initOptions (/Users/9_Semester/node_modules/babel-core/lib/transformation/file/index.js:194:75)
at new File (/Users/9_Semester/node_modules/babel-core/lib/transformation/file/index.js:123:22)
> TransformError: /Users/9_Semester/node_modules/graphql/language/parser.js: Unknown plugin "transform-runtime" specified in "/Users/9_Semester/node_modules/graphql/package.json" at 5, attempted to resolve relative to "/Users/9_Semester/node_modules/graphql"

After installing the babel-plugin-transform-runtime I got the same error with the preset es2015. After installing them both, it works.

馃悶 bug

Most helpful comment

I'm going to tackle React Native this week. It seems like just a very small modification would fix this bug, and then we can put React Native on the homepage.

All 8 comments

That's odd - @martijnwalraven did you see this when working with react native?

Had the same with respect to 'transform-runtime' as reported in this issue.

I already had preset ES2015 installed.

So is the solution to somehow declare those dependencies? It's kind of weird that the package.json of the graphql package is affecting us..

Yes, I also had to install these manually, see here for the steps I followed. I linked to what might be a related issue about React Native's Packager there, but I don't fully understand what is going on or what we can do about it yet.

We can test out fixes with this boilerplate: https://github.com/scaphold-io/react-native-starter-kit

I'm going to tackle React Native this week. It seems like just a very small modification would fix this bug, and then we can put React Native on the homepage.

Btw, link to the graphql bug: https://github.com/graphql/graphql-js/issues/414

OK, I believe we have conclusively fixed this issue in Apollo Client version 0.3.27, which now depends on graphql-tag, which contains a pre-bundled GraphQL printer and parser to avoid the build issues. Let me know if this doesn't work! Big thanks to @abhiaiyer91 for building the bundle script.

Was this page helpful?
0 / 5 - 0 ratings