graphql-js
fix(esm): added export mapping to package.json for proper cjs/esm entrypoints
#4081
Open

fix(esm): added export mapping to package.json for proper cjs/esm entrypoints #4081

favna wants to merge 2 commits into graphql:next from favna:patch-1
favna
favna1 year ago👍 2

With the current code that doesn't define export mapping modern tooling such as vitest v1.6.0 tries to access the CJS version of GraphQL in my project (https://github.com/favware/graphql-pokemon) because it doesn't know where to find the ESM version. This subsequently causes the error:

Cannot use GraphQLNonNull "Ability!" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

By following the modern system of defining package entrypoints through the exports mapping this problem is solved because now vitest will properly access the ESM variant for graphql.

favna fix(esm): added export mapping to package.json for proper cjs/esm ent…
c7eb8bcb
linux-foundation-easycla
linux-foundation-easycla1 year ago (edited 1 year ago)

CLA Signed


The committers listed above are authorized under a signed CLA.

netlify
netlify1 year ago (edited 1 year ago)

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit e47fb5f
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/6638ea1be863740008e525e2
😎 Deploy Preview https://deploy-preview-4081--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

favna fix: fixed build-npm script and export mapping
e47fb5fb
favna
favna1 year ago

@benjie What is the way GraphQL addresses community bug fix PRs? I see GraphQL 16.8.2 got merged with a single bug fix as well and to be frank I'd say this one is equally as important because it also addresses bundlers and shipping code on modern ESM stacks.

benjie
benjie1 year ago

What is the way GraphQL addresses community bug fix PRs?

GraphQL is a community operated technology, so all bug fix PRs are community bug fix PRs. Contributors are encouraged to represent their fixes at a GraphQL.js WG where it can be discussed with other community members; you can add yourself to an agenda here: https://github.com/graphql/graphql-js-wg/tree/main/agendas/2024

If you can't make any meetings (for example, due to timezone concerns) then you can request someone to represent a topic for you - hopefully someone else agrees with the need for the feature and will then represent it on your behalf.

to be frank I'd say this one is equally as important

We agree that this is important; there's active research being conducted that relates to (and predates) your PR - please see #4074 for more details.

favna
favna356 days ago

I keep procrastinating preparing something and signing up but I do feel like I want to. The timezone should be fine just fine, I'm from The Netherlands so only 2 hours ahead of UTC.

benjie
benjie356 days ago

We’d love to see you there! Unfortunately I can’t make either of the next two meetings but I plan to be there in September.

yaacovCR
yaacovCR17 days ago

To be discussed at Thursday June 25 5pm UTC meeting https://github.com/graphql/graphql-js-wg/blob/main/agendas/2025/06-Jun/25-graphql-js-wg-june-2025.md

We invite everyone to consider joining if you are able!

favna
favna17 days ago (edited 15 days ago)

Oh my gosh I completely forgot I had this PR open still. I added tomorrow's meeting to my agenda and I'll try to remember to call in.

Edit: Making this edit while the call is still going on but sadly I missed it as I wasn't home in time. I'm looking forward to hearing back what was discussed.

Login to write a write a comment.

Login via GitHub

Reviewers
No reviews
Assignees
No one assigned
Labels
Milestone