Skip to content
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

fix: order imports and remove circular dependencies #41824

Merged
merged 8 commits into from
Aug 2, 2021

Conversation

ojeytonwilliams
Copy link
Contributor

@ojeytonwilliams ojeytonwilliams commented Apr 14, 2021

The goal here was just to simplify the linting/formatting and order the the imports so that webpack would know how to order the css imports. This has worked, but we should audit the css, since the declaration order has probably changed.

However, reordering the imports showed that several modules had circular dependencies since they broke when the order changed. To fix this I separated out the offending code (types for actions) to flatten out the dependencies.

This did not fix redux/settings however, since there was a missing type, updateUserFlagComplete. I don't know how everything functioned without it, but I created it anyway.

@github-actions github-actions bot added platform: api Server application that needs familiarity with Express, Loopback, MongoDB etc. platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: i18n language translation/internationalization. Often combined with language type label scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. labels Apr 14, 2021
@ojeytonwilliams ojeytonwilliams force-pushed the chore/simplify-prettier branch from 7cf87c1 to 25e2612 Compare April 14, 2021 17:08
@ahmaxed
Copy link
Member

ahmaxed commented Apr 16, 2021

I didn't notice any inconsistencies in the UI. I am still investigating the action.

@ahmaxed
Copy link
Member

ahmaxed commented Apr 17, 2021

So when you create an asyc type, the complete and error versions get created automatically.

export const createAsyncTypes = action => [
`${action}`,
`${action}Complete`,
`${action}Error`
];

@ojeytonwilliams
Copy link
Contributor Author

That's interesting, thanks Ahmad. It explains why it wasn't completely broken! I will need to look into why the tests started failing, though.

@ojeytonwilliams
Copy link
Contributor Author

ojeytonwilliams commented Apr 22, 2021

@ahmadabdolsaheb mystery solved. You were spot on - there was no need to add updateUserFlagComplete. The reason the test was failing was another circular dependency issue: settingsTypes was undefined.

With that in mind, I think (short of introducing bugs) the only change this might have introduced is to the CSS. And that should be limited to the challenge pages.

@gitpod-io
Copy link

gitpod-io bot commented Apr 22, 2021

@ojeytonwilliams ojeytonwilliams marked this pull request as ready for review April 22, 2021 17:45
@ojeytonwilliams ojeytonwilliams requested a review from a team as a code owner April 22, 2021 17:45
@raisedadead raisedadead added the status: merge conflict To be applied to PR's that have a merge conflict and need updating label Apr 26, 2021
@raisedadead
Copy link
Member

Do we want to give this one more go?

@ojeytonwilliams
Copy link
Contributor Author

Sure. I'll take a stab at it tomorrow.

We might need a small freeze, though.

@raisedadead
Copy link
Member

Sure.

redux depended on templates/Challenges/redux and vice versa.  This
meant that import order mattered and confusing bugs could arise.

(cherry picked from commit 7d67a4e)
Import order generally does not matter, but there are edge cases
(circular  imports and css imports, for example) where changing order
changes behaviour

(cherry picked from commit b8d1393)
This brings the classic Show closer to the others as they
now all create the description and title components
@ojeytonwilliams ojeytonwilliams force-pushed the chore/simplify-prettier branch from 7dc4ad5 to 6c68517 Compare July 30, 2021 13:43
@gitpod-io
Copy link

gitpod-io bot commented Jul 30, 2021

@ojeytonwilliams ojeytonwilliams changed the title fix: order imports fix: order imports and remove circular dependencies Jul 30, 2021
@ojeytonwilliams ojeytonwilliams removed the status: merge conflict To be applied to PR's that have a merge conflict and need updating label Jul 30, 2021
@ojeytonwilliams
Copy link
Contributor Author

@raisedadead I removed the prettier changes and brought everything up-to-date. Ironically, ordering the inputs was not enough to get rid of these warnings:

chunk commons [mini-css-extract-plugin]
Conflicting order. Following module has been added:
 * css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[1]!./node_modules/gatsby-plugin-postcss/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[2]!./src/t
emplates/Challenges/components/test-suite.css
despite it was not able to fulfill desired ordering with these modules:
 * css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[1]!./node_modules/gatsby-plugin-postcss/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[2]!./src/t
emplates/Challenges/components/challenge-description.css
   - couldn't fulfill desired order of chunk group(s) component---src-templates-challenges-projects-backend-show-tsx
   - while fulfilling desired order of chunk group(s) component---src-templates-challenges-classic-show-tsx
 * css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[1]!./node_modules/gatsby-plugin-postcss/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[2]!./node_
modules/prismjs/themes/prism.css
   - couldn't fulfill desired order of chunk group(s) component---src-templates-challenges-projects-backend-show-tsx
   - while fulfilling desired order of chunk group(s) component---src-templates-challenges-classic-show-tsx
 * css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[1]!./node_modules/gatsby-plugin-postcss/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[9].oneOf[1].use[2]!./node_
modules/prismjs/plugins/line-numbers/prism-line-numbers.css
   - couldn't fulfill desired order of chunk group(s) component---src-templates-challenges-projects-backend-show-tsx
   - while fulfilling desired order of chunk group(s) component---src-templates-challenges-classic-show-tsx

because of nested imports. That's why I changed classic/Show.tsx slightly, so that it's closer to the other Show.tsxs as far as imports are concerned.

@naomi-lgbt
Copy link
Member

There's a lot less noise when I run the development build now, but I do get this:

image

naomi-lgbt
naomi-lgbt previously approved these changes Jul 30, 2021
Copy link
Member

@naomi-lgbt naomi-lgbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite that warning, everything seems to look good locally. 🙂

@ojeytonwilliams
Copy link
Contributor Author

Huh. It's weird that we don't have that rule. Let me see about adding that and fixing the issue.

Copy link
Member

@naomi-lgbt naomi-lgbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All better!

I still get this one, but I think this is actual babel and not us.
image

@ojeytonwilliams
Copy link
Contributor Author

It's been around for a while, I think, https://github.com/freeCodeCamp/freeCodeCamp/runs/3204052148?check_suite_focus=true#step:9:221 and doesn't seem to be breaking anything

Copy link
Member

@ahmaxed ahmaxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than what Nick said, LGMT.

Copy link
Member

@moT01 moT01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I looked this over and tested it pretty thoroughly - didn't find any issue. LGTM 👍

@moT01 moT01 merged commit e118dda into freeCodeCamp:main Aug 2, 2021
@ojeytonwilliams ojeytonwilliams deleted the chore/simplify-prettier branch August 2, 2021 13:48
ShaunSHamilton pushed a commit that referenced this pull request Aug 5, 2021
* rename to TS

* update import

* migrate with-instant-search

* change falsy values to empty string

* update import order

Finish resolving conflict from #41824

* update import order for search-bar

* update setTimeout() type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: api Server application that needs familiarity with Express, Loopback, MongoDB etc. platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: i18n language translation/internationalization. Often combined with language type label scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants