{"id":25371,"library":"esbuild-plugin-markdown","title":"esbuild-plugin-markdown","description":"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.","status":"active","version":"0.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/martonlederer/esbuild-plugin-markdown","tags":["javascript","typescript"],"install":[{"cmd":"npm install esbuild-plugin-markdown","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-markdown","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-markdown","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for parsing markdown to HTML","package":"marked","optional":false}],"imports":[{"note":"The plugin is a named export, not default.","wrong":"import markdownPlugin from 'esbuild-plugin-markdown'","symbol":"markdownPlugin","correct":"import { markdownPlugin } from 'esbuild-plugin-markdown'"},{"note":"CommonJS require may not resolve the module correctly; ESM import is required for esbuild.","wrong":"const myDoc = require('./doc.md')","symbol":"File with .md import","correct":"import myDoc from './doc.md' // TypeScript: declare module '*.md'"},{"note":"Types are exported; using 'any' defeats type safety.","wrong":"type MarkdownPluginOptions = { markedOptions?: any }","symbol":"Type definitions","correct":"import type { MarkdownPluginOptions } from 'esbuild-plugin-markdown'"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { markdownPlugin } from 'esbuild-plugin-markdown';\n\nbuild({\n  entryPoints: ['src/index.js'],\n  outfile: 'dist/bundle.js',\n  plugins: [\n    markdownPlugin({\n      markedOptions: { breaks: true }\n    })\n  ]\n}).catch(() => process.exit(1));","lang":"typescript","description":"Bundles a JavaScript file and imports a Markdown file, parsing it with marked and enabling line breaks."},"warnings":[{"fix":"Add a .d.ts file with: declare module '*.md' { const content: { html: string; raw: string; filename: string }; export default content; }","message":"TypeScript cannot resolve .md files unless you declare a module or include a type definition like 'declare module \"*.md\"'.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Check for updates regularly or pin version if stability needed.","message":"The plugin API may change in future versions as esbuild evolves.","severity":"deprecated","affected_versions":"0.0.3"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Add markdownPlugin() to the plugins array in the esbuild build configuration.","cause":"The plugin is not added to the esbuild plugins list or the import is not processed.","error":"error: No loader is configured for \".md\" files: ..."},{"fix":"Run npm install marked or add it to your dependencies.","cause":"The 'marked' dependency is missing.","error":"Cannot find module 'marked'"},{"fix":"Ensure the plugin is correctly loaded and applied to esbuild.","cause":"Importing .md file without the plugin active, resulting in undefined content.","error":"TypeError: Cannot read properties of undefined (reading 'html')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}