SWC minify's mangling of classnames causes GCP library to fail an internal type check that relies on constructor.name #69930
Unanswered
Driptap
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Using GCP's BigQuery library to create a table from a file in GCS requires passing a (GCP Bigquery defined class)
File
object to the BigQuery client.The BigQuery client checks the
constructor.name
amongst other things to ensure the correct object is passed.The typecheck fails from what I have come to the conclusion is the mangling of the class name, resulting in a runtime error with the minified code.
I don't want to comment on this method of type checking an object, it seems it may be a recurring issue with other libraries that rely on this or similar methods; ie. as describe in this issue and this discussion.
It seems there is a possibility to configure SWC not to mangle class or function names.
I have made use of the
serverMinification
flag to overcome this issue but thought it'd be good to share this while SWC is being adopted into next.js.I don't have a lot of time to create a repro repository required for submitting a bug, so would be keen to know if there is another solution to allow the disabling of class name mangling that I've overlooked before putting time into that.
Beta Was this translation helpful? Give feedback.
All reactions