{"id":11310,"library":"micromark-util-combine-extensions","title":"micromark Extension Combiner Utility","description":"micromark-util-combine-extensions is a dedicated utility package within the unified collective, designed to efficiently merge multiple micromark syntax extensions or HTML extensions into a single, cohesive extension object. This functionality is crucial for creating and managing markdown processing presets, such as `micromark-extension-gfm`, which bundle several individual extensions into a convenient package. The package is currently at version 2.0.1, which is compatible with Node.js 16+ and works specifically with `micromark@3`. As a component of the `micromark` monorepo, its release cadence generally aligns with the broader `micromark` project, which sees regular updates for performance and bug fixes across its various components. Its primary differentiator is its singular focus on extension combination, providing a streamlined API (`combineExtensions`, `combineHtmlExtensions`) that simplifies complex extension management for developers building custom markdown processing pipelines.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/micromark/micromark#main","tags":["javascript","micromark","util","utility","extension","combine","merge","typescript"],"install":[{"cmd":"npm install micromark-util-combine-extensions","lang":"bash","label":"npm"},{"cmd":"yarn add micromark-util-combine-extensions","lang":"bash","label":"yarn"},{"cmd":"pnpm add micromark-util-combine-extensions","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This utility operates on `micromark`'s `Extension` and `HtmlExtension` types and is intended for use within the `micromark` ecosystem. It is explicitly compatible with `micromark@3`.","package":"micromark","optional":false}],"imports":[{"note":"This package is ESM-only, meaning CommonJS `require` syntax is not supported. Use ES modules `import`.","wrong":"const { combineExtensions } = require('micromark-util-combine-extensions')","symbol":"combineExtensions","correct":"import { combineExtensions } from 'micromark-util-combine-extensions'"},{"note":"There is no default export; `combineHtmlExtensions` must be imported by name as a named export.","wrong":"import combineHtmlExtensions from 'micromark-util-combine-extensions'","symbol":"combineHtmlExtensions","correct":"import { combineHtmlExtensions } from 'micromark-util-combine-extensions'"}],"quickstart":{"code":"import {gfmAutolinkLiteral} from 'micromark-extension-gfm-autolink-literal'\nimport {gfmStrikethrough} from 'micromark-extension-gfm-strikethrough'\nimport {gfmTable} from 'micromark-extension-gfm-table'\nimport {gfmTaskListItem} from 'micromark-extension-gfm-task-list-item'\nimport {combineExtensions} from 'micromark-util-combine-extensions'\n\n// This example combines several GFM syntax extensions into a single extension object\n// suitable for use with micromark. Note that some extensions are functions that need\n// to be called (e.g., gfmStrikethrough()), while others are direct objects.\nconst combinedGfmSyntaxExtension = combineExtensions([\n  gfmAutolinkLiteral,\n  gfmStrikethrough(), // Some extensions are functions that return the actual extension object\n  gfmTable,\n  gfmTaskListItem\n])\n\nconsole.log('Successfully combined GFM syntax extensions for micromark:', combinedGfmSyntaxExtension)\n\n// You would typically pass this combined extension to the micromark parser:\n// import { micromark } from 'micromark';\n// const html = micromark('~Hello~', { extensions: [combinedGfmSyntaxExtension] });\n// console.log(html); // Outputs HTML for strikethrough content, e.g., <p><del>Hello</del></p>","lang":"javascript","description":"Demonstrates how to combine multiple individual micromark syntax extensions into a single extension object using `combineExtensions` for easier management and use with the `micromark` parser."},"warnings":[{"fix":"Migrate your project to use ES modules (`import`) or use a build tool like Rollup or Webpack to handle ESM imports in a CommonJS context.","message":"This package is ESM-only and does not support CommonJS `require()`. Attempting to import it with `require` will result in an error.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure your project explicitly lists `micromark@3` as a dependency or peer dependency and that your installed version matches this requirement.","message":"This utility is designed to work with `micromark@3`. Using it with incompatible major versions of `micromark` (e.g., `micromark@2` or `micromark@4`) may lead to unexpected behavior or type mismatches due to changes in the extension object structure.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Always refer to the documentation for each individual micromark extension to confirm whether it needs to be called as a function or passed directly as an object.","message":"Some micromark extensions are exported as functions that need to be called (e.g., `gfmStrikethrough()`), while others are direct objects (e.g., `gfmAutolinkLiteral`). Not calling the function for extensions that expect it will result in an invalid extension being passed to `combineExtensions`.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change your import statement to `import { combineExtensions } from 'micromark-util-combine-extensions'`.","cause":"Attempting to import `micromark-util-combine-extensions` using CommonJS `require()` syntax in a Node.js environment.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure your build configuration correctly handles ESM modules. Verify that you are using a named import `import { combineExtensions }` and not a default import `import combineExtensions`.","cause":"This error often occurs when bundling (e.g., with Webpack) and attempting to use a CommonJS-style import on an ESM module, or when a named import is incorrectly treated as a default import.","error":"TypeError: (0 , micromark_util_combine_extensions__WEBPACK_IMPORTED_MODULE_0__.combineExtensions) is not a function"},{"fix":"Call the extension as a function: `gfmStrikethrough()` instead of `gfmStrikethrough` when adding it to the array for `combineExtensions`.","cause":"An extension function (like `gfmStrikethrough`) was expected to be called to produce an extension object, but it was passed directly without invocation.","error":"TypeError: micromark_extension_gfm_strikethrough_1.gfmStrikethrough is not a function"}],"ecosystem":"npm"}