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

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

favna
Copy link

@favna favna commented May 6, 2024

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.

Copy link

linux-foundation-easycla bot commented May 6, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented May 6, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant