Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blocz/mdx-loader

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blocz/mdx-loader

The only difference between [`@mdx-js/loader`](https://www.npmjs.com/package/@mdx-js/loader) and `@blocz/mdx-loader` is that `@blocz/mdx-loader` outputs, in addition to the MDX component, an object `importStatements` with the list of every imports defined

  • 0.0.7
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

TL;DR

The only difference between @mdx-js/loader and @blocz/mdx-loader is that @blocz/mdx-loader outputs, in addition to the MDX component, an object importStatements with the list of every imports defined in the MDX file.

How to use

yarn add -D @blocz/mdx-loader

And then, adds in your webpack config:

module.exports = {
    // ...
    module: {
        rules: [
            // ...
            {
                test: /.mdx?$/,
                loader: "@blocz/mdx-loader",
            },
        ],
    },
};

And finally:

import MyAwesomeComponent, { importStatements } from './my-awesome-component.mdx';

type importStatements

interface ImportStatement {
    module: string;
    imports: Array<{
        imported: string;
        local: string;
        value: any;
    }>;
}

// example with
// import React, { Component } from 'react';
// import { MDX as MDXLive } from '@blocz/mdx-live';

const importStatements: ImportStatement[] = [
    {
        module: "react",
        imports: [
            {
                imported: "default",
                local: "React",
                value: this_is_the_value_of_the_variable_React,
            },
            {
                imported: "Component",
                local: "Component",
                value: this_is_the_value_of_the_variable_Component,
            },
        ],
    },
    {
        module: "@blocz/mdx-live",
        imports: [
            {
                imported: "MDX",
                local: "MDXLive",
                value: this_is_the_value_of_the_variable_MDXLive,
            },
        ],
    },
];

FAQs

Package last updated on 13 May 2020

Did you know?

Socket

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.

Install

Related posts

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