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

[docs] generate code paths for webpack raw-loader efficiency #27301

Merged
merged 6 commits into from
Jan 23, 2025

Conversation

cmpadden
Copy link
Contributor

@cmpadden cmpadden commented Jan 23, 2025

Summary & Motivation

Edit looks like the regex is missing one of the entries as indicated by the failed Vercel build. Will look into this tomorrow.

Error: Can't render static file for pathname "/guides/build/partitions-and-backfills/defining-dependencies-between-partitioned-assets"

raw-loader was previously scanning the entire examples/ folder, and leaving many artifacts. Resulting in excessive memory usage (see memory snapshot).

image

This introduces a build step to create a mapping of CodeExample paths to their corresponding import, see improved memory snapshot.

image

@salazarm we discussed this offline at some point, but would definitely appreciate your input on how this can be improved. Right off the bat, I'm not sure if the regex works for components that span multiple lines. Also want to get your input on if the server conditional logic is required. It seems to work with out it.

How I Tested These Changes

Changelog

Insert changelog entry or delete this section.

@cmpadden cmpadden requested a review from salazarm January 23, 2025 04:23
@cmpadden cmpadden force-pushed the colton/generate-code-example-imports branch from 0914350 to f10acb4 Compare January 23, 2025 14:57
@cmpadden cmpadden marked this pull request as ready for review January 23, 2025 15:37
@cmpadden cmpadden requested a review from neverett as a code owner January 23, 2025 15:37
@@ -5,7 +5,7 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start -p 3050",
"build": "docusaurus build",
"build": "yarn generate-code-imports && docusaurus build",
Copy link
Contributor

Choose a reason for hiding this comment

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

do we also need to generate code imports before running yarn start ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I can add it there too! was a little worried about performance impact, but it would be a much better user experience.

Copy link
Contributor

@salazarm salazarm left a comment

Choose a reason for hiding this comment

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

lgtm, could get better bundling by generating individual components for each example but I think this is a good trade off of complexity and making a big improvement. Also 2Mb for strings aint that much and reducing it to 1kb wont yield THAT much improvement.

@cmpadden
Copy link
Contributor Author

lgtm, could get better bundling by generating individual components for each example but I think this is a good trade off of complexity and making a big improvement. Also 2Mb for strings aint that much and reducing it to 1kb wont yield THAT much improvement.

Thanks for all the help Marco! 🙏

@cmpadden cmpadden merged commit b20994d into master Jan 23, 2025
5 of 6 checks passed
@cmpadden cmpadden deleted the colton/generate-code-example-imports branch January 23, 2025 15:41
//if (isServer) {
// const module = CODE_EXAMPLE_PATH_MAPPINGS[path];
// processModule({cacheKey, module, lineStart, lineEnd, startAfter, endBefore});
//}

if (!contentCache[cacheKey]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that docusaurus supports Suspense on the server!

Copy link
Contributor

Choose a reason for hiding this comment

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

(the fact that we didn't need the isServer logic).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

heck yeah! 🤯

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should've probably removed that comment, whoops. Can do that in the future.

@cmpadden cmpadden changed the title [docs] wip - generate code paths for webpack raw-loader efficiency [docs] generate code paths for webpack raw-loader efficiency Jan 23, 2025
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.

2 participants