Closed roccomuso closed 1 year ago
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!
Build fails when included in create-react-app.
That issue regarding superstruct could be find in many other repos
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:
I see, looks like this issue is relevant and has been fixed: https://github.com/ianstormtaylor/superstruct/issues/404 just need to update superstruct in web3 now
Based on this comment it looks like the change will not work for RN: https://github.com/ianstormtaylor/superstruct/issues/404#issuecomment-753378281
I managed to get it to work on our app using a similar workaround to this: https://github.com/ianstormtaylor/superstruct/issues/404#issuecomment-753379956
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'],
...
}
}
This is resolved!
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.
solana-web3.js
right now doesn't work in react-native environment due to https://github.com/ianstormtaylor/superstruct/issues/86A different
superstruct
bundle without the.cjs
extension should be used. Or it could be replaced entirely with a different dependency.