-
Notifications
You must be signed in to change notification settings - Fork 164
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
Upgrade CRA, webpack5, storybook 4.6 #405
Conversation
32b8f38
to
4332191
Compare
3ced686
to
62f0cc2
Compare
A number of issues for this have been fixed externally, and internally to headlamp in separate PRs. Next step is rebase this so it is much smaller, and also to try and find a solution to the remaining issue found after the upgrade. |
c6f8c6f
to
aa30a20
Compare
The failure here is related to a headlamp-plugin types issue with notifications. |
cfdd8b7
to
7faf8b6
Compare
@joaquimrocha this one is ready to review. |
When running Otherwise, since it seems to work, and as you said, there's no great alternative to the patching. I think we can go ahead with this (as much as I'd like to avoid adding more complexity to the project). |
This is fixed. I updated how this works according to the latest instructions (adding the package and removing the npx part in the postinstall). |
Upgrade dependencies
Create React App 5 (which uses Webpack 5) and storybook 4.6, and
npm audit --fix
.Some dependencies haven't been updated to work with Webpack 5, because webpack 5 doesn't pollyfill node modules with their browser equivalents anymore (it is considered a bug by Create React 5 which they are going to fix inside CRA but they haven't fixed it yet). To work around this until the bug is fixed upstream, patch-package is used to hotfix this issue.
How to use
Everything should work as before.
Testing done
Create React 5, Webpack 5, Storybook 6.4 upgrade notes
Below are notes made during upgrading and working through issues.
Create React Webpack 5 issues with deps on node modules
facebook/create-react-app#11756
package aliaseshttps://github.com/facebook/create-react-app/issues/11756#issuecomment-998418988
Storybook webpack 5
https://storybook.js.org/blog/storybook-for-webpack-5/
@axe-core
crypto-browserify
"Failed to parse source map"
'@storybook/preset-create-react-app' doesn't work with storybook. Hasn't been updated for CRA 5.
tools which allow own configuration
issues raised
Module not found: Error: Can't resolve 'http' in '/home/rene/dev/headlamp/frontend/node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers'
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
- install 'stream-http'
Module not found: Error: Can't resolve 'https' in '/home/rene/dev/headlamp/frontend/node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers'
Least bad way to use CRA 5
I've added issues to packages affected by no-node-polyfills-in-webpack5, and there might be an option to use polyfills in CRA 5
However, what to do for now?
The least big change which doesn't block us is to use patch-package.
vi node_modules/react-scripts/config/webpack.config.js
process
Uncaught ReferenceError: process is not defined
at Object../node_modules/@apidevtools/json-schema-ref-parser/lib/util/url.js (bundle.js:31294:29)
at Object.options.factory (bundle.js:370810:31)
at webpack_require (bundle.js:370203:33)
at fn (bundle.js:370481:21)
at Object../node_modules/@apidevtools/json-schema-ref-parser/lib/util/errors.js (bundle.js:30998:5)
at Object.options.factory (bundle.js:370810:31)
at webpack_require (bundle.js:370203:33)
at fn (bundle.js:370481:21)
at Object../node_modules/@apidevtools/json-schema-ref-parser/lib/parsers/json.js (bundle.js:29495:5)
at Object.options.factory (bundle.js:370810:31)
node_modules/@apidevtools/json-schema-ref-parser/lib/util/url.js
npm install
"@apidevtools/json-schema-ref-parser
Issue with npm run storybook
https://storybook.js.org/blog/storybook-for-webpack-5/
This is one of the original issues...
Issue with Jest
Jest doesn't support ESM modules yet.
remarkjs/react-markdown#635 (comment)
react-markdown is only releasing as ESM.
So we need to add a bunch of jest config in package.json with transformIgnorePatterns to ignore dependencies of react-markdown.
eslint-plugin-react dependency
There was an issue with eslint-plugin-react version conflict: jsx-eslint/eslint-plugin-react#3128 (comment)
typedoc
Had to upgrade typedoc. Re: typedoc2md/typedoc-plugin-markdown#283 (comment)
node 10 EOL, node 16 active LTS
Seems lots of packages are dropping node 10 support, since it's no longer supported. This is the default on Ubuntu 20.04.
Current LTS is node 16. https://nodejs.org/en/about/releases/
Node 12 End of life is in a few months April 30(2022-04-30.)
npm install prod build
npm install util url buffer
npm install postcss-flexbugs-fixes
mac electron build with nodejs 16
From this issue, there appears to be a merged PR with a fix. electron-userland/electron-builder#5862
electron-builder 22.11.2 contains the fix: https://github.com/electron-userland/electron-builder/releases/tag/v22.11.2
22.11.2 failed to build on linux, using [email protected]