-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): always alias React/ReactDOM to site dependency so that imp…
…orting MDX from anywhere works (#10391)
- Loading branch information
Showing
8 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# test-bad-package | ||
|
||
This package declares a wrong React version on purpose (16.14.0) | ||
|
||
The goal is to test that the MD/MDX content of this package can still be imported/rendered by our website. | ||
|
||
See related issue https://github.com/facebook/docusaurus/issues/9027 | ||
|
||
--- | ||
|
||
import {version as ReactVersion} from 'react'; | ||
import {version as ReactDOMVersion} from 'react-dom'; | ||
|
||
export function TestComponent() { | ||
const expectedVersion = 18; | ||
if (!ReactVersion.startsWith(`${expectedVersion}`)) { | ||
throw new Error( | ||
`'test-bad-package/README.mdx' is rendered with bad React version: ${ReactVersion}`, | ||
); | ||
} | ||
if (!ReactVersion.startsWith(`${expectedVersion}`)) { | ||
throw new Error( | ||
`'test-bad-package/README.mdx' is rendered with bad React-DOM version: ${ReactDOMVersion}`, | ||
); | ||
} | ||
return ( | ||
<> | ||
<div>React version: {ReactVersion}</div> | ||
<div>React DOM version: {ReactDOMVersion}</div> | ||
</> | ||
); | ||
} | ||
|
||
<TestComponent /> | ||
|
||
--- | ||
|
||
## MDX Components work: | ||
|
||
<details> | ||
<summary>Summary</summary> | ||
|
||
Details | ||
|
||
</details> | ||
|
||
```js | ||
const age = 42; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "test-bad-package", | ||
"version": "3.5.1", | ||
"private": true, | ||
"dependencies": { | ||
"react": "16.14.0", | ||
"react-dom": "16.14.0", | ||
"@mdx-js/react": "1.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
website/_dogfooding/_docs tests/tests/import-bad-package.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Import Bad Package | ||
|
||
We are importing MDX content from a file that is in a package that has a bad React version. | ||
|
||
This is expected to work despite the bad version. | ||
|
||
See https://github.com/facebook/docusaurus/issues/9027 | ||
|
||
--- | ||
|
||
import Readme from '@site/../admin/test-bad-package/README.mdx'; | ||
|
||
<Readme /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters