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

Improve docs dev server performance #1297

Merged
merged 4 commits into from
Feb 8, 2025
Merged

Conversation

fuma-nama
Copy link
Contributor

What's Done

  • Migrate to Tailwind CSS v4 so we can use the latest Fumadocs features (v15)
    • Config migrated, the current config is pretty minimal so it should be working fine
  • Enable Fumadocs async mode
    • Async mode compiles content on-demand, hence imports are not allowed, we moved them to page.tsx and pass down via MDX components
    • Improved next-themes configuration, disable it entirely and always use dark mode

@fuma-nama
Copy link
Contributor Author

fuma-nama commented Feb 7, 2025

Hmm weird that .source/ is already excluded from eslint, still getting warnings from that

@fuma-nama
Copy link
Contributor Author

should be working now

Tab,
SyntaxTabs,
SyntaxTab,
...(await import("../../../components/AutoplayDemo.tsx")),
Copy link
Member

Choose a reason for hiding this comment

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

Oof. In the future do you think there will be some way to do this that's less fragile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about Organise everything to a single mdx.tsx file and we export all MDX components there

Copy link
Member

Choose a reason for hiding this comment

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

That part doesn't matter to me a ton. I guess what I'm hoping for eventually would be when I create a new component, it would be automatically available.

Could add some kind of file watcher or something and try to handle it, but for now this is fine as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if you're using the approach mentioned above, MDX components are automatically available once you exported them

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if eventually there would be some way to hook into Next's file watching process or something and handles those exports in the background in .source.

For now this is fine though, excited to give it a shot!

Copy link
Contributor Author

@fuma-nama fuma-nama Feb 8, 2025

Choose a reason for hiding this comment

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

Yep that's great.

The experience you're looking for feels like Nuxt.js's components folder? I think that's possible by auto-generating an index.ts file to auto re-export all files in the directory

Copy link
Member

Choose a reason for hiding this comment

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

Yeah exactly. I haven't messed around much with full-stack frameworks but that sounds like what I was hoping for.

Not sure if you noticed but I actually hackily implemented something kind of similar to generate TS snippets: https://github.com/arktypeio/arktype/blob/main/ark/docs/lib/writeSnippetsEntrypoint.ts

Copy link
Member

@ssalbdivad ssalbdivad left a comment

Choose a reason for hiding this comment

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

Thanks so much for taking the time to do this upgrade! I had no idea about the imports in Page.

Still feels a bit janky to enumerate all those, but it's nice they're not needed in MDX I suppose. Also of course anything that improves the perf would be very welcome 😊

Just wanted feedback on a couple small things and will be good to merge!

enableSystem: false,
defaultTheme: "dark"
enabled: false,
enableSystem: false
Copy link
Member

Choose a reason for hiding this comment

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

Will this still be dark by default? I don't have light colors configured so the goal here was to make sure they wouldn't render.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The exact purpose here is to disable next-themes and ensure it's always dark mode

@@ -3,10 +3,6 @@ title: Announcing ArkType 2.0
description: 100x faster validation with DX that will blow your mind
---

import { MainAutoplayDemo } from "../../../components/AutoplayDemo.tsx"
Copy link
Member

Choose a reason for hiding this comment

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

Okay so essentially because we list these imports in page.tsx, the names are available by default and don't have to be imported anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@ssalbdivad ssalbdivad merged commit dd0b097 into arktypeio:main Feb 8, 2025
6 checks passed
ssalbdivad pushed a commit that referenced this pull request Feb 8, 2025
@ssalbdivad
Copy link
Member

image

This was a huge improvement 😍 Still hoping for some optimizations from NextJS, but this makes loading the docs (previously 30-40 seconds) much more bearable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done (merged or closed)
Development

Successfully merging this pull request may close these issues.

2 participants