Skip to content
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

Can't build with Rollup due to Circular dependencies #924

Closed
acoreyj opened this issue Aug 10, 2018 · 9 comments
Closed

Can't build with Rollup due to Circular dependencies #924

acoreyj opened this issue Aug 10, 2018 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@acoreyj
Copy link

acoreyj commented Aug 10, 2018

Circular dependencies make building for browser with rollup impossible, you will get the below error in console.

Uncaught TypeError: Cannot read property 'checkForResolveTypeResolver' of undefined

Rollup outputs the following about the circular dependency

Circular dependency: node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/addResolveFunctionsToSchema.js -> node_modules/graphql-tools/dist/generate/index.js
Circular dependency: node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/addResolveFunctionsToSchema.js -> commonjs-proxy:/Users/Corey/Documents/workspace/mkr/examples/memory/node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/index.js
Circular dependency: node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/assertResolveFunctionsPresent.js -> node_modules/graphql-tools/dist/generate/index.js
Circular dependency: node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/attachConnectorsToContext.js -> node_modules/graphql-tools/dist/generate/index.js
Circular dependency: node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/buildSchemaFromTypeDefinitions.js -> node_modules/graphql-tools/dist/generate/index.js
Circular dependency: node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/checkForResolveTypeResolver.js -> node_modules/graphql-tools/dist/generate/index.js
Circular dependency: node_modules/graphql-tools/dist/generate/index.js -> node_modules/graphql-tools/dist/generate/concatenateTypeDefs.js -> node_modules/graphql-tools/dist/generate/index.js
@acoreyj acoreyj changed the title Circular dependencies and rollup Can't build with Rollup due to Circular dependencies Aug 10, 2018
@stubailo
Copy link
Contributor

I'd accept a PR to fix this, but making this work with Rollup specifically isn't a big priority since this is (1) primarily a server-side library and (2) circular dependencies are explicitly a part of JavaScript so hopefully Rollup can one day support them.

@stubailo stubailo added the help wanted Extra attention is needed label Aug 10, 2018
@stubailo
Copy link
Contributor

Even better would be an automated test to check for Rollup compatibility, since this is very likely to regress in the future.

@dnalborczyk
Copy link
Contributor

dnalborczyk commented Aug 20, 2018

circular dependencies are explicitly a part of JavaScript so

I think this is a little too generalized. it depends on the module system (es6, cjs, amd, umd) one is using. I don't know rollup much, and not sure if the above is valid or not, but having circular dependencies sounds like code smell. it might also cause problems when graphql-tools is switching to es6 modules in the future.

@bennypowers
Copy link

bennypowers commented Dec 10, 2018

The best way to fix this would be to distribute standard modules.

If a CJS build is needed, it could be automated with rollup.

I'd be happy to make a PR for that.

I can't at the moment use this library (for client-side code) in testing because it fails to build, due to the heavy transformations applied to the source

I'd accept a PR to fix this, but making this work with Rollup specifically isn't a big priority since this is (1) primarily a server-side library and (2) circular dependencies are explicitly a part of JavaScript so hopefully Rollup can one day support them.

This kind of comes off like you're saying "Rollup users and developers who write standard javascript don't matter". I'm sure that's not what you mean, but there are a lot of developers who would love to use your libraries if the barrier to entry was lowered a little (read: if they could just import it like normal).

The tide towards standard js is already turning with projects like pikapkg.com satisfying the desire for cruft-free JS. Please let the community help you ride that wave 〰️ .

gaberudy added a commit to gaberudy/graphql-tools that referenced this issue Jan 23, 2019
@btakita
Copy link

btakita commented May 22, 2019

It seems like the only way to get around this atm is to use commonjs instead of ESM (import) for anything related to graphql.

@btakita
Copy link

btakita commented May 22, 2019

Is this project still active & accepting pull requests?

btakita pushed a commit to btakita/graphql-tools that referenced this issue May 22, 2019
@btakita btakita mentioned this issue May 22, 2019
@langpavel
Copy link

This is not only about rollup. This is about every module which need call this library immediately, in initialization phase.

@yaacovCR
Copy link
Collaborator

Is this project still active & accepting pull requests?

Yes!

@yaacovCR
Copy link
Collaborator

yaacovCR commented Mar 31, 2020

Should be fixed by #1326, rolling into #1306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants