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

Remove terser for react-native support #2263

Merged
merged 1 commit into from
Nov 21, 2022
Merged

Conversation

Perronef5
Copy link
Contributor

@Perronef5 Perronef5 commented Nov 16, 2022

CHANGES 📲

  • Removing rollup-plugin-terser for react-native support.

Reasoning

The anchor-ts client uses rollup to bundle ts code for the browser. In the process of bundling, it passes the code through a minification/uglification plugin called rollup-plugin-terser.

The terser mangles the code in a way that the the variable assigned to the import of @solana/web3.js is reused.

Something similar to this is happening in the final output:

var s = require("@solana/web3.js")

function x() {
  var s, a, b; // ----> redefined s
  ...
  s.TransactionInstruction() // ----> calls method on original s
}

Issues supporting this claim:

#1082
#2054
#1747
https://stackoverflow.com/questions/70652456/solanaweb-3-js-package-typeerror-s-transactioninstruction-is-not-a-constructor/70964609#70964609

@vercel
Copy link

vercel bot commented Nov 16, 2022

@Perronef5 is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@Henry-E
Copy link

Henry-E commented Nov 16, 2022

Cool, let's run the tests and see what happens!

@Perronef5
Copy link
Contributor Author

Perronef5 commented Nov 16, 2022

Cool, let's run the tests and see what happens!

Something happened 😅

@Henry-E Can we retry? Seems to be a connection issue

@Henry-E
Copy link

Henry-E commented Nov 17, 2022

  • very simple PR
  • removes terser() function, going to check why it was there in the first place first before removing
  • tests pass

Probably a merge

Before merging though @Perronef5 does this affect the original reason for the terser() function which was part of adding support for next.js #1108 ?

It seems like this might break the minification needed for next.js (though not sure, only gathered that from a cursory google search).

@Perronef5
Copy link
Contributor Author

  • very simple PR
  • removes terser() function, going to check why it was there in the first place first before removing
  • tests pass

Probably a merge

Before merging though @Perronef5 does this affect the original reason for the terser() function which was part of adding support for next.js #1108 ?

It seems like this might break the minification needed for next.js (though not sure, only gathered that from a cursory google search).

Dang thats a good point. Let me test with next.js

@tlrjs
Copy link

tlrjs commented Nov 21, 2022

Dang thats a good point. Let me test with next.js

Any findings here?

I can't see why Anchor specifically would need to be minified for Next.js. Mango uses Next.js with multiple dependencies that are not minified.

@Henry-E
Copy link

Henry-E commented Nov 21, 2022

Cool, just wanted to get confirmation either way as to whether it would be an issue to remove it. From what you're saying it's sounding less like it should be an issue.

@Henry-E Henry-E merged commit fb6508a into coral-xyz:master Nov 21, 2022
@Henry-E Henry-E removed the blocked label Nov 21, 2022
@Perronef5
Copy link
Contributor Author

Cool, just wanted to get confirmation either way as to whether it would be an issue to remove it. From what you're saying it's sounding less like it should be an issue.

Hey sorry for the late reply. I did get it working with NextJS so we should be good. I see you merged already just wanted to share my findings 👍🏽

Henry-E pushed a commit to Henry-E/anchor that referenced this pull request Dec 6, 2022
Co-authored-by: Luis Perrone <perronef5@users.noreply.github.com>
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.

3 participants