micromark-build is a small, specialized Command Line Interface (CLI) tool designed to optimize and build development source code for micromark extensions into production-ready output. It achieves this by applying a series of Babel transformations such as `babel-plugin-unassert`, `babel-plugin-undebug`, and `babel-plugin-inline-constants`. These plugins are responsible for removing development-specific assertions (like `assert` or `uvu/assert`), debug calls (from `debug`), and for inlining constant values from specified modules (e.g., `micromark-util-symbol`). This optimization process results in smaller and faster code for deployment in browser or Node.js environments. The current stable version is 2.0.3, with new releases typically coordinated within the broader micromark monorepo. Its primary differentiating factor is its tailored optimization focus specifically for the micromark ecosystem, making it an essential utility for developers creating micromark extensions who need to balance development-time debugging with production-ready performance and minimal bundle size.
npm install micromark-buildVerified import paths — ran on the pinned version, not inferred.
This quickstart illustrates how to configure `micromark-build` in a `package.json` for a micromark extension. It shows how to define `dev/` and production `lib/` entry points using an `exports` map, and provides example development code that `micromark-build` will optimize by removing assertions and debug logs, and inlining constants.
Ensure your development environment runs on Node.js v16 or higher. Always consult the `micromark` monorepo's `security.md` for the most up-to-date compatibility requirements before upgrading.
Only integrate `micromark-build` into projects developing or extending `micromark` functionality. For other types of JavaScript or TypeScript projects, consider widely-used bundlers or build tools like Webpack, Rollup, or esbuild.
Configure your `package.json` with an `exports` field pointing to both `development` (e.g., `./dev/index.js`) and `default` (e.g., `./index.js`) entry points. When developing, run your application or tests with `node --conditions development your-entry-file.js`.
Verify that your project structure includes a `dev/` folder containing your development source code. Ensure that `micromark-build` and its internal dependencies are correctly installed and accessible in your environment (`npm install`). Check for any syntax errors in your source files that might halt the Babel transformation.
As `micromark-build` is a CLI tool, it should not be imported or required as a programmatic module. Instead, execute it from your `package.json` scripts, for example, by adding `"build": "micromark-build"` to your `scripts` section and running `npm run build`.