-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 (requires migration to MDX v2) #4532
Conversation
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
Signed-off-by: Randy Lau <randychilau@gmail.com>
🚀 Preview for commit 697d013 at: https://64b77eab68eede4ef5ccdc34--layer5.netlify.app |
Hi @Nikhil-Ladha, Thanks for the kind words. Sounds good, I updated the CONTRIBUTING.md doc with info on the build times in "How to Contributes" section and added guidelines about image filesize & dimensions, feel free to review/edit. I recently found that any component used for shortcodes in mdx files were added to the general For example, the following data is for the home page: notes:
Regarding the upgrade migration to Gatsby v5, I am interested in helping with this if that is the desired direction. I noticed you were responsible for upgrading the site to Gatsby v4. Do you have any advice for going through this process? Lastly, thanks for taking the time overseeing and reading through this verbose PR. Cheers, |
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.
Looking great, let's merge this and let things settle in.
Yeah, I am aware of this. Though, just to confirm did you cross-check if we were importing a component in an incorrect way that is leading to this, or that's just how Gatsby is? I think it's the latter, but WDYT?
I can feel the same too, we might need some optimization throughout the code base in how we are using GraphQL as well.
Well, thanks to Gatsby documentation it makes the process much smoother. Just follow the migration guide, there might be some hiccups due to some extra plugins that we use, but we should be able to get around it some way or the other. Let me know, if something doesn't pan out, we can connect and discuss futher on that.
You're welcome :)
|
Hi @Nikhil-Ladha, As you can see, things did not go as planned, and turned into one of my biggest worries as an aspiring developer. Thankfully it was reverted relatively quickly. What I neglected to consider was that anything involving page creation needs another layer of testing with the Another misstep was that I should have taken a look at the build logs and tested the netlify site preview, instead of simply trusting the checks passing and my experience with the local production builds. Then I would have:
I think what is happening with the gatsby-plugin-mdx v4 when
The mdx source pages are being created by the same gatsby-node.js so it should not trigger onCreatePage, but perhaps the plugin is doing something different now (it only does this when using To handle this trigger in onCreatePage, a conditional check is done to see if the path ends in Is there a GitHub Page testing environment that can be used for PRs that involve page creation as a double check before going to live production? Anyway, hopefully that fix will resolve it and things can move forward. Cheers, |
A big miss from my end too, should have cross checked the preview :/ |
Regarding the testing env, we created a testing repo long back, probably you can use that. |
Hi @Nikhil-Ladha, The testing repo looks very interesting, a few questions:
I think this would be very useful for changes to gatsby-node.js involving page creation/redirects/urls. Thanks, |
The site is already configured to build from Github pages, so once I merge your PR in the repo you should be able to see the same on the hosted site. |
Ah, geez. I was to help, but time got away from me. Did we end up getting @randychilau's PR/commits reopened? Is that what this PR is? |
Maybe it's evident or has already been discussed, but outside of local builds, deployment previews are build each time that a PR is opened and each time that a new commit is pushed to an open PR. |
We are talking about the configuration available in the laye5labs/layer5 repo, a secondary source to test out the site changes using Gtihub pages. |
Oh! Gotcha. Great suggestion, particularly, since @Nikhil-Ladha is quite adept at X-Robots-Tag: noindex. 😄 |
Haha, I see that 🌚 |
@leecalcote No problem, I appreciated the quick response and offer to help. Thanks to a blog post on git reverting reverts, I was able to get another PR set up (#4585) for review. Regarding previews, I thought for PRs that specifically interact with the trailing slash customizations for GitHub pages, an option to test a preview served by GitHub Pages may be useful (since the current site previews in GitHub Actions are served by Netlify). @Nikhil-Ladha When you can, please merge the PR to the testing repo to see it in action. I can also update the CONTRIBUTING.md "Developer Notes" section with some language about this repo being available for additional testing of certain PRs and asking a maintainer for additional assistance/more information. Thanks! |
Sure, some more changes are required in the repo before the testing because of the repo confiuration like adding a
I would let it be a secret, and only grant access to special scenarios :)
|
@Nikhil-Ladha Sure, please grant me merge permissions and I can try testing it out myself (at least if I start a 🔥 on this site, it won't required emergency assistance 🚒 🧯). Thanks for taking the time! |
Cool, sent you the invite. |
Description
This PR is a migration to gatsby-plugin-mdx v4 (which requires migration to MDX v2)
Motivation: To resolve an issue of imports used in MDX files being added to the app bundle for every page
Unnecessary files in the app bundle adds to the page weight and can potentially cause slower performance and longer loading times, especially on mobile.
Gatsby resolves this issue in gatsby-plugin-mdx v4:
Layer5 example
before:
this file src/collections/programs/sca-contributhon/index.mdx imports the image
sca.svg
import {ReactComponent as ScaLogo} from "./sca.svg";
when you view the treemap from a recent lighthouse report for the
/about
page:sca.svg
is included even though it is not displayed on the/about
page.collection
, much of which shoul not be included in the bundle, is over 300KUnused Bytes
which is approx 350kbafter:
collection
is significantly reduced and less than 25KUnused Bytes
is approx. 200kb which is over 40% less.Notes for Reviewers
IMPORTANT:
This PR is stable for creating
production
builds,but forUpdate: Development build is stable, but requires more memory to run.development
builds, it is only stable when including a limited number of mdx files (usingignore
option ingatsby-source-filesystem
, otherwise there is a significant memory issue in Gatsby v4.This memory issue in
development
may be resolved in Gatsby v5 with an upgraded webpack. However as long as we are using Gatsby v4, it is not possible to get support/feedback from Gatsby Dev team on this issue.While there are benefits to migrating to MDX v2, the time and conditions required for
production
anddevelopment
builds in Gatsby v4 may be too costly to justify migration.Please note there are multiple aspects of this PR that can be made into separate PRs which do not require upgrading to
gatsby-plugin-mdx v4
ormdx v2
and merged with the current site, for example:ignore
option ingatsby-source-filesystem
to make local dev and production builds faster, as suggested here.(please let me know if the above is a desired action)
If the decision is to archive/close this PR until the site migrates to Gatsby 5 (and React 18) and wants to move to MDXv2, then I suggest adding a comment to the gatsby-config.js file in the "gatsby-plugin-mdx" section about this PR for reference and possible future merging.
A OOM memory issue during production builds was resolved using this github comment/workaround in the gatsby-ssr.js file.
A memory issue in the development build was worked around ~~by using github comments on limiting the number of mdx files included ~~(and possibly using
gatsby-plugin-no-sourcemaps
. Update: reducing the file size of pages built from mdx files helped work around memory issue.These memory issues may be resolved by migrating to Gatsby v5 because it uses an upgraded version of webpack.
Signed commits