-
Notifications
You must be signed in to change notification settings - Fork 964
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
Create React App is broken by lack of default polyfills in Webpack 5 #241
Comments
It's worth noting that |
I discovered this when I started working on adding check for import extensions to eslint: 7b44365 |
Recommended solution seems to be:
Full breakdown: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c |
🧐 this is unrelated. Fixed this by adding the missing transient dependencies
or by removing "eslintConfig": {
"extends": [
"react-app",
- "react-app/jest"
]
}, |
I am facing the same issues and I am using node |
Need to fix this asap |
Linting and the starter projects are fixed thanks to @cogoo in #245. This issue is otherwise blocked until Craco fully supports CRA 5 / Webpack 5 and we can configure Webpack to build with ESM modules that don't use .mjs extensions. Until then, please use one of the starter projects that use Next.js or CRA 4. They work right now and don't require additional configuration. Instructions to run the React UI + CRA4 starter project are here: |
Any recommendation to those who have already started a project? I'd rather not remake my project and just want to fix this to continue working |
Nope, there's no good workaround at this time, sorry. CRA 5 is not supported. |
It's relatively straightforward to take your code from your CRA 5 app and drop it into the CRA 4 based react-ui-starter project though. |
fair enough, thanks |
Hey guys, I got it to work. I uninstalled the libraries listed below and downloaded them again with these specific versions: |
@Malai237 you don't need to downgrade the packages to get this to work with CRA 4. The react-ui-starter project works out of the box with the latest versions of the packages using CRA 4. |
Just published:
These packages include #245 and should work with CRA4 / Craco. |
I was not able to get the starter projects to work. Since there is a parent directory to the For example: The instructions in https://github.com/solana-labs/wallet-adapter#build-from-source Clone the project:
Install dependencies:
Build all packages:
Run locally:
Then I moved the |
I can't even get this to work with CRA 4. Jest tests break:
|
So I have learned that the issue is specifically with |
This is because of Lerna + Yarn workspaces linking the dependencies locally. If you move |
What tests are you running? The only Jest tests that ship with this project right now are in the React package. This shouldn't affect your starter project running, right? |
As for the Jest tests that ship with the React package, they run and pass:
|
I just did this and it works. |
Perhaps we should configure the starter projects to disable hoisting since they are supposed to run standalone. Comes at the expense of initial install time, but maybe worthwhile? cc @cogoo |
Just to add my experience, the packages don't work with the latest Next.js version (12.0.7) in a project I created via CNA. Downgrading to Next.js 11 as used in the starter seems to have worked though. Next.js now uses SWC instead of webpack by default, so might this also be part of the problem? I'm not familiar with the details at all so please forgive me if this is a dumb question, but it seems like using mjs extensions for the esm exports has the broadest compatibility and resolves the issue, so is there a reason not to do that? |
@gpoole #246 is probably related to the Next.js issue. I'm also not familiar with it and haven't tested with Next 12.
@cogoo you spent a good bit of time trying out different builds, wdyt? |
I sort of suspect that's true: yarnpkg/yarn#2914 (comment) Maybe we should #yolo merge this, publish it, and see? |
Published:
Using these dependencies should fix the polyfill / CRA problems with no additional config required. Huge thanks to @steveluscher for his heroic effort debugging and fixing this both here and in upstream projects. |
(And if this doesn't fix all the CRA issues, at least we're a bit closer) |
@steveluscher lol |
@jordansexton What's holding #276 back from being merged in? I'm trying to do work in a repo where my coworkers and I are using Webpack 5 and this is blocking us from moving forward. There are manual fixes that we've tried that work but those are not satisfactory for shipping of course. EDIT: I see that PR was only opened on Thursday or something so makes sense that it isn't in. Appreciate the work y'all are doing |
@TomLisankie thanks for understanding. #276 just needs to be tested before merging (I rushed to publish its predecessor #264 and broke all the packages) and I haven't had time to test it yet. |
Got it, thanks. |
Anyone have issue with latest wallet adapter with cra 4.0 ?
|
Can someone please document what the correct work around would be? As stated above, simply downgrading CRA does not work |
See #265! |
Published:
Please try these packages using CRA 5! And huge thanks to @steveluscher for your tireless work on this. |
Amazing! Thanks |
This is fixed via #299. The core issue is that the Torus and Ledger JS libraries don't correctly polyfill and incorrectly use globals, and this isn't handled by Webpack 5 without additional configuration, which you can't add with CRA5 alone. We use react-app-rewired to override, as Craco doesn't support CRA5 yet. See the new create-react-app-starter project. The key parts are the config-overrides.js file and Published:
|
@jordansexton thanks for all of this. I took my CRA project and just copied over the releveant parts from the package.json (devDependencies) and config.json into my existing project and all is well |
I got the error message
Sorry I didn't find the right solution,Tried the upgrade version to no avail, Can someone tell me how to fix it, thanks |
Did anyone manage to fix this issue? ./node_modules/@netless/window-manager/dist/index.mjs |
working with solana has been the worst experience of my programming life |
Edit by @jordansexton:
To anyone looking for a very good workaround right now, don't use Create React App. Just use the react-ui-starter or material-ui-starter projects with Parcel, or the nextjs-starter project with Next.js, save yourself a huge hassle, and get much faster builds with SWC instead of Babel.
Describe the bug
Broken build with CRA v5, unable to resolve modules.
To Reproduce
Steps to reproduce the behavior:
npx create-react-app my-app-test
Solution
Relative imports must include a file extension to follow ESM strict mode requirements introduced in Webpack 5. It's valid typescript to include
.js
extensions as part of the import path 🤯 :example.ts
compiles to
example.js
The text was updated successfully, but these errors were encountered: