-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Override jsx built-in components #2050
Conversation
… (h1, p, img, ...etc)
…nal code generated
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## main #2050 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 2308 2301 -7
=========================================
- Hits 2308 2301 -7
Continue to review full report at Codecov.
|
This behavior is intentional see the discussion in #821 |
This behavior is intentional |
@ChristianMurphy @wooorm should Something like this perhaps? diff --git a/node_modules/@mdx-js/mdx/lib/core.js b/node_modules/@mdx-js/mdx/lib/core.js
index 96e34d7..19d0d6d 100644
--- a/node_modules/@mdx-js/mdx/lib/core.js
+++ b/node_modules/@mdx-js/mdx/lib/core.js
@@ -75,6 +75,7 @@ export function createProcessor(options = {}) {
remarkPlugins,
remarkRehypeOptions = {},
SourceMapGenerator,
+ disableParentContext,
...rest
} = options
let index = -1
@@ -122,7 +123,7 @@ export function createProcessor(options = {}) {
pipeline
.use(rehypeRecma)
.use(recmaDocument, {...rest, outputFormat})
- .use(recmaJsxRewrite, {development, providerImportSource, outputFormat})
+ .use(recmaJsxRewrite, {development, providerImportSource, outputFormat, disableParentContext})
if (!jsx) {
pipeline.use(recmaJsxBuild, {outputFormat})
diff --git a/node_modules/@mdx-js/mdx/lib/plugin/recma-jsx-rewrite.js b/node_modules/@mdx-js/mdx/lib/plugin/recma-jsx-rewrite.js
index e1d8dbf..5a6c7a8 100644
--- a/node_modules/@mdx-js/mdx/lib/plugin/recma-jsx-rewrite.js
+++ b/node_modules/@mdx-js/mdx/lib/plugin/recma-jsx-rewrite.js
@@ -59,7 +59,8 @@ const own = {}.hasOwnProperty
* @type {import('unified').Plugin<[RecmaJsxRewriteOptions]|[], Program>}
*/
export function recmaJsxRewrite(options = {}) {
- const {development, providerImportSource, outputFormat} = options
+ const {development, providerImportSource, outputFormat, disableParentContext} = options
return (tree, file) => {
// Find everything that’s defined in the top-level scope.
@@ -183,7 +184,7 @@ export function recmaJsxRewrite(options = {}) {
}
// @ts-expect-error Allow fields passed through from mdast through hast to
// esast.
- else if (node.data && node.data._mdxExplicitJsx) {
+ else if (!disableParentContext && node.data && node.data._mdxExplicitJsx) {
// Do not turn explicit JSX into components from `_components`.
// As in, a given `h1` component is used for `# heading` (next case),
// but not for `<h1>heading</h1>`. |
Also while messing with the tests it's unclear to me that
|
I do not believe |
I've been investigating the differences between
mdx-bundler
andnext-remote-mdx@3.0.5
and discovered that no matter what I didmdx-bundler
would not replace anyjsx
that had a native version if explicitly used inside of themdx
file.Here is an example which shows 3 different scenarios and the result using
latest
:does not override: <img src="test.png" />
Since this is a built-in component, no override check is performed andjsxRuntime.jsx.img
is useddoes override: ![Image](test.png)
All md conversions automatically go through thecomponents
override check<Img src="test.png" />
Custom components automatically go through thecomponents
checkEventually I tracked the difference between handling in
mdx-js/mdx
between version1.*.*
and2.*.*
.Code Removed
The only reasoning I could come up with is that maybe it compiles slightly smaller and runs slightly faster but I don't think it'll have any real performance differences.
kentcdodds/mdx-bundler#160