
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@blocz/mdx-plugin-detect-imports
Advanced tools
@blocz/mdx-plugin-detect-importsMDX plugin to detect the list of every imports done in a MDX file.
If your MDX file look like this:
import { Tabs, Button } from "@blocz/elements";
## Hello MDX
1. First item
2. Second item
<Button
// this is a comment
variant="blue"
label="Label"
/>
This plugin will transform this file into:
import { Button, Tabs as Tabulations } from "@blocz/elements";
## Hello MDX
1. First item
2. Second item
<Button variant="blue" label="Label" />
export const importStatements = [
{
module: "@blocz/elements",
imports: [
{
imported: "Button",
local: "Button",
value: this_is_the_value_of_the_variable_Button
},
{
imported: "Tabs",
local: "Tabulations",
value: this_is_the_value_of_the_variable_Tabs
}
]
}
]
yarn add -D @blocz/mdx-plugin-detect-imports
const detectImportsPlugin = require("@blocz/mdx-plugin-detect-imports");
module.exports = {
// ...
module: {
rules: [
// ...
{
test: /.mdx?$/,
loader: "@mdx-js/loader",
options: {
remarkPlugins: [detectImportsPlugin],
// Or if you want to specify a custom name for the exported variable:
remarkPlugins: [
[detectImportsPlugin, { exportName: "otherName" }],
],
},
},
],
},
};
And finally:
import MyAwesomeComponent, { importStatements } from './my-awesome-component.mdx';
(or import MyAwesomeComponent, { otherName } from './my-awesome-component.mdx'; if you specified a custom name.)
const mdx = require("@mdx-js/mdx");
const detectImportsPlugin = require("@blocz/mdx-plugin-detect-imports");
const jsx = await mdx(mdxText, {
remarkPlugins: [detectImportsPlugin],
});
// Or if you want to specify a custom name for the exported variable:
const jsx = await mdx(mdxText, {
remarkPlugins: [[detectImportsPlugin, { exportName: "otherName" }]],
});
ImportStatementIf you need typings, we provide the following type:
interface ImportStatement {
module: string;
imports: Array<{
imported: string;
local: string;
value: any;
}>;
}
And then you can do:
// mdx.d.ts
declare module "*.mdx" {
const MDXComponent: (props: any) => JSX.Element;
// you can replace `importStatements` with your own variable name
export const importStatements: ImportStatement[];
export default MDXComponent;
}
FAQs
Unknown package
We found that @blocz/mdx-plugin-detect-imports demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.