New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mdx-bundler

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdx-bundler - npm Package Compare versions

Comparing version 10.0.2 to 10.0.3

2

dist/index.js

@@ -184,3 +184,3 @@ "use strict";

define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'production')
},

@@ -187,0 +187,0 @@ plugins: [(0, _esbuildPluginGlobalExternals.globalExternals)({

{
"name": "mdx-bundler",
"version": "10.0.2",
"version": "10.0.3",
"description": "Compile and bundle your MDX files and their dependencies. FAST.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -184,2 +184,3 @@ <div align="center">

- [Bundling a file.](#bundling-a-file)
- [Custom Components in Downstream Files](#custom-components-in-downstream-files)
- [Known Issues](#known-issues)

@@ -715,2 +716,58 @@ - [Inspiration](#inspiration)

### Custom Components in Downstream Files
To make sure custom components are accessible in downstream MDX files, you
can use the `MDXProvider` from `@mdx-js/react` to pass custom components
to your nested imports.
```
npm install --save @mdx-js/react
```
```tsx
const globals = {
'@mdx-js/react': {
varName: 'MdxJsReact',
namedExports: ['useMDXComponents'],
defaultExport: false,
},
};
const { code } = bundleMDX({
source,
globals,
mdxOptions(options: Record<string, any>) {
return {
...options,
providerImportSource: '@mdx-js/react',
};
}
});
```
From there, you send the `code` to your client, and then:
```tsx
import { MDXProvider, useMDXComponents } from '@mdx-js/react';
const MDX_GLOBAL_CONFIG = {
MdxJsReact: {
useMDXComponents,
},
};
export const MDXComponent: React.FC<{
code: string;
frontmatter: Record<string, any>;
}> = ({ code }) => {
const Component = useMemo(
() => getMDXComponent(code, MDX_GLOBAL_CONFIG),
[code],
);
return (
<MDXProvider components={{ Text: ({ children }) => <p>{children}</p> }}>
<Component />
</MDXProvider>
);
};
```
### Known Issues

@@ -717,0 +774,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc