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

(build) - Fix graphql imports for Webpack 5 #1094

Merged
merged 6 commits into from
Oct 28, 2020
Merged

Conversation

kitten
Copy link
Member

@kitten kitten commented Oct 28, 2020

Resolve #1086

Summary

Another week another small ESM issue in Webpack 5. In the upgrade Webpack now supports package.json:exports maps. However, a small problem with this support is how it handles sub-packages without a package.json:exports. There's a small quirk in Webpack that will require all import paths to be exact (including extensions) even when the sub-package doesn't have a package.json:exports map.

We're affected by this because we use our babel-plugin-modular-graphql plugin to convert some graphql imports into more specific ones. But instead of specifying files like graphql/language/visitor we need to add the full path like graphql/language/visitor.mjs. While I'm not convinced that this is the correct behaviour, it's an easy fix.

Set of changes

  • Upgrade to [email protected] which adds an extension option
  • Refactor Rollup build pipeline to move production/non-production plugins to output.plugins. This allows us to merge the two build runs into a single one.
  • Move babel-plugin-modular-graphql to cleanup() plugin.

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2020

🦋 Changeset detected

Latest commit: 297fe0f

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

This PR includes changesets to release 6 packages
Name Type
@urql/preact Patch
@urql/exchange-execute Patch
@urql/exchange-graphcache Patch
@urql/exchange-populate Patch
@urql/core Patch
@urql/introspection 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/graphql imports esm (build) - Fix graphql imports for Webpack 5 Oct 28, 2020
Copy link
Collaborator

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing!

@kitten kitten merged commit 9aed08f into main Oct 28, 2020
@kitten kitten deleted the fix/graphql-imports-esm branch October 28, 2020 13:46
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.

Webpack 5 resolution issues
2 participants