-
Notifications
You must be signed in to change notification settings - Fork 82
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
Update to Docusaurus 3.6 #294
base: main
Are you sure you want to change the base?
Update to Docusaurus 3.6 #294
Conversation
✅ Deploy Preview for docusaurus-openapi ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
}, | ||
}, | ||
].filter(Boolean), | ||
use: [getJSLoader({ isServer }), mdxLoaderItem].filter(Boolean), |
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.
Hey
This is not really a public API (for now) 😅 , I may refactor this on a minor version.
I'm not sure what was the error in the first place since the author didn't share the full stacktrace, and how this fixes it 🤔
Note: with Docusaurus v3 you don't need to put a js loader in front of MDX anymore, the output of MDX is already in a form your bundler can understand unless you do anything fancy in MDX docs.
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.
I'm not sure what was the error in the first place since the author didn't share the full stacktrace, and how this fixes it
In terms of the original error, this PR was opened to address #293
Here's an example stacktrace:
Module build failed (from ./node_modules/@docusaurus/mdx-loader/lib/index.js):
TypeError: The "from" argument must be of type string. Received undefined
at validateString (node:internal/validators:162:11)
at Object.relative (node:path:1194:5)
at aliasedSitePath (/home/chris/dev/my-website/node_modules/@docusaurus/utils/lib/pathUtils.js:85:51)
at loadMDX (/home/chris/dev/my-website/node_modules/@docusaurus/mdx-loader/lib/loader.js:62:77)
at async Object.mdxLoader (/home/chris/dev/my-website/node_modules/@docusaurus/mdx-loader/lib/loader.js:156:24)
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.
The original error happened because the OpenAPI plugin wasn't passing the siteDir
option to mdx-loader
. Apparently that wasn't being used before Docusaurus 3.6 so the plugin still worked, but now it's actually being used.
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.
I've updated the PR to no longer use createMDXLoaderItem
.
Note: with Docusaurus v3 you don't need to put a js loader in front of MDX anymore, the output of MDX is already in a form your bundler can understand unless you do anything fancy in MDX docs.
Thanks for the tip! I've removed the extra JS loader. 👍
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.
Hmmm I see thanks.
siteDir
is a required loader option before v3.6, but maybe it wasn't failing before. Unfortunately since you don't use the types you didn't know your code didn't typecheck.
I think it could actually be better if you use createMDXLoaderItem
to ensure that no attribute is missing if we add more of them in the future. Unfortunately we can't guarantee this won't happen in a minor version 😅
I think in the future we'll provide some kind of public API provided by the plugin lifecycle such as getMDXLoader()
, similar to what you already used with getJSLoader
.
If we introduce this new API, we may still keep createMDXLoaderItem()
so it should be fine to use it. You already use non-public APIs anyway 😅
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.
You're right, we weren't using the proper types. Woops! 😅
I've added satisfies MDXLoaderOptions
to the options
object, so these kinds of errors can be caught more quickly in the future. Then createMDXLoaderItem()
can still be non-public API for now. 👍
194a6f2
to
7f3af13
Compare
Docusaurus 3.6 introduced some changes which broke the OpenAPI plugin (see #293). This PR fixes that issue,
by using the newby adding the missingcreateMDXLoaderItem
API to create the rule for@docusaurus/mdx-loader
(see facebook/docusaurus#10450)siteDir
property to themdx-loader
options.This PR also adds support for Docusaurus Faster (facebook/docusaurus#10556).
Fixes #293