-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Disable Terser Mangle for Turbopack Compatibility #43
Conversation
|
Even if this addresses the issue, merging and releasing this wouldn't sit right with me. Sorry To explain the reasons as to why:
Since this points out a clear issue, and implies there's an underlying reproduction here, it should probably be reported with these resources to the Turbopack team. I'm quite sure that if this is an issue, duplicate issues, some maybe even with replies from their team, will exist. But without a clear reason to work around this, I'm not really sure why this should be changed on our end 😅❤️ |
It's important not to overlook the fact that Turbopack could potentially have the same issue with other packages in this context. However, from a developer's perspective, it might be a reasonable quick fix to change the naming during the build process (even though the root cause of the issue isn’t directly related to the That said, I completely agree that it is ultimately up to the team developing the package to decide how they want to handle this, and developers could potentially solve the issue themselves in their own projects using different approaches. For the sake of providing a concrete example, I've included a simple code snippet below where the e is not defined error occurs. The issue can be resolved by changing the definition of
I'll make sure to report this issue to Turbopack with the necessary details as well. Thanks for your feedback |
Cheers! Just to clarify, if they have acknowledged the bug and can't fix it quickly enough, or if they don't acknowledge it, I'm happy to come back to this and merge the workaround here 👍 |
Summary
This pull request addresses an issue where the
Kind
object was incorrectly transformed when building the package with Turbopack, specifically when used together with thegql.tada
package. Specifically, when using themangle
option in the Terser plugin, theKind
constant was renamed toe
, leading to runtime errors due to undefined references ("Kind": () => e
).Turbopack, unlike Webpack, can be sensitive to the mangling of variable names, and this was causing issues with the way
Kind
was being referenced. By disabling the mangling of variable names, we ensure that theKind
object retains its original name in the final build, making it compatible with Turbopack.Set of changes
mangle
option in Terser: The mangling of variable names has been turned off to prevent Turbopack from misinterpretingKind
ase
.Impact
Kind
object and other constants are not renamed during the build process, making the package work correctly with Turbopack while preserving the intended behavior.How to verify
Visuals
1. Before the Change (with Mangling enabled):
__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f40$0no$2d$co$2b$graphql$2e$web$40$1$2e$0$2e$11_graphql$40$16$2e$9$2e$0$2f$node_modules$2f40$0no$2d$co$2f$graphql$2e$web$2f$dist$2f$graphql$2e$web$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["Kind"] -> references 'e', which is 'undefined' in this case
2. After the Change (with Mangling disabled):
__TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f40$0no$2d$co$2b$graphql$2e$web$40$1$2e$0$2e$11_graphql$40$16$2e$9$2e$0$2f$node_modules$2f40$0no$2d$co$2f$graphql$2e$web$2f$dist$2f$graphql$2e$web$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__["Kind"] -> references 'Kind' correctly
Related Discussions/Issues:
ReferenceError: e is not defined error occurs when running next dev --turbo
Error after update to v1.0.10