Registry / devops / esbuild-plugin-markdown

esbuild-plugin-markdown

JSON →
library0.0.3jsnpmunverified

An esbuild plugin that enables importing Markdown files as JavaScript modules. This v0.0.3 plugin uses the 'marked' library to parse Markdown to HTML. It exports both the raw markdown string and parsed HTML. Ideal for static site generation or content loading at build time. Compared to alternatives like '@mdx-js/esbuild', it is simpler and more lightweight but offers less transformation flexibility. The package ships with TypeScript types and is released infrequently.

npm install esbuild-plugin-markdown
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-MAR
E
esbuild-plugin-markdown
devopsjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

markdownPlugin
import { markdownPlugin } from 'esbuild-plugin-markdown'
import markdownPlugin from 'esbuild-plugin-markdown'
The plugin is a named export, not default.
File with .md import
import myDoc from './doc.md' // TypeScript: declare module '*.md'
const myDoc = require('./doc.md')
CommonJS require may not resolve the module correctly; ESM import is required for esbuild.
Type definitions
import type { MarkdownPluginOptions } from 'esbuild-plugin-markdown'
type MarkdownPluginOptions = { markedOptions?: any }
Types are exported; using 'any' defeats type safety.

Bundles a JavaScript file and imports a Markdown file, parsing it with marked and enabling line breaks.

import { build } from 'esbuild'; import { markdownPlugin } from 'esbuild-plugin-markdown'; build({ entryPoints: ['src/index.js'], outfile: 'dist/bundle.js', plugins: [ markdownPlugin({ markedOptions: { breaks: true } }) ] }).catch(() => process.exit(1));
Debug
Known issues
gotchaTypeScript cannot resolve .md files unless you declare a module or include a type definition like 'declare module "*.md"'.
fix
Add a .d.ts file with: declare module '*.md' { const content: { html: string; raw: string; filename: string }; export default content; }
affects: >=0.0.0
deprecatedThe plugin API may change in future versions as esbuild evolves.
fix
Check for updates regularly or pin version if stability needed.
affects: 0.0.3
Errors
Common errors & fixes
error: No loader is configured for ".md" files: ...
The plugin is not added to the esbuild plugins list or the import is not processed.
fix
Add markdownPlugin() to the plugins array in the esbuild build configuration.
Cannot find module 'marked'
The 'marked' dependency is missing.
fix
Run npm install marked or add it to your dependencies.
TypeError: Cannot read properties of undefined (reading 'html')
Importing .md file without the plugin active, resulting in undefined content.
fix
Ensure the plugin is correctly loaded and applied to esbuild.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
markedrequiredRuntime dependency for parsing markdown to HTML
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-markdown — npm install esbuild-plugin-markdown · libregistry