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

Re-export graphql-tag exports directly, without destructuring. #8221

Merged
merged 1 commit into from
May 14, 2021

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented May 14, 2021

Seems to fix #8217, judging from the provided reproduction. Presumably this is because using ECMAScript export...from syntax means we don't have to import anything into the scope of the index.ts module, which makes the whole situation easier for the tree-shaker to reason about.

Seems to fix #8217, judging from the provided reproduction. Presumably
this is because using ECMAScript re-export syntax means we don't have to
import anything into the scope of the index.ts module, which makes
the whole situation easier for the tree-shaker to reason about.
Copy link
Contributor

@brainkim brainkim left a comment

Choose a reason for hiding this comment

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

lgtm

@benjamn benjamn merged commit 19a58e1 into main May 14, 2021
@benjamn benjamn deleted the improve-graphql-tag-tree-shakability branch May 14, 2021 17:56
@cecchi
Copy link

cecchi commented May 25, 2021

FWIW: We're still seeing graphql-tag wind up in our bundle with a Webpack setup and apollo/[email protected]. We precompile all operations, so this is unexpected. I don't have a reproduction repo I can share unfortunately, but am curious whether other Apollo users are running into the same issue still.

Inspecting the Webpack stats shows the reason for the package's inclusion as "harmany side effect" or "harmony import specifier". From a sample build's stats:

        {
          "moduleId": "krkH",
          "moduleIdentifier": "/my-project/node_modules/graphql-tag/lib/index.js 7f8f243dc3479ff2d3a02646936a0fda",
          "module": "../node_modules/graphql-tag/lib/index.js + 14 modules",
          "moduleName": "../node_modules/graphql-tag/lib/index.js + 14 modules",
          "type": "harmony side effect evaluation",
          "userRequest": "./ast.mjs",
          "loc": "3:0-37"
        },
        {
          "moduleId": "krkH",
          "moduleIdentifier": "/my-project/node_modules/graphql-tag/lib/index.js 7f8f243dc3479ff2d3a02646936a0fda",
          "module": "../node_modules/graphql-tag/lib/index.js + 14 modules",
          "moduleName": "../node_modules/graphql-tag/lib/index.js + 14 modules",
          "type": "harmony import specifier",
          "userRequest": "./ast.mjs",
          "loc": "31:31-36"
        }

@nbudin
Copy link

nbudin commented May 27, 2021

I'm seeing the same thing @cecchi is, and in case a reproduction repo is helpful, here's our app that is experiencing this same issue: https://github.com/neinteractiveliterature/larp_library

@hwillson hwillson removed this from the MM-2021-06 milestone Jul 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-exports from graphql-tag prevent Webpack from tree-shaking correctly
5 participants