Registry / devops / micromark-build

micromark-build

JSON →
library2.0.3jsnpmunverified

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-build
INSTALL
IMPORT
SIG · MICROMARK-BUILD
M
micromark-build
devopsjavascriptv2.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

micromark-build (CLI)
npm install micromark-build --save-dev // Then, in package.json scripts: "build": "micromark-build"
import { micromarkBuild } from 'micromark-build'
This package is fundamentally a Command Line Interface (CLI) tool and is not intended for direct programmatic JavaScript/TypeScript imports. Its functionality is invoked via command-line execution, typically through an npm script.
Development Condition
node --conditions development ./dev/index.js
import { development } from 'micromark-build'
While `micromark-build` processes files that can be conditionally loaded, the 'development' condition itself is a Node.js runtime flag, not a direct export from this package. Developers configure their project's `exports` map and use this flag to access unoptimized development code.
TypeScript Types (related)
import type { CompileContext } from 'micromark-util-types'
import type { BuildOptions } from 'micromark-build'
`micromark-build` itself is fully typed with TypeScript but explicitly states it exports no *additional* public types for direct import. Any necessary types for developing micromark extensions, which `micromark-build` processes, would typically be imported from other `micromark-util-*` or `micromark-core-*` packages within the ecosystem.

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.

{ "name": "my-micromark-extension", "version": "1.0.0", "description": "My custom micromark extension.", "type": "module", "main": "index.js", "scripts": { "build": "micromark-build" }, "exports": { "development": "./dev/index.js", "default": "./index.js" }, "devDependencies": { "micromark-build": "^2.0.0", "devlop": "^1.0.0", "micromark-util-symbol": "^2.0.0", "uvu": "^0.5.0" } } // Example: my-micromark-extension/dev/index.js // (This file is processed by `micromark-build` into lib/index.js) import { codes } from 'micromark-util-symbol'; import { assert } from 'uvu/assert'; import { debug } from 'devlop'; const log = debug('my-extension'); export function myExtension() { assert.ok(true, 'This assertion will be removed in production!'); log('Debugging my extension setup.'); return { tokenizer: { 92: onBackslash } }; // ASCII 92 is '\\' } function onBackslash(code) { log('Handling backslash character.'); // `codes.backslash` will be inlined in production by micromark-build. return code === codes.backslash ? 1 : 0; }
micromark-build --version
Debug
Known issues
breakingProjects within the unified collective, including `micromark-build`, are only compatible with maintained versions of Node.js. Major releases typically drop support for unmaintained Node.js versions.
fix
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.
affects: >=2.0.0
gotchamicromark-build is a highly specialized tool tailored for the `micromark` ecosystem, specifically for optimizing micromark extensions. It is not a generic JavaScript build tool and is not recommended for use outside this context.
fix
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.
affects: >=1.0.0
gotchaTo correctly use `micromark-build` and leverage its development-time features (assertions, debug messages), you must define an `exports` map in your `package.json` with a `development` condition. To run your project using the development files, Node.js must be launched with the `--conditions development` flag.
fix
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`.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Command failed with exit code 1
This generic error often indicates that `micromark-build` could not find the expected `dev/` source directory, or encountered other file system or processing errors during its run.
fix
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.
Error: Cannot find module 'micromark-build' from '...' or 'TypeError: micromarkBuild is not a function'
These errors occur when attempting to `import` or `require` `micromark-build` directly into your JavaScript/TypeScript code.
fix
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`.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
babel-plugin-unassertrequiredUsed internally by `micromark-build` to remove `assert`, `power-assert`, `uvu/assert`, and `devlop` calls from development code.
babel-plugin-undebugrequiredUsed internally by `micromark-build` to remove `debug` calls from development code, optimizing production bundles.
babel-plugin-inline-constantsrequiredUsed internally by `micromark-build` to inline values from specified constant modules, such as `micromark-util-symbol`, for improved performance and reduced bundle size.
micromark-util-symbolrequiredThis package's constants are specifically targeted and inlined by `micromark-build`. Developers of micromark extensions are encouraged to use `micromark-util-symbol` for constants to benefit from this optimization.
Agent activity
5 hits · last 30 days
node
4
Perplexity
1
Resources