Skip to content

Commit

Permalink
feat(docs): Use webpack resolve alias instead of patching MDX loader
Browse files Browse the repository at this point in the history
  • Loading branch information
clemyan committed Feb 21, 2024
1 parent 4279136 commit b3e3337
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 137 deletions.
43 changes: 18 additions & 25 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
62 changes: 0 additions & 62 deletions .yarn/patches/@docusaurus-mdx-loader-npm-3.1.1-f9575cfad3.patch

This file was deleted.

3 changes: 0 additions & 3 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ packageExtensions:
react-is: "*"
scheduler: "*"

"@docusaurus/mdx-loader@^3":
dependencies:
"@mdx-js/react": "^3"
"@docusaurus/[email protected]":
peerDependencies:
"@docusaurus/plugin-content-docs": "3.1.1"
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@types/jest": "^28.1.6",
"@types/micromatch": "^4.0.1",
"@types/node": "^18.17.15",
"@types/react": "^18.2.54",
"@types/semver": "^7.1.0",
"@yarnpkg/cli": "workspace:^",
"@yarnpkg/core": "workspace:^",
Expand All @@ -32,8 +31,7 @@
},
"resolutions": {
"ink": "patch:ink@npm%3A3.0.8#~/.yarn/patches/ink-npm-3.0.8-3a8005f59f.patch",
"yoga-layout-prebuilt": "patch:[email protected]#./.yarn/patches/yoga-layout-prebuilt.patch",
"@docusaurus/mdx-loader": "patch:@docusaurus/mdx-loader@npm%3A3.1.1#~/.yarn/patches/%40docusaurus-mdx-loader-npm-3.1.1-f9575cfad3.patch"
"yoga-layout-prebuilt": "patch:[email protected]#./.yarn/patches/yoga-layout-prebuilt.patch"
},
"dependenciesMeta": {
"core-js": {
Expand Down Expand Up @@ -79,11 +77,9 @@
},
"dependencies": {
"@iarna/toml": "^2.2.5",
"@mdx-js/react": "^3.0.0",
"@yarnpkg/types": "workspace:^",
"chalk": "^3.0.0",
"micromatch": "^4.0.2",
"react": "^18.2.0",
"semver": "^7.1.2"
}
}
5 changes: 5 additions & 0 deletions packages/docusaurus/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {PluginModule} from '@docusaurus/types';
import {createRequire} from 'node:module';
import path from 'node:path';

const webpack = createRequire(require.resolve(`@docusaurus/core/package.json`))(`webpack`);

Expand All @@ -22,6 +23,10 @@ const plugin: PluginModule = async function() {
os: require.resolve(`os-browserify`),
path: require.resolve(`path-browserify`),
},
alias: {
'@mdx-js/react': require.resolve(`@mdx-js/react`),
react: path.resolve(require.resolve(`react/package.json`), `..`),
},
},
plugins: [
new webpack.DefinePlugin({
Expand Down
44 changes: 2 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3533,7 +3533,7 @@ __metadata:
languageName: node
linkType: hard

"@docusaurus/mdx-loader@npm:3.1.1":
"@docusaurus/mdx-loader@npm:3.1.1, @docusaurus/mdx-loader@npm:^3":
version: 3.1.1
resolution: "@docusaurus/mdx-loader@npm:3.1.1"
dependencies:
Expand Down Expand Up @@ -3570,43 +3570,6 @@ __metadata:
languageName: node
linkType: hard

"@docusaurus/mdx-loader@patch:@docusaurus/mdx-loader@npm%3A3.1.1#~/.yarn/patches/%40docusaurus-mdx-loader-npm-3.1.1-f9575cfad3.patch":
version: 3.1.1
resolution: "@docusaurus/mdx-loader@patch:@docusaurus/mdx-loader@npm%3A3.1.1#~/.yarn/patches/@docusaurus-mdx-loader-npm-3.1.1-f9575cfad3.patch::version=3.1.1&hash=1e716c"
dependencies:
"@babel/parser": "npm:^7.22.7"
"@babel/traverse": "npm:^7.22.8"
"@docusaurus/logger": "npm:3.1.1"
"@docusaurus/utils": "npm:3.1.1"
"@docusaurus/utils-validation": "npm:3.1.1"
"@mdx-js/mdx": "npm:^3.0.0"
"@slorber/remark-comment": "npm:^1.0.0"
escape-html: "npm:^1.0.3"
estree-util-value-to-estree: "npm:^3.0.1"
file-loader: "npm:^6.2.0"
fs-extra: "npm:^11.1.1"
image-size: "npm:^1.0.2"
mdast-util-mdx: "npm:^3.0.0"
mdast-util-to-string: "npm:^4.0.0"
rehype-raw: "npm:^7.0.0"
remark-directive: "npm:^3.0.0"
remark-emoji: "npm:^4.0.0"
remark-frontmatter: "npm:^5.0.0"
remark-gfm: "npm:^4.0.0"
stringify-object: "npm:^3.3.0"
tslib: "npm:^2.6.0"
unified: "npm:^11.0.3"
unist-util-visit: "npm:^5.0.0"
url-loader: "npm:^4.1.1"
vfile: "npm:^6.0.1"
webpack: "npm:^5.88.1"
peerDependencies:
react: ^18.0.0
react-dom: ^18.0.0
checksum: 10/3afba7701b7e5af78ba8e1f3d90ba774c4b72241ebaac2f8530e81921e631b22d6009e66228320066716366e510bdf71b10f4a9c086acd39f373772fa759c73f
languageName: node
linkType: hard

"@docusaurus/module-type-aliases@npm:3.1.1, @docusaurus/module-type-aliases@npm:^3.1.1":
version: 3.1.1
resolution: "@docusaurus/module-type-aliases@npm:3.1.1"
Expand Down Expand Up @@ -4774,7 +4737,7 @@ __metadata:
languageName: node
linkType: hard

"@mdx-js/react@npm:^3, @mdx-js/react@npm:^3.0.0":
"@mdx-js/react@npm:^3.0.0":
version: 3.0.1
resolution: "@mdx-js/react@npm:3.0.1"
dependencies:
Expand Down Expand Up @@ -6982,11 +6945,9 @@ __metadata:
"@babel/preset-react": "npm:^7.18.6"
"@babel/preset-typescript": "npm:^7.18.6"
"@iarna/toml": "npm:^2.2.5"
"@mdx-js/react": "npm:^3.0.0"
"@types/jest": "npm:^28.1.6"
"@types/micromatch": "npm:^4.0.1"
"@types/node": "npm:^18.17.15"
"@types/react": "npm:^18.2.54"
"@types/semver": "npm:^7.1.0"
"@yarnpkg/cli": "workspace:^"
"@yarnpkg/core": "workspace:^"
Expand All @@ -7002,7 +6963,6 @@ __metadata:
jest: "npm:^29.2.1"
micromatch: "npm:^4.0.2"
pirates: "npm:^4.0.5"
react: "npm:^18.2.0"
semver: "npm:^7.1.2"
tslib: "npm:^2.4.0"
typescript: "npm:5.4.0-beta"
Expand Down

0 comments on commit b3e3337

Please sign in to comment.