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

New release v11.0.0 (Update v9.0.0 from upstream aka FTW-hourly) #199

Merged
merged 132 commits into from
Jul 11, 2022

Conversation

Gnito
Copy link
Collaborator

@Gnito Gnito commented Jul 11, 2022

NOTE: THIS IS GOING TO CAUSE A MAJOR VERSION CHANGE TO TEMPLATES.

This PR updates sharetribe-scripts to the next major version.

sharetribe-scripts is a fork of Create React App (CRA) repository and specifically react-scripts is modified to support server-side rendering, code-splitting, and certain PostCSS plugins that we chose to include years ago. (E.g. introduced CSS Modules before CRA took the same approach.)

This update is actually an update from CRA 4.0.2 to v5.0.1

The breaking changes are in v5.0.0

Highlights from CRA update:

Note: we haven't explored Tailwind support since it would mean a complete rewrite for the FTW templates. In addition, CSS Modules make it easier for customizers to learn a big codebase like FTW (i.e. which component is responsible for a different sections of DOM, etc.).


Consequences

Major updates to Webpack (v4 > v5) and PostCSS (v7 > v8), were the most worksome for FTW templates.

  • The upper restriction of Node.js engine "version earlier than v17" has been lifted!

  • Loadable components was updated

    • FTW and other client apps should update their part of Loadable components too
      • "@loadable/component": "^5.15.2",
      • "@loadable/server": "^5.15.2",
  • You should add @importfor customMediaQueries.css file.

    • E.g. @import '../../styles/customMediaQueries.css';
    • Some parallelism has increased in the build process and postcss-import wasn't included without it being explicitly mentioned per CSS file.
  • src/index.js was refactored.

    • We rearranged the module imports
      • marketplaceDefaults.css was introduced first before any of the components were imported.
      • This ensures that the content of marketplaceDefaults.css is first in the built CSS file (main chunk).
        (The order of classes in CSS files affects declaration overrides.)
  • postcss-apply plugin is not working anymore

    • It's been deprecated for a long time because W3C decided to not go forward with that feature suggestion

    • You should migrate away from postcss-apply syntax (aka CSS Property Sets)

      • Most of the code changes in this PR are about migrating away from CSS Property Sets
    • However, we have introduced a naive custom version of postcss-apply as a private plugin to give more time to migrate away.

      Most of the previous CSS Property Sets are turned into CSS classes in the marketplaceDefaults.css file.
      So, most of the time the change is minimal:

      .author {
        @apply --marketplaceH4FontStyles;
      }
      
      .author {
        composes: h4 from global;
      }
      

      Unfortunately, there's one problem that doesn't make it that straightforward. The order of the plain CSS classes in the marketplaceDefaults.css file defines which classes override each other. (The composes feature just includes those class names to DOM element - not their content.) Therefore, if multiple @apply rules are used inside the CSS module class, you need to check if there are overwrites between declarations of those Sets.

      Button styling included almost always some overrides. We decided to split buttons styles into smaller chunks that can be combined:

      .buttonLink {
        @apply --marketplaceButtonStyles;
      }
      .buttonLinkPrimary {
        @apply --marketplaceButtonStylesPrimary;
      }
      
      .buttonLinkSecondary {
        @apply --marketplaceButtonStylesSecondary;
      }
      
      

      New syntax:

      .buttonLink {
        composes: button buttonFont buttonText buttonBorders buttonColors from global;
      }
      .buttonLinkPrimary {
        composes: button buttonFont buttonText buttonBorders buttonColorsPrimary from global;
      }
      
      .buttonLinkSecondary {
        composes: button buttonFont buttonText buttonBordersSecondary buttonColorsSecondary from global;
      }
      

      This might be a bit controversial, but it introduces fewer CSS overrides. Of course, you are free to customize this to your liking.


Potential issues that you might encounter if taking an update from upstream

NOTE: You may need to delete your node_modules folder and reinstall your dependencies by running npm install (or yarn) if you encounter errors after upgrading.

Old version of @babel/runtime

Module not found: Error: Can't resolve './defineProperty' in '/Users/vesaluusua/st/ftw-daily/node_modules/redux/node_modules/@babel/runtime/helpers/esm'
Did you mean 'defineProperty.js'?

Redux has sub-dependency to @babel/runtime. An old version of that package doesn't handle ES Modules well. You might need to call yarn upgrade redux after yarn install to update Redux sub dependencies to the latest in yarn.lock file.
reduxjs/redux#4174

customMediaQueries.css was not @imported in the file that uses them

You should be able to find correct files by grepping files that don't contain "customMediaQueries" but which contain "--viewport".

In OSX, that could be done in Terminal with:

grep -r --include \*.module.css -L customMediaQueries ./src | xargs grep -l '\-\-viewport'

Missing propertySets.css file and your custom CSS Property Sets

You should consider if you want to refactor your custom @apply rules (i.e. migrate away as recommended) or reintroduce / revert the deletion of the propertySets.css file.

Some changes related to naming:

  • button styles as described before.

  • --marketplaceLinkStyles > .a

  • --marketplaceH1FontStyles > .h1

  • --marketplaceH2FontStyles > .h2

  • --marketplaceH3FontStyles > .h3

  • --marketplaceH4FontStyles > .h4

  • --marketplaceH5FontStyles > .h5

  • --marketplaceH6FontStyles > .h6

  • marketplaceTabNavFontStyles was inlined for FTW-daily

  • marketplaceTabNavHorizontalFontStyles was inlined for FTW-daily

Wrong syntax for CSS Property Sets (postcss-apply)

Some of the definitions of CSS Property Sets in the FTW codebase used a wrong syntax to define them. The previous way how PostCSS v7 parsed CSS files to the AST (Abstract Syntax Tree) didn't care about that, but PostCSS v8 changed the parsing logic.

🚫 Invalid:

--marketplaceModalTitleStyles {
  font-size: 30px;
}

✅ Valid:

--marketplaceModalTitleStyles: {
  font-size: 30px;
}

You should only face this issue if you continue to use CSS Property Sets. However, you should consider them as deprecated and migrate away.

There are a couple of warnings with yarn run dev

[0] (node:58738) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
[0] (Use `node --trace-deprecation ...` to show where the warning was created)
[0] (node:58738) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.

This is hopefully fixed in the next release:
facebook/create-react-app#11862

Gnito and others added 30 commits May 19, 2022 16:03
Fix undefined REACT_APP_GOOGLE_ANALYTICS_ID
Bumps [eventsource](https://github.com/EventSource/eventsource) from 1.0.7 to 1.1.1.
- [Release notes](https://github.com/EventSource/eventsource/releases)
- [Changelog](https://github.com/EventSource/eventsource/blob/master/HISTORY.md)
- [Commits](EventSource/eventsource@v1.0.7...v1.1.1)

---
updated-dependencies:
- dependency-name: eventsource
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
…tsource-1.1.1

Bump eventsource from 1.0.7 to 1.1.1
Note: FTW-product already uses this library on ListingPage.
- h4, clearfix, marketplaceMessageFontStyles
- used h4, h5, buttonFont, and marketplaceTinyFontStyles
- --marketplaceSmallFontStyles was only used here. It's now renamed as smallFontStyles.
- Uses marketplaceModalInMobileBaseStyles
- And h2, h4, h5, and marketplacetineyFontStyles.
- Button styles are also used for bookButton
- a, button styling classes
- Button: composes: button buttonFont buttonText buttonBorders buttonColors from global;
- PrimaryButton: composes: button buttonFont buttonText buttonBorders buttonColorsPrimary from global;
- SecondaryButton: composes: button buttonFont buttonText buttonBordersSecondary buttonColorsSecondary from global;
- marketplaceModalTitleStyles
- marketplaceModalParagraphStyles
- marketplaceModalTitleStyles
- marketplaceModalParagraphStyles
Gnito and others added 23 commits July 7, 2022 16:52
- h4, h5, a, marketplaceSearchFilterSublabelFontStyles, marketplaceModalPasswordMargins,
  marketplaceModalHelperText, marketplaceModalHelperLink, marketplaceModalCloseIcon
- h4, h5, marketplaceSearchFilterSublabelFontStyles
- h4,h5, marketplaceDefaultFontStyles
- marketplaceModalFormRootStyles, marketplaceModalPasswordMargins, marketplaceModalBottomWrapper,
  marketplaceModalBottomWrapperText, marketplaceModalHelperText, marketplaceModalHelperLink
- h3, marketplaceModalPasswordMargin, marketplaceModalHelperText, marketplaceModalHleperLink
- inlined h4 styles due to exposed element (p)
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.3 to 4.21.1.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](browserslist/browserslist@4.16.3...4.21.1)

---
updated-dependencies:
- dependency-name: browserslist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [moment](https://github.com/moment/moment) from 2.29.3 to 2.29.4.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](moment/moment@2.29.3...2.29.4)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](chalk/ansi-regex@v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
…alize-url-4.5.1

Bump normalize-url from 4.5.0 to 4.5.1
…-regex-4.1.1

Bump ansi-regex from 4.1.0 to 4.1.1
…serslist-4.21.1

Bump browserslist from 4.16.3 to 4.21.1
@Gnito Gnito temporarily deployed to ftw-hourly July 11, 2022 13:42 Inactive
@Gnito Gnito force-pushed the update-v9.0.0-from-upstream branch from e83cd52 to 8831b49 Compare July 11, 2022 13:43
@Gnito Gnito changed the title Update v9.0.0 from upstream New release v11.0.0 (Update v9.0.0 from upstream aka FTW-hourly) Jul 11, 2022
@Gnito Gnito force-pushed the update-v9.0.0-from-upstream branch from 8831b49 to fc832a4 Compare July 11, 2022 13:53
@Gnito Gnito merged commit 0686a1a into master Jul 11, 2022
@Gnito Gnito deleted the update-v9.0.0-from-upstream branch July 11, 2022 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant