-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feat: Upgrade major deps and to Webpack 5 #1202
Conversation
This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was also able to resolve the peer dependencies without much issues.
Hmm I am confused here. Doesnt npm also easily resolve peer dependencies for you? like at most we can just run the npm download to install peer deps?
In fact, there should be no reliance on process.env for e2e tests.
This is not true right, we would need the GitHub access tokens for this? Additionally, this could be the case in the future right, how do we deal if that is the case?
There were some sourcemap generation warnings on service start. This seems to be an issue from Create React App and Webpack 5. See this open issue for more details.
Hence, for now I have disabled sourcemap generation in the dev command.
Hmm I am not too sure about this. I rather generate warning and fail quickly rather than disabling sourcemap as a whole during development
Other non-nits:
we should have an issue to use yarn in the backend!
.eslintrc.json
Outdated
@@ -41,7 +41,9 @@ | |||
"react/jsx-props-no-spreading": "warn", | |||
"react/require-default-props": "off", | |||
"import/prefer-default-export": "off", | |||
"@typescript-eslint/ban-ts-comment": "off", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, why are we turning this off ah?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were quite a few typescript errors. I fixed most of them, except 1-2 which I had to ignore. I think if you look through below you would find 1-2 places where I am using ts-ignore to ignore the error for now.
@seaerchin mentioned he can help look into that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is only 1-2 places, could we mark them at the file level rather than having a global config here?
src/layouts/ReviewRequest/components/ApprovedModal/ApprovedModal.stories.tsx
Show resolved
Hide resolved
|
dismissing my review cos it's stale but the type errors above are due to a version mismatch between the versions of design system and chakra. we pinned design system to the path going forward (discussed offline w @harishv7) is to up design system version since we now satisfy peer deps but it means that we do have to resolve breaking changes ourselves |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But firstly, how and what are we using sourcemaps for? Source maps allows to map a transformed file back to the original source file. If you think that's valuable, sure let's enable it
Hmm correct me if I am wrong ya, but source maps are being used for debugging purposes as it allows us to step through code based on the source code rather than the source code right? May I also have context to the warnings? does it warn that the sourcemaps couldn't be generated?
What do you mean by "step through code based on the source code rather than the source code right"? Sourcemaps allow us to transform a file back into original source file for debugging purpose. Personally, I havent used it before, but I think let's keep it on for now. Btw, I have re-enabled the sourcemaps, somehow after a clean install the warnings are gone. will continue monitoring this |
Hey team, I am unable to resolve this weird error. I had to unroll my shift to yarn for now to continue development. If you guys know of a way to resolve this weird error let me know.
Technically we should not be using |
This reverts commit 67faf00.
6d66fb6
to
4886ad0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading to 1.x version seems non-trivial and should be tackled on a PR of its own. Example of errors we see with 1.2.0 is shown here:
oo got it, thanks for showing the examples as well
I understand that the nature of this PR will lead to having a lot of files changed. I am under the assumption that this PR took a pause to make sure e2e was in order before proceeding through the reviewal process again. Could I get your help to highlight key technical decisions made/non-trivial code changes that occurred from the time when eng took a pause from reviewing this to now so reviewers can focus specifically on code changes that has occurred since that pause?
* ref(e2e): test structure (#1298) * refactor(collaborators): shift out command to utils * chore(fixtures): shard out selectors * chore(navigation): add return type * refactor(collaborators): shift utils out into file * chore(sesion): add site * fix(navigation): fix url * feat(constants): add staging link * refactor(build): reset to commit hash * refactor(collaborators): shift commands out * chore(modal): make selector more selective * fix(collaborators): close modal * feat(cypress api): add function to create rr automatically * refactor(session): allow passing in site * feat(cypress): add api requests to be * refactor(collaborators): shift clean up * chore(session): remove await * feat(cypress api): add some api for rr * chore(fixutres): add selectors and constants * refactor(utils): shift stuff into utils * fix(session): make email based on type * chore(collab/build): update import, ignore console.log * fix(collab): ignore forbidden error * test(e2e): scaffold comments (#1304) * feat(comments): add comments api for cypress * feat(cypress utils): add more util commands * feat(session/dashboard): add const and chnage email based on type * test(comments): scaffold test spec * refactor(utils): add ignores * test(e2e): scaffold notif tests (#1305) * feat(notifications api): add new notif api * test(notifications spec): add e2e for notifs * docs(notif spec): update comment * chore(notifications): update import and naming * chore(const): add new char constants * chore(pages): add default length * chore(notif spec): add test case * feat(site launch): site dashboard stories (#1296) * chore(assets): add in assets * feat(storybook): add in site lunch storybook for dashboard * feat(siteLaunchService): allo storybook to be accessed * style(site launch context): use useParams to get sitename * style(siteLaunchService): add comments for clarity * feat(siteLaunchDashboardApi): return res.data * style(siteLaunchUtils): file structure * style(site launch dashboard): use flex * style(siteLaunchDashboard): remove redundant code * style(siteLaunchContext): remove redundant useEffect call * style(siteLaunchUtils): change the location of constants * style(siteDashboardStoryBook): cleaner storybook representation * style(siteDashboard): abstract out component * style(site launch): spelling * style(site launch context): change API contract * style(site launch): naming * style(site launch context): use useEffect instead * feat(site dashboard): use correct icon + words should not be squished * fix(display card): change padding * fix(display card): no extra padding from title to icon * style(siteLaunch): expose type as object first * style(sitedashboard): simpify api contract * test(e2e): scaffold dashboard tests (#1302) * test(dashboard.spec): add initial scaffold for dashboard chore(dashboard.spec): update imports chore(dashboard.spec): remove .only * chore(dashboard.spec): update desc * docs(cypress): add docs * fix(chromatic cicd): fix over-building chromatic (#1311) * fix(chromatic cicd): fix over-building chromatic * fix(chromatic.yml): check for output first * test(spec): shard out tests for rr (#1317) * Feat: Upgrade major deps and to Webpack 5 (#1202) * feat: update cypress to 12.8.0 * feat: add engines for node version * feat: upgrade lockfile * feat: upgrade chakra, sentry, design system, react, webpack * feat: use yarn * fix: remove old extends in eslint * feat: use webpack 5 config for cypress * feat: update eslint rule * chore: add cypress env to gitignore * chore: minor formatting on file * fix: error on missing props in story file * fix: enforce cookies to be string * fix: type error for unresolved var * feat: cypress utils resolution * fix: app tsconfig utils resolution * chore: add eslint plugin * fix: comment out component from stories * fix: update isFullWidth to use w for chakra 2 * feat: update react to use createRoot * fix: add path alias for cypress tsconfig * chore: upgrade chakra to latest * chore: upgrade to react 18.2.0 * chore: upgrade storybook * fix: use craco for jest tests * fix: storybook config for wp 5 * chore: upgrade storybook to latest * feat: update to use yarn * fix: refactor util functions to allow specific imports in Cypress * fix: disable sourcemap when building to avoid warnings * fix: add names for steps * fix: update ci-e2e to use yarn and latest packages * fix: update chromatic workflow * fix: allow ts-ignore in eslint * chore: ts-ignore implicit any * fix: cypress resolution for utils * fix: use export default in cypress config * chore: remove unused comment * chore: refactor file name from legacyUtils to fileNameUtils * chore: update craco, react-beautiful-dnd, eslint-plugin-react-hooks, react-test-renderer, remove babel-eslint * fix: use new babel parser for eslint * feat: upgrade to latest yarn version * chore: revert back to use npm * fix: npm build cmd in ci workflows * chore: update deps for storybook * chore: remove unneeded dependencies * chore: pin chakra ui to 2.2.1 due to design system * fix: uncomment story changes due to chakra mismatch * fix: adding back num tests config for cypress * chore: upgrade react mde editor * fix: classname for mde editor table icon * chore: recreate package-lock with new node version * fix: update actions versions in chromatic workflow * fix: pin chakra version * fix: storybook build * fix: run eslint fix * fix: warn for vars use before define rule * fix: warn for unused expression rule * fix: add react-hooks plugin for eslint * chore: run prettier eslint * fix: warn for camelcase rule * fix: update eslint config to use latest babel parser and fix lint errors * fix: update value to be optional prop * chore: remove yarn lock * fix: add typescript extensions for lint scripts * fix: lint fixes for import sorting * chore: run lint fix * fix: lint and build issues * fix: lint and build * feat: update h4 to h6 * feat: update h3 to h5 * feat: update h2 to h4 * fix: package-lock * fix: margin bottom for comments * fix: squished menu * fix: dropdown colors * fix: squished notification menu * dummy commit * Revert "dummy commit" This reverts commit 67faf00. * chore: update lock file * chore: ignore eslint warning * fix: imports for workspace e2e * chore: update package-lock * fix: remove yarn as package manager * fix: update nvmrc to use node 18 * fix: add netlify build script * fix: remove global eslint rule * revert: changes on EditContactUs * revert: changes on EditHomepage * revert: changes on cypress html * docs(setup): add docs for e2e setup (#1314) * feat: handle V2 errors for create and update pages (#1312) * feat: handle V2 errors for create and update pages * fix: handle axios error * feat: add error dto for v2 error * feat: update dto structure * fix(settings): use gh session defaults (#1321) * feat: set cookies with domain (#1320) * feat: set cookies with domain * feat: add optional cookie options * 0.32.0 --------- Co-authored-by: seaerchin <[email protected]> Co-authored-by: Kishore <[email protected]> Co-authored-by: Harish <[email protected]>
This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers |
Problem
This is a major PR that has some breaking changes. Currently, most of our dependencies are still using old versions. We are using outdated versions of key dependencies like Chakra UI, React, Design System and dev dependencies like Cypress.
Solution
This PR addresses the issue (#1196) by upgrading the dependencies. Along with this we will be upgrading to Webpack 5 which is required by the dependencies. Some of the key changes:
Node version used for testing & dev: 18.15.0
Breaking Changes
Features
Following on from the older PR,
Chakra Updates
Button, Icon Button, Input, NumberInput, Radio, Checkbox, Select# We removed the isFullWidth prop from these components. Use width="full" or width="100%" instead.
React Upgrades
createRoot
insteadyarn.lock
with the use of yarn as package managertest
command. Otherwise, all other commands will usereact-scripts
Visual Changes
Due to the upgrade of design system, the headings have been remapped.
Previous H6 are now h4
Previous H5 are now h3
Previous H4 are now h2
See the difference between these files to understand what has changed:
Storybook Updates
When running
npm run build-storybook
it outputs a weird error:ERR! ModuleNotFoundError: Module not found: Error: Can't resolve '@mdx-js/react' in '/.storybook/foundations/Colours'
There is a related issue for this: storybookjs/storybook#18094 which mentions some compatibility issues for storybook with react 18 version
I have performed some upgrades to overcome this and installed the missing deps as devDeps in package.json
Upgrade storybook with
npx storybook upgrade
https://storybook.js.org/docs/react/configure/upgrading
Cypress Changes
Cypress is working good with webpack 5 now. Some issues and how I overcame them:
When there are errors such as
cy.setSessionDefaults()
is not definedReference
Key Changes
For Cypress, I had to refactor the imports in the tests. Starting from Webpack 5,
process
,path
and other automatic polyfills were removed. Hence, we will encounterprocess is not defined
error if we import files using env variables for example.This is case, our spec files such as
editPage.spec.js
was import utils which in turn was importingapi.js
which in turn was usingprocess.env
to set some of the variables.This was not unnecessary for Cypress tests. In fact, there should be no reliance on
process.env
for e2e tests.Hence, I refactored all the required imports into a separate file called
legacyUtils.js
and then made more specific imports in our spec files to resolve this.Related Reading:
https://gist.github.com/ef4/d2cf5672a93cf241fd47c020b9b3066a
https://stackoverflow.com/questions/65018431/webpack-5-uncaught-referenceerror-process-is-not-defined
https://webpack.js.org/blog/2020-10-10-webpack-5-release/#changes-to-the-structure
Webpack Changes
Cypress Related
Inside cypress.config.ts, we use Webpack preprocessor 5 for Cypress to configure Webpack 5 compatibility.
Reference
Alias resolution for paths
https://webpack.js.org/configuration/resolve/
TypeScript Changes
Some TypeScript related changes were required for Cypress to work with Webpack. Check out the below issue and example for what worked.
Related reading: cypress-io/cypress#24185
CI Changes
With the move to yarn, I had to edit all the workflow yml files we have. I also took this opportunity to upgrade the actions package versions we are using. The CI on this PR is expected to fail due to the numerous lint/formatting errors. This has been fixed in the next PR (see below section)
Related PR
There were a lot of Eslint and Prettier errors. To facilitate review, I have done them on a separate branch and PR here: #1203
The above PR will be merged into this current branch and then we will finally merge everything into
identity-phase-2
.Tests
Before Testing
node_modules
folderyarn install
Tests to Run
Please run all tests including E2E tests to confirm everything is working fine.
npm run test
)!run e2e
)Deploy Notes
Make sure this is well tested on staging before deploying to production.