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

[MDX] Migration to gatsby-plugin-mdx v4 with fix for onCreatePage trigger issue #4585

Open
wants to merge 61 commits into
base: master
Choose a base branch
from

Conversation

randychilau
Copy link
Contributor

@randychilau randychilau commented Jul 20, 2023

Description

This PR is a second try migrating to gatsby-plugin-mdx v4 (and MDXv2) which fixes an issue discovered in the first try (PR #4532).

The issue was that mdx pages were being handled differently in v4 when the env variable CI is set to true activating customized onCreatePage and envCreatePage functions. CI=true is the default case for all Github Actions.

As a result, mdx sourced pages which used the children feature of v4 were triggering the customized onCreatePage function which is designed to handle non-mdx sourced pages. Adding a conditional check for path ending in .html resolves the issue.

before (taken from the checks in PR 4532):
image

redirect loop example at /programs/gsoc in netlify site preview.

after (taken from the checks in this PR):
image

no redirect loop example at /programs/gsoc in netlify site preview.


Notes for Reviewers

Added section to CONTRIBUTING.md file with reminders when working on gatsby-node.js and page creation/url/redirect.

🌺 Thanks for everyone's patience and quick action to report issues, revert the PR, and discuss possible solutions.

Signed commits

  • Yes, I signed my commits.

…4532-mdx2-upgrade"

This reverts commit 8362b4e, reversing
changes made to 4c2e586.

Signed-off-by: Randy Lau <[email protected]>
@github-actions github-actions bot added project/meshery area/news A noteworthy article, event, happening area/blog New posts or new blog functionality area/projects An issue relating to Layer5 initiatives (projects) area/community area/learn Related to /learn section area/events area/careers area/resources project/kanvas area/site-config labels Jul 20, 2023
@l5io
Copy link
Contributor

l5io commented Jul 20, 2023

🚀 Preview for commit d8e08ae at: https://64b8cdb5900f064ab12c3be6--layer5.netlify.app

@Nikhil-Ladha
Copy link
Contributor

Nikhil-Ladha commented Jul 20, 2023

Everything looks, actually good this time.
Godd catch!

@l5io
Copy link
Contributor

l5io commented Jul 21, 2023

🚀 Preview for commit b8ec8f5 at: https://64bac90b210ccf0508d788eb--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Jul 21, 2023

🚀 Preview for commit cb31caa at: https://64bad58a9338e10375d87a77--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Jul 21, 2023

🚀 Preview for commit e4c1b8f at: https://64baf5fbcf89bc03a5636f85--layer5.netlify.app

@Nikhil-Ladha
Copy link
Contributor

Please do discuss the PR on the Monday's website call if possible for you (time wise), and request for people to test out the preview. From, my side things look good and we can give this a go.

gatsby-config.js Outdated
@@ -72,7 +78,7 @@ module.exports = {
overrides: {
// or disable plugins
inlineStyles: false,
cleanupIDs: false,
cleanupIds: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am guessing this resolves the cleanupIds error that we are sseing during the build, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing. Yes, that is correct.


Possible reason why:

The original property value came from Gatsby's docs.
image

but then I believe the warning started appearing in build logs after this package upgrade:
Bump @svgr/webpack from 6.5.1 to 8.0.1 #4467

and then when looking at the SVGO github's plugin chart, the property value had different casing:
image

After correcting the config settings with the SVGO casing the warning did not appear anymore.

Cheers!

Copy link
Member

Choose a reason for hiding this comment

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

@randychilau @Nikhil-Ladha, we're still seeing these messages while building. cleanupIds is enabled by default as @randychilau pointed out. Do we know why it's necessary to disable this minification? At first blush, minification is ideal. Was having this enabled, corrupting some images?

Copy link
Member

Choose a reason for hiding this comment

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

We should find that this mis-capitalization is once again corrected and that the warning messages disappear - 329de49#diff-b5e305780d9d473da97c61beab8bc36e5e8871b360942e4686c9b20d8c5d4cfaR75

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @leecalcote,

regarding the question:

"Do we know why it's necessary to disable this minification? At first blush, minification is ideal. Was having this enabled, corrupting some images?"

The cleanupIds option is disabled to prevent conflicts of multiple SVGs on the same page:

Note: SVGO does not produce unique IDs when using the cleanupIDs option; if you’re using SVGs that rely on IDs (e.g. to target template elements with use) and include multiple SVGs on the same page you may wish to disable the cleanupIDs option to prevent conflicts. (src)

If I recall correctly, the Layer5 site required cleanupIds to be false so that pages with multiple SVGs could have a unique ID for each SVG that could be targeted for transitioning between light and dark mode.

Cheers,
Randy

@l5io
Copy link
Contributor

l5io commented Jul 22, 2023

🚀 Preview for commit c594161 at: https://64bc318dc252e0225e126f4e--layer5.netlify.app

@randychilau
Copy link
Contributor Author

randychilau commented Jul 24, 2023

Hi @Nikhil-Ladha,

We discussed this PR on today's Website's call, and asked the community to test the preview and I believe someone also built the branch without issues.

@leecalcote mentioned that this merge might be an issue for contributors who have experienced memory issues during the image-processing phase. Something I forgot to mention was that the memory issues were occurring during the Build HTML Renderering stage, and there were generally no issues during the image-processing stage. However every contributor's setup is different, and since I have not had issues with image-processing in the past, my build data points may be irrelevant.

Lee also mentioned potentially migrating to Gatsby 5 (which requires bump React 18 and includes a new webpack version) in this PR to see if the cold build time will come down.

So as of now I see a few options:

  1. merge this PR

    • accept the longer cold build time for now
    • listen for any memory build issues from community
    • create separate PR for migration to Gatsby 5
  2. add to this PR a Gatsby 5 migration

    • test to see build time reduces in Gatsby 5
    • re-evaluate whether or not to merge this PR
  3. hold this PR and create separate PR for migration to Gatsby 5 on the current site

    • after PR for Gatsby 5 migration is tested and merged, revisit this PR for testing

My initial thought is if the choice is between option 2 or 3, then 3 would be the way to go since a Gatsby 5 migration can be done independent of MDX related upgrades and has its own benefits for the site.

Happy to hear thoughts on the above and how to proceed.

Cheers,
Randy

@l5io
Copy link
Contributor

l5io commented Sep 5, 2023

🚀 Preview for commit 7eddcd5 at: https://64f6c9073e38135fb2118291--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Sep 5, 2023

🚀 Preview for commit 1e10f7a at: https://64f774de721d0f1471d942f0--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Sep 5, 2023

🚀 Preview for commit d4861ea at: https://64f77a7a28f3e016e67a88f9--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Sep 5, 2023

🚀 Preview for commit 3db1070 at: https://64f79759bfd6992f58637054--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Sep 5, 2023

🚀 Preview for commit d64cd34 at: https://64f7a158767e580074fd3467--layer5.netlify.app

@randychilau
Copy link
Contributor Author

Hi All,

Reviewed the latest updates/changes for compatibility with MDX v2, and added them to this PR.

This PR is waiting on the review and merging of PR #4646 (Gatsby v5). Afterwards, will merge those changes into this PR with the hope that migrating to Gatsby v5 (and new webpack) will address cold build times and memory requirements with MDX v2.

Thanks,
Randy

@l5io
Copy link
Contributor

l5io commented Sep 11, 2023

🚀 Preview for commit 6245012 at: https://64ff5ed6ecfe833e585869b2--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Sep 20, 2023

🚀 Preview for commit 228a0e4 at: https://650b43fdbb800d32b676c3a6--layer5.netlify.app

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the issue/stale Issue has not had any activity for an extended period of time label Mar 17, 2024
@stale stale bot removed the issue/stale Issue has not had any activity for an extended period of time label Jul 16, 2024
@vishalvivekm
Copy link
Member

@Aviral0702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/blog New posts or new blog functionality area/careers area/ci area/community area/events area/learn Related to /learn section area/news A noteworthy article, event, happening area/projects An issue relating to Layer5 initiatives (projects) area/resources area/site-config issue/willfix project/kanvas project/meshery
Development

Successfully merging this pull request may close these issues.

7 participants