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

Bug: Mangling of Constants Causing Runtime Errors in GraphQL-based Packages with Turbopack #73383

Open
kushadige opened this issue Nov 30, 2024 · 1 comment · May be fixed by #73544
Open

Bug: Mangling of Constants Causing Runtime Errors in GraphQL-based Packages with Turbopack #73383

kushadige opened this issue Nov 30, 2024 · 1 comment · May be fixed by #73544
Labels
bug Issue was opened via the bug report template. linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Comments

@kushadige
Copy link

Link to the code that reproduces this issue

0no-co/graphql.web#43

To Reproduce

  1. Install and configure Next.js 15 with Turbopack and a GraphQL-based package (e.g., gql.tada).
  2. Start the application using Turbopack in development mode.
  3. Encounter runtime errors where exported constants (e.g., Kind) are incorrectly referenced (e.g., as e instead of e1).

Current vs. Expected behavior

Current behavior: Some exported constants in graphql.web, such as Kind as e, are incorrectly referenced during the bundling process in Turbopack, leading to references like e instead of the intended e1. This causes runtime errors because the application expects the correct constant name (e.g., e1 for Kind), but Turbopack provides an incorrect reference.

Expected behavior: The exported constants should be preserved with their correct names during bundling. For example, Kind should not be mangled to e or any other incorrect name, and it should maintain its correct reference throughout the build and runtime.

Example Code:
0no-co/graphql.web#43

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:02:45 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.5.0
  npm: 9.8.0
  Yarn: N/A
  pnpm: 9.7.1
Relevant Packages:
  next: 15.0.3 // Latest available version is detected (15.0.3).
  react: 19.0.0-rc-66855b96-20241106
  react-dom: 19.0.0-rc-66855b96-20241106
  gql.tada: 1.8.10
  graphql: 16.9.0
  urql: 4.2.1
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

@kushadige kushadige added the bug Issue was opened via the bug report template. label Nov 30, 2024
@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Nov 30, 2024
@mischnic mischnic added the linear: turbopack Confirmed issue that is tracked by the Turbopack team. label Dec 1, 2024
@nphmuller
Copy link
Contributor

nphmuller commented Dec 4, 2024

This is probably the same issue as #72232 although the title and description here are more descriptive of what's going on.

Worth re-sharing: if I change the variable name in the library from e to for example foo (and rename all references accordingly) the issue disappears. Turbopack now recognizes all references and mangles them correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants