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

Update to Docusaurus 3.6 #294

Merged
merged 7 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions demo/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const config = {
},
},

future: {
experimental_faster: true,
},

presets: [
[
"docusaurus-preset-openapi",
Expand Down
3 changes: 2 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "^3.2.0",
"@docusaurus/core": "^3.6.0",
"@docusaurus/faster": "^3.6.0",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-preset-openapi": "^0.7.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-docusaurus-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"license": "MIT",
"dependencies": {
"@docusaurus/logger": "^3.2.0",
"@docusaurus/logger": "^3.6.0",
"commander": "^5.1.0",
"fs-extra": "^11.0.0",
"lodash": "^4.17.20",
Expand Down
16 changes: 8 additions & 8 deletions packages/docusaurus-plugin-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.2.0",
"@docusaurus/types": "^3.2.0",
"@docusaurus/module-type-aliases": "^3.6.0",
"@docusaurus/types": "^3.6.0",
"@types/js-yaml": "^4.0.5",
"@types/json-schema": "^7.0.9",
"@types/lodash": "^4.14.176",
"@types/postman-collection": "^3.5.3",
"utility-types": "^3.10.0"
},
"dependencies": {
"@docusaurus/mdx-loader": "^3.2.0",
"@docusaurus/plugin-content-docs": "^3.2.0",
"@docusaurus/utils": "^3.2.0",
"@docusaurus/utils-common": "^3.2.0",
"@docusaurus/utils-validation": "^3.2.0",
"@docusaurus/mdx-loader": "^3.6.0",
"@docusaurus/plugin-content-docs": "^3.6.0",
"@docusaurus/utils": "^3.6.0",
"@docusaurus/utils-common": "^3.6.0",
"@docusaurus/utils-validation": "^3.6.0",
"chalk": "^4.1.2",
"clsx": "^1.2.1",
"js-yaml": "^4.1.0",
Expand All @@ -43,7 +43,7 @@
"lodash": "^4.17.20",
"openapi-to-postmanv2": "^4.20.1",
"postman-collection": "^4.1.0",
"webpack": "^5.88.1"
"webpack": "^5.95.0"
},
"peerDependencies": {
"react": "^18.0.0",
Expand Down
14 changes: 10 additions & 4 deletions packages/docusaurus-plugin-openapi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { readFile } from "node:fs/promises";
import { join, relative, resolve } from "node:path";

import type { Options as MDXLoaderOptions } from "@docusaurus/mdx-loader";
import type {
LoadContext,
Plugin,
Expand Down Expand Up @@ -245,12 +246,13 @@ export default function pluginOpenAPI(

configureWebpack(
_config: Configuration,
isServer: boolean,
{ getJSLoader }: ConfigureWebpackUtils
_isServer: boolean,
_configureWebpackUtils: ConfigureWebpackUtils
) {
const {
rehypePlugins,
remarkPlugins,
recmaPlugins,
beforeDefaultRehypePlugins,
beforeDefaultRemarkPlugins,
} = options;
Expand All @@ -267,15 +269,19 @@ export default function pluginOpenAPI(
test: /(\.mdx?)$/,
include: [dataDir, contentPath].map(addTrailingPathSeparator),
use: [
getJSLoader({ isServer }),
{
loader: require.resolve("@docusaurus/mdx-loader"),
options: {
admonitions: options.admonitions,
remarkPlugins,
rehypePlugins,
recmaPlugins,
beforeDefaultRehypePlugins,
beforeDefaultRemarkPlugins,
staticDirs: siteConfig.staticDirectories.map((dir) =>
resolve(siteDir, dir)
),
siteDir,
markdownConfig: siteConfig.markdown ?? { mdx1Compat: {} },
metadataPath: (mdxPath: string) => {
if (mdxPath.startsWith(dataDir)) {
Expand All @@ -287,7 +293,7 @@ export default function pluginOpenAPI(
return join(dataDir, `${docuHash(aliasedSource)}.json`);
}
},
},
} satisfies MDXLoaderOptions,
},
].filter(Boolean),
},
Expand Down
14 changes: 13 additions & 1 deletion packages/docusaurus-plugin-openapi/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Joi,
RemarkPluginsSchema,
RehypePluginsSchema,
RecmaPluginsSchema,
AdmonitionsSchema,
} from "@docusaurus/utils-validation";
import chalk from "chalk";
Expand All @@ -23,14 +24,17 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, "id" | "sidebarPath"> = {
apiItemComponent: "@theme/ApiItem",
remarkPlugins: [],
rehypePlugins: [],
recmaPlugins: [],
beforeDefaultRemarkPlugins: [],
beforeDefaultRehypePlugins: [],
admonitions: true,
sidebarCollapsible: true,
sidebarCollapsed: true,
onInlineTags: "warn",
tags: undefined,
};

export const OptionsSchema = Joi.object({
export const OptionsSchema = Joi.object<PluginOptions>({
path: Joi.string().default(DEFAULT_OPTIONS.path),
routeBasePath: Joi.string()
// '' not allowed, see /~https://github.com/facebook/docusaurus/issues/3374
Expand All @@ -42,6 +46,7 @@ export const OptionsSchema = Joi.object({
apiItemComponent: Joi.string().default(DEFAULT_OPTIONS.apiItemComponent),
remarkPlugins: RemarkPluginsSchema.default(DEFAULT_OPTIONS.remarkPlugins),
rehypePlugins: RehypePluginsSchema.default(DEFAULT_OPTIONS.rehypePlugins),
recmaPlugins: RecmaPluginsSchema.default(DEFAULT_OPTIONS.recmaPlugins),
beforeDefaultRemarkPlugins: RemarkPluginsSchema.default(
DEFAULT_OPTIONS.beforeDefaultRemarkPlugins
),
Expand All @@ -51,6 +56,13 @@ export const OptionsSchema = Joi.object({
admonitions: Joi.alternatives()
.try(AdmonitionsSchema, Joi.boolean().invalid(true))
.default(DEFAULT_OPTIONS.admonitions),
onInlineTags: Joi.string()
.equal("ignore", "log", "warn", "throw")
.default(DEFAULT_OPTIONS.onInlineTags),
tags: Joi.string()
.disallow("")
.allow(null, false)
.default(() => DEFAULT_OPTIONS.tags),
});

export function validateOptions({
Expand Down
3 changes: 2 additions & 1 deletion packages/docusaurus-plugin-openapi/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* ========================================================================== */

import type { MDXOptions } from "@docusaurus/mdx-loader";
import type { TagsPluginOptions } from "@docusaurus/utils";
import type { Request } from "postman-collection";

import {
Expand All @@ -20,7 +21,7 @@ export type {
PropSidebar,
PropSidebarItem,
} from "@docusaurus/plugin-content-docs-types";
export interface PluginOptions extends MDXOptions {
export interface PluginOptions extends MDXOptions, TagsPluginOptions {
id: string;
path: string;
routeBasePath: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@docusaurus/types": "^3.2.0",
"@docusaurus/types": "^3.6.0",
"@types/webpack-dev-server": "^4.7.2"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-preset-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"watch": "tsc --watch"
},
"devDependencies": {
"@docusaurus/types": "^3.2.0"
"@docusaurus/types": "^3.6.0"
},
"dependencies": {
"@docusaurus/preset-classic": "^3.2.0",
"@docusaurus/preset-classic": "^3.6.0",
"docusaurus-plugin-openapi": "^0.7.5",
"docusaurus-plugin-proxy": "^0.7.5",
"docusaurus-theme-openapi": "^0.7.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-template-openapi/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "^3.2.0",
"@docusaurus/core": "^3.6.0",
"docusaurus-preset-openapi": "0.7.5",
"@mdx-js/react": "^3.0.0",
"clsx": "^1.2.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus-theme-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.2.0",
"@docusaurus/types": "^3.2.0",
"@docusaurus/module-type-aliases": "^3.6.0",
"@docusaurus/types": "^3.6.0",
"@types/concurrently": "^6.3.0",
"@types/crypto-js": "^4.1.0",
"@types/lodash": "^4.14.176",
Expand All @@ -35,7 +35,7 @@
"concurrently": "^5.2.0"
},
"dependencies": {
"@docusaurus/theme-common": "^3.2.0",
"@docusaurus/theme-common": "^3.6.0",
"@mdx-js/react": "^3.0.0",
"@monaco-editor/react": "^4.3.1",
"@reduxjs/toolkit": "^1.7.1",
Expand All @@ -56,7 +56,7 @@
"redux-devtools-extension": "^2.13.8",
"refractor": "^4.8.1",
"striptags": "^3.2.0",
"webpack": "^5.88.1"
"webpack": "^5.95.0"
},
"peerDependencies": {
"react": "^18.0.0",
Expand Down
13 changes: 9 additions & 4 deletions packages/docusaurus-theme-openapi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import path from "path";

import type { Plugin } from "@docusaurus/types";
import { ProvidePlugin } from "webpack";
import type { ConfigureWebpackUtils, Plugin } from "@docusaurus/types";
import type { Configuration as WebpackConfiguration } from "webpack";

export default function docusaurusThemeOpenAPI(): Plugin<void> {
return {
Expand All @@ -22,10 +22,15 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
return path.resolve(__dirname, "..", "src", "theme");
},

configureWebpack() {
configureWebpack(
_config: WebpackConfiguration,
_isServer: boolean,
{ currentBundler }: ConfigureWebpackUtils
) {
const bundler = currentBundler.instance ?? require("webpack");
return {
plugins: [
new ProvidePlugin({
new bundler.ProvidePlugin({
Buffer: [require.resolve("buffer/"), "Buffer"],
process: require.resolve("process/browser"),
}),
Expand Down
Loading