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(build): Fix Node.js ESM/cjs-module-lexer compatibility #2485

Merged
merged 7 commits into from Jun 8, 2022

Conversation

kitten
Copy link
Member

@kitten kitten commented Jun 8, 2022

Resolve #2484

Summary

This fixes Node.js ESM compatibility of urql's @urql/core re-exports when the CommonJS module is used in ESM mode.

In Node.js' ESM mode, any CommonJS module will be analyzed with cjs-module-lexer, which then ensures that the module actually contains the exports that an ESM module requests. When a re-export is used, a heuristic is applied by the module which is prone to failure. Prior to this change, urql's reexport of @urql/core wasn't detected correctly.

I changed Rollup's CommonJS output until this was resolved and added a plugin to ensure future compliance.

Set of changes

  • Upgrade Rollup
  • Adjust Rollup's CommonJS output
  • Add plugin to check Rollup output with cjs-module-lexer

@kitten kitten requested a review from JoviDeCroock June 8, 2022 11:50
@kitten kitten requested a review from ryan-roemer as a code owner June 8, 2022 11:50
@changeset-bot
Copy link

changeset-bot bot commented Jun 8, 2022

🦋 Changeset detected

Latest commit: fe3bfe7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
next-urql Patch
urql Patch
@urql/preact Patch
@urql/svelte Patch
@urql/vue Patch
@urql/storybook-addon Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten changed the title Fix/node esm compatibility fix(build): Fix Node.js ESM/cjs-module-lexer compatibility Jun 8, 2022
@kitten kitten merged commit cf10d01 into main Jun 8, 2022
@kitten kitten deleted the fix/node-esm-compatibility branch June 8, 2022 12:15
@urql-ci urql-ci mentioned this pull request Jun 8, 2022
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.

(react-urql): Import error in Node.js ESM mode
2 participants