rollup-plugin-md
raw JSON → 1.0.1 verified Mon Apr 27 auth: no javascript abandoned
A Rollup plugin for importing Markdown files as ES modules. Current stable version 1.0.1, last updated in 2018 with no recent releases. It uses the 'marked' library for Markdown parsing, converts .md files to HTML strings that can be imported in JavaScript/TypeScript. Key differentiator: minimal plugin for Rollup ecosystem, but lacks active maintenance.
Common errors
error Error: Could not resolve './example.md' (note that you need plugins to import files that are not JavaScript) ↓
cause The markdown file import was not processed because the plugin is not correctly configured in rollup.config.js.
fix
Ensure rollup-plugin-md is added to the plugins array in rollup.config.js.
error TypeError: md is not a function ↓
cause Wrong import style: using named import instead of default import.
fix
Use 'import md from 'rollup-plugin-md'' (default import), not named import.
error Cannot find module 'marked' ↓
cause Optional dependency 'marked' is not installed.
fix
Run 'npm install marked' or set 'marked: false' in plugin options.
Warnings
deprecated Project has not been updated since 2018 and may be incompatible with modern Rollup versions. ↓
fix Consider alternatives like @rollup/plugin-html or Vite's built-in markdown support.
gotcha The plugin expects '.md' extension and will fail on other markdown extensions like '.markdown'. ↓
fix Use only .md files or consider a different plugin.
gotcha The plugin uses the 'marked' library as a peer dependency with a loose version range, may pull incompatible versions. ↓
fix Pin a compatible version of marked manually.
breaking No support for Rollup configuration format changes from CommonJS to ES modules in Rollup v2+. ↓
fix Use dynamic import or convert config to CommonJS if using old plugin.
Install
npm install rollup-plugin-md yarn add rollup-plugin-md pnpm add rollup-plugin-md Imports
- default wrong
import { md } from 'rollup-plugin-md'correctimport md from 'rollup-plugin-md' - import .md files wrong
const content = require('./example.md')correctimport content from './example.md' - TypeScript types wrong
declare module '*.md'correct// not available - no type definitions
Quickstart
// rollup.config.js
import md from 'rollup-plugin-md';
export default {
input: 'main.js',
output: { dir: 'dist', format: 'es' },
plugins: [md({
// Pass options to the 'marked' parser
marked: { gfm: true }
})]
};
// main.js
import readme from './README.md';
console.log(readme); // HTML string