Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

superstruct dependency and react native #1002

Closed
roccomuso opened this issue Dec 9, 2020 · 7 comments
Closed

superstruct dependency and react native #1002

roccomuso opened this issue Dec 9, 2020 · 7 comments

Comments

@roccomuso
Copy link

solana-web3.js right now doesn't work in react-native environment due to ianstormtaylor/superstruct#86

A different superstruct bundle without the .cjs extension should be used.
Or it could be replaced entirely with a different dependency.

@jstarry
Copy link
Contributor

jstarry commented Dec 14, 2020

Hey @roccomuso, could you please provide some more info on the issue that you're hitting for react native? The superstruct issue you linked doesn't seem to have anything to do with react native so I'm not sure what exactly the problem is, thanks!

@roccomuso
Copy link
Author

Build fails when included in create-react-app.

That issue regarding superstruct could be find in many other repos

@roccomuso
Copy link
Author

error: bundling failed: Error: While trying to resolve module superstruct from file node_modules/solana-web3.js/lib/validator-info.js, the package node_modules/superstruct/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (node_modules/superstruct/lib/index.cjs. Indeed, none of these files exist:

@jstarry
Copy link
Contributor

jstarry commented Dec 14, 2020

I see, looks like this issue is relevant and has been fixed: ianstormtaylor/superstruct#404 just need to update superstruct in web3 now

@leolangen
Copy link

leolangen commented Mar 16, 2021

Based on this comment it looks like the change will not work for RN: ianstormtaylor/superstruct#404 (comment)

I managed to get it to work on our app using a similar workaround to this: ianstormtaylor/superstruct#404 (comment)

We have a different version of metro-config in our project, using RN version 0.61.2

in the file metro.config.js in the root of the project, I added the cjs extension as follows:

...
const defaultSourceExts = require('metro-config/src/defaults/defaults').sourceExts 

module.exports = {
  ...
  resolver: {
    sourceExts: [...defaultSourceExts, 'cjs'],
    ...
  }
}

@steveluscher
Copy link
Contributor

This is resolved!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants