-
Notifications
You must be signed in to change notification settings - Fork 958
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
Building a fresh project with create react app gives a module error. #200
Comments
It looks like this is an issue coming from react-scripts v5, which is what the new app is being initialized with. The react-ui-starter project builds as expected with react-scripts v4: https://github.com/solana-labs/wallet-adapter/blob/52c5195cb64ed3b8aec00e104b2cafc681818c2c/packages/starter/react-ui-starter/package.json#L43 Looking @ https://github.com/facebook/create-react-app/releases/tag/v5.0.0 it seems like the switch the Webpack 5, or maybe the eslint changes, could be responsible. |
A potential workaround is described here: reduxjs/redux#4174 {
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
}, |
Thanks for the reply. I'm not expert, so forgive me if I'm mistaken, but I think doing webpack config modifications requires the create-react-app project to eject, right? I verified that it works fine in CRA v4. |
I'm also not an expert on CRA. But I think you can customize your config without ejecting using https://github.com/gsoft-inc/craco |
I saw that project in the react-ui starter and thought it would help but Craco only supports CRA v4 according to their current readme. :( |
Let me know if you find anything about the issue! |
Had the exact same issue using CRA v5. Not sure if this is a good solution, but manually changing the package.json to "react-scripts": "^4.0.3" and running "yarn install" after worked for me. |
Yeah, I would recommend to anyone reading this to not use CRA v5 until dilanx/craco#353 is resolved and we can upgrade the starter packages here with an updated version of Craco. |
This worked for me as well. Thanks for the suggestion! Hopefully they fix soon. |
Worked for me beautifully. Thanks edit: doesn't work for tests, unfortunately. only for building |
I tried today to build an app with my own webpack configuration. For people that tried to do the same thing and get brought here, check this answer on stack overflow + add .mjs loader as dlazares has shown. https://stackoverflow.com/questions/69431515/how-to-use-webpack-and-web3-in-react |
Is there any fix to this? |
@kevinforrestconnors did you try running the code in the CRA-based starter projects? |
Which config file does this code need to be in? |
@kevinforrestconnors see reduxjs/redux#4174 for that |
I installed craco and ran the tests using this config:
module.exports = {
webpack: {
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
}; Same issue,
|
@kevinforrestconnors there isn't enough context to know what the issue is from an error like that. I'm happy to take a look, but please provide a link to a repository that reproduces the issue for you and steps on how to reproduce it. |
thanks for taking a look, here is a reproducible repo https://github.com/kevinforrestconnors/reproducible-issue to reproduce, |
@jordansexton, I'm facing the same issue now. But I'm not using Craco. There's something should be done with my webpack.config.js (I think). Here's the error I see:
|
Look at my previous answer. It should resolve your problem. |
Updating to the latest version of these packages fixes the issue "@solana/wallet-adapter-base": "^0.9.0",
"@solana/wallet-adapter-react": "^0.15.0",
"@solana/wallet-adapter-react-ui": "^0.8.0",
"@solana/wallet-adapter-wallets": "^0.14.0", |
Could you share what you're trying to import? From the error it looks like you're trying to do a deep import, consider importing from the root of the package: import {Adapter} from '@solana/wallet-adapter-wallets'; |
That was really helpful. Thx <3 |
Closing since it seems like the issues are fixed in the current release which ships proper ESM and CJS builds. Thanks everyone for your input! If you're still having issues after upgrading, please open a new issue with a reproduction. |
Describe the bug
Building a fresh project with create react app gives an error. Note, that this is with create react app v5.
To Reproduce
Steps to reproduce the behavior:
Then copy your example code into the project.
Expected behavior
builds
The text was updated successfully, but these errors were encountered: