Repository navigation
React build breaks after migrating to 15.5.1 #14389
Copy link
Copy link
Closed
Labels
outdatedscope: reactIssues related to React support for NxIssues related to React support for Nxtype: bug
Description
Current Behavior
After we migrated to v15.5.1 (from 15.4.4), a few of our React apps started failing on builds.
There was a polyfill for node (which I couldn't find in code history, but it might have been another polyfill) that does not exist anymore.
We are using a custom webpack configuration which is using the plugin from @nrwl/react/plugins/webpack.
I assume this is caused by one of those:
- feat(webpack): remove support for legacy browsers (#14190) #14257
- feat(webpack): generate React and Web apps with webpack.config.js file #14285
Expected Behavior
Should work as it previously did.
Github Repo
No response
Steps to Reproduce
- Create a repo with a React app
- Install
graphql-request - Use it anywhere in your code
- Run a build
Nx Report
Node : 16.16.0
OS : darwin arm64
yarn : 3.3.1
nx : 15.5.1
@nrwl/angular : Not Found
@nrwl/cypress : 15.5.1
@nrwl/detox : Not Found
@nrwl/devkit : 15.5.1
@nrwl/esbuild : Not Found
@nrwl/eslint-plugin-nx : 15.5.1
@nrwl/expo : Not Found
@nrwl/express : Not Found
@nrwl/jest : 15.5.1
@nrwl/js : 15.5.1
@nrwl/linter : 15.5.1
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 15.5.1
@nrwl/nx-cloud : 15.0.2
@nrwl/nx-plugin : 15.5.1
@nrwl/react : 15.5.1
@nrwl/react-native : Not Found
@nrwl/rollup : 15.5.1
@nrwl/schematics : Not Found
@nrwl/storybook : 15.5.1
@nrwl/web : 15.5.1
@nrwl/webpack : 15.5.1
@nrwl/workspace : 15.5.1
@nrwl/vite : 15.5.1
typescript : 4.9.4
---------------------------------------
Local workspace plugins:
@island/workspace
---------------------------------------
Community plugins:
nx-stylelint: 14.0.2Failure Logs
ERROR in ./node_modules/combined-stream/lib/combined_stream.js 2:13-37
Module not found: Error: Can't resolve 'stream' in '/Users/dan/work/apps/node_modules/combined-stream/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
@ ./node_modules/graphql-request/node_modules/form-data/lib/form_data.js 1:21-47
@ ./node_modules/graphql-request/dist/createRequestBody.js 7:34-54
@ ./node_modules/graphql-request/dist/index.js 178:42-72
@ ./apps/app/src/app/api/graphql/rpa-store-client.ts 1:0-38 9:40-43
@ ./apps/app/src/features/foo/Drawer.tsx 31:0-33:48 134:6-19
@ ./apps/app/src/components/Drawers/DrawerList.ts 19:0-67 152:46-60
@ ./apps/app/src/components/Drawers/Drawers.tsx 5:0-42 11:18-28
@ ./apps/app/src/app/App.tsx 5:0-56 25:314-321
@ ./apps/app/src/index.tsx 5:0-35 17:216-226Additional Information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
outdatedscope: reactIssues related to React support for NxIssues related to React support for Nxtype: bug
Activity
mandarini commentedon Jan 16, 2023
Mentioning this here as potentially related?
vadimka123 commentedon Jan 17, 2023
I think it more excepted behavior because webpack removed polyfills by default in v5, same did nx team
kenneth-toxcon commentedon Jan 17, 2023
Seems related to a change added in #14285
nvonbenken commentedon Jan 18, 2023
I'm also running into this.
bdebon commentedon Jan 19, 2023
Same issue on a react project. Was trying to migrate from 15.0.3 -> 15.5.2
kenneth-toxcon commentedon Jan 19, 2023
@bdebon migrating to 15.4.4 works for me now.
ivi-hamiti commentedon Jan 19, 2023
encountered same issue when upgraded from 15.4.2 -> 15.5.2
jihoun commentedon Jan 20, 2023
According to my test it appeared in 15.4.6
PointSingularity commentedon Jan 23, 2023
15.5.3 Still has the same problem.
bigcakes commentedon Jan 23, 2023
Also hitting this issue, pretty surprising for a minor bump
mandarini commentedon Jan 23, 2023
This should be fixed in latest version. Can you please try again with latest (
15.5.3)?bdebon commentedon Jan 23, 2023
Hello,
I have the sensation 15.5.3 did not fix it either.
I end up with this error while running
nx serveand here is the list of our deps
mandarini commentedon Jan 23, 2023
Ok, these two PRs should fix it I think:
#14546 and #14478
bdebon commentedon Jan 23, 2023
Hey! Thank you for the feedbacks!
I was doing the first PR by myself because it was breaking anyways, but did not try the content of the second PR. I'll try later or I'll try it altogether when merged.
Thank you again for the quick feedback
jaysoo commentedon Jan 23, 2023
The issue is that
resolve.mainFieldsneed the first entry to bebrowserfor packages likeaxiosso the right entry point is used. In this case, because it is missing,axiostries to pull inurl` and other Node built-ins.We'll patch this in the next release, for now the workaround is to edit your
webpack.config.jsfile and manually add this entry.e.g.
And make sure
project.jsonpoints to this file:zackarydev commentedon Jan 23, 2023
jaysoo commentedon Jan 23, 2023
@ZackTherrien That looks like a different issue.
jaysoo commentedon Jan 23, 2023
Fixed here #14546
jihoun commentedon Jan 24, 2023
seems to be more accurate
bdebon commentedon Jan 24, 2023
I confirm the migration to the
15.6.0was flawless! Everything is back to normal. Thank you very much for the reactivity, you're the bests!github-actions commentedon Mar 3, 2023
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.