npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@innerfuse/mdx.macro

v0.1.0

Published

A babel-macro for transforming mdx

Downloads

3

Readme

mdx.macro

Babel Macro

npm version

A babel-macro for converting mdx into an inline component.

## This is some MDX source

<SomeComponent />

~~strikethrough~~
import { mdx, imports } from 'mdx.macro'
import { MDXTag } from '@mdx-js/tag'
imports() // copies import statements from markdown file to here

const SomeMDXComponent = mdx('./markdown.md')

generates...

```js
const SomeMDXComponent = ({ components, ...props }) => (
  <MDXTag name="wrapper" components={components}>
    <MDXTag name="h2" components={components}>{`This is some MDX source`}</MDXTag>{' '}
    <SomeComponent />{' '}
    <MDXTag name="p" components={components}>
      <MDXTag
        name="del"
        components={components}
        parentName="p"
      >
        {`strikethrough`}
      </MDXTag>
    </MDXTag>
  </MDXTag>
)

Getting started

Set up an application

Recommended setup - set up an application from scratch

yarn or npm can be used

create a package.json file

  npm init

  yarn init

install webpack and webpack-cli as dev dependencies

  npm i webpack webpack-cli webpack-dev-server html-webpack-plugin -D

  yarn add webpack webpack-cli webpack-dev-server html-webpack-plugin -D

add to package.json

  "scripts": {
    "start": "webpack-dev-server --mode development --open",
    "build": "webpack --mode production"
  },

install and save react and react-dom

  npm i react react-dom

  yarn add react react-dom

install and save the following dev dependencies

  npm i @babel/core babel-loader @babel/preset-env @babel/preset-react -D

  yarn add @babel/core babel-loader @babel/preset-env @babel/preset-react -D

create a webpack config. Example of a basic webpack config file:

  const HtmlWebPackPlugin = require("html-webpack-plugin");

  const htmlPlugin = new HtmlWebPackPlugin({
    template: "./src/index.html",
    filename: "./index.html"
  });

  module.exports = {
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: "babel-loader"
          }
        }
      ]
    },
    plugins: [htmlPlugin]
  };

create a .babelrc file and add the following presets

  {
    "presets": ["@babel/preset-env", "@babel/preset-react"]
  }

Install and save the following dev dependencies

  npm i @innerfuse/mdx.macro babel-plugin-macros @mdx-js/tag -D

  yarn add @innerfuse/mdx-macro babel-plugin-macros @mdx-js/tag -D

Add babel-plugin-macros to your babel config file

  "plugins": [
    "babel-plugin-macros"
  ]

Known Problems

If you use a React component which is not defined in the Javascript file and is not imported the application will stop working and you will get an error similar to __jsxFilename not defined. If this is the case ensure you have the component referred in the Markdown file is defined.