-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update docs for commonjs import patterns #1090
Comments
hmm! so how are you importing graphiql, from CDN or via webpack using // index.js
const { default: GraphiQL } = require('graphiql'); now, because before we had this: // index.js
module.exports = GraphiQL but that broke tree shaking so now we do a default esm export instead: |
so my bad, I should have updated docs and possibly made this a breaking change |
let me know if that fix works for you @Chetabahana. here are the available import patterns: import { GraphiQL } from 'graphiql';
import GraphiQL from 'graphiql';
// note: using cjs will ead to larger bundler builds
const { GraphiQL } = require('graphiql');
const { default: GraphiQL } = require('graphiql');
const GraphiQL = require('graphiql').default; |
I was using this code :
I will try to use your suggestion and let you know. |
Thank you @acao. There is one working which is: const { default: GraphiQL } = require('graphiql'); These two are not working (same errors): const { GraphiQL } = require('graphiql');
const GraphiQL = require('graphiql').default; Also the for Import code: import { GraphiQL } from 'graphiql';
import GraphiQL from 'graphiql'; Detail error for the import: Error: Parsing file /home/runner/work/tree/tree/test/fixtures/three.graphql/editor.js: 'import' and 'export' may appear only with 'sourceType: module' (4:0)
at Deps.parseDeps (/home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/module-deps/index.js:510:15)
at getDeps (/home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/module-deps/index.js:438:44)
at /home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/module-deps/index.js:421:38
at ConcatStream.<anonymous> (/home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/concat-stream/index.js:37:43)
at ConcatStream.emit (events.js:215:7)
at finishMaybe (/home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/readable-stream/lib/_stream_writable.js:630:14)
at endWritable (/home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/readable-stream/lib/_stream_writable.js:638:3)
at ConcatStream.Writable.end (/home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/readable-stream/lib/_stream_writable.js:594:41)
at DuplexWrapper.onend (/home/runner/work/tree/tree/test/fixtures/three.graphql/node_modules/readable-stream/lib/_stream_readable.js:577:10)
at Object.onceWrapper (events.js:299:28) |
interesting! import/export issue looks like its related to your bundler perhaps. i should add some tests for this as well. what are you using to bundle GraphiQL? im familiar with webpack and rollup, somewhat with parcel, and that message output looks unfamiliar, maybe even reminiscent of broccoli or gulp? |
Here is the code:
It is placed in a build script and run with npm run-script via scripts field in package.json |
ah ok! we just migrated our library build from the original browserify setup, but yeah it should still be supported for consumption just fine! the babel config and plugin versions in the webpack example should give you a good start if you still need to finesse them! |
Ok thanks. I am going to look in to that option. |
i think you'll need to use |
i am learning on it, the browserify editor.js -t brfs -o build.js --no-babelrc i do appreciate if you could advise more, here is my tutorial link at the moment |
Finally I get my package up and running using your import code:
By following documentation of Babelify Options and Browserify Handbook on Configuring Transforms I changed the bundel code as below:
Here is my current package.json. I am still on the way to bundle with webpack. |
Case
I updated package deps from v0.16.0 to v0.17.0, v0.17.1 and v0.17.2 which all are fine.
But got errors from the version v0.17.3 up to the latest v0.17.5 on React.createElement:
Kindly please advise. Thanks.
Details
Screenshot
The text was updated successfully, but these errors were encountered: