{"id":11282,"library":"mdast-squeeze-paragraphs","title":"mdast Paragraph Squeezer","description":"mdast-squeeze-paragraphs is a focused utility within the unified ecosystem, specifically designed to remove empty paragraphs from an mdast (Markdown Abstract Syntax Tree) tree. It identifies and eliminates paragraphs that contain no non-whitespace characters, often a result of previous tree transformations. The current stable version is 6.0.0. Releases are typically tied to Node.js LTS cycles, with new major versions dropping support for unmaintained Node.js versions. A key differentiator and notable recommendation from its maintainers is that developers should 'probably never!' use this package directly, encouraging users to clean their trees themselves or use the higher-level `remark-squeeze-paragraphs` plugin instead. This package is primarily intended for authors of other mdast utilities or plugins who need fine-grained control over tree sanitation at a low level.","status":"active","version":"6.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/mdast-squeeze-paragraphs","tags":["javascript","unist","mdast","mdast-util","util","utility","squeeze","remove","empty","typescript"],"install":[{"cmd":"npm install mdast-squeeze-paragraphs","lang":"bash","label":"npm"},{"cmd":"yarn add mdast-squeeze-paragraphs","lang":"bash","label":"yarn"},{"cmd":"pnpm add mdast-squeeze-paragraphs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is ESM-only since v5.0.0 and requires Node.js 16+ since v6.0.0. CommonJS `require` is not supported. There is no default export.","wrong":"const squeezeParagraphs = require('mdast-squeeze-paragraphs')","symbol":"squeezeParagraphs","correct":"import { squeezeParagraphs } from 'mdast-squeeze-paragraphs'"},{"note":"For Deno or browser environments, import directly from `esm.sh` specifying the major version.","symbol":"squeezeParagraphs","correct":"import { squeezeParagraphs } from 'https://esm.sh/mdast-squeeze-paragraphs@6'"},{"note":"While valid ESM, you would then access the function as `mod.squeezeParagraphs`. There is no default export, so `import mod` will fail.","wrong":"import mod from 'mdast-squeeze-paragraphs'","symbol":"Wildcard import","correct":"import * as mod from 'mdast-squeeze-paragraphs'"}],"quickstart":{"code":"import {squeezeParagraphs} from 'mdast-squeeze-paragraphs';\nimport {u} from 'unist-builder';\n\nconst tree = u('root', [\n  u('paragraph', []),\n  u('paragraph', [u('text', 'Alpha')]),\n  u('paragraph', [u('text', ' ')])\n]);\n\nsqueezeParagraphs(tree);\n\nconsole.dir(tree, {depth: null});\n// Expected output:\n// { type: 'root',\n//   children:\n//    [ { type: 'paragraph',\n//        children: [ { type: 'text', value: 'Alpha' } ] } ] }","lang":"typescript","description":"Demonstrates how to import and use `squeezeParagraphs` to remove empty paragraphs from an mdast tree created with `unist-builder`."},"warnings":[{"fix":"Ensure your Node.js environment is updated to version 16 or higher to use `mdast-squeeze-paragraphs@6`.","message":"Version 6.0.0 changes Node.js compatibility, now requiring Node.js 16 or later.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Migrate your import statements from CommonJS `require()` to ESM `import` syntax. Configure your project to support ESM.","message":"The package transitioned to ESM-only starting from version 5.0.0, removing CommonJS support.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Ensure your build tooling and Node.js version are recent enough to correctly resolve packages using `export` maps. Avoid using private APIs.","message":"Version 6.0.0 introduced the use of an `export` map, which might affect module resolution in some environments or older tooling.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update any code that expects a return value from `squeezeParagraphs` to account for `undefined`. The function modifies the tree in place.","message":"The `squeezeParagraphs` function in version 6.0.0 now explicitly returns `undefined`.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update your project's `@types/mdast` dependency to a compatible version (e.g., `^4.0.0`) if necessary.","message":"Version 6.0.0 updates its dependency on `@types/mdast`, which might require you to update your own `@types/mdast` version if you encounter type conflicts.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Review `unist-util-remove` changelogs for breaking changes if encountering issues after upgrading `mdast-squeeze-paragraphs` to v4.0.0, especially in TypeScript projects.","message":"Version 4.0.0 updated `unist-util-remove`, which could potentially introduce breaking changes if your project or its dependents rely on specific internal types or behaviors of `unist-util-remove`.","severity":"breaking","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Consider if `remark-squeeze-paragraphs` or a custom tree transformation better suits your needs before integrating this low-level utility directly.","message":"The maintainers advise against direct use of `mdast-squeeze-paragraphs` in most application code, recommending higher-level plugins like `remark-squeeze-paragraphs` or manual tree cleaning instead.","severity":"gotcha","affected_versions":"always"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Convert your import statements to ESM `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';` and ensure your project is configured for ESM.","cause":"Attempting to use CommonJS `require()` with an ESM-only package.","error":"TypeError: require is not a function"},{"fix":"Upgrade your Node.js environment to version 16 or higher to meet the package's minimum requirement.","cause":"Running the package on an unsupported Node.js version (older than 16).","error":"Error: 'mdast-squeeze-paragraphs' requires Node.js 16 or later."},{"fix":"Set your TypeScript `tsconfig.json` `compilerOptions.module` to `ESNext` or `NodeNext` and `compilerOptions.moduleResolution` to `NodeNext` for better ESM interoperability. Alternatively, use dynamic `import()` for ESM packages in CJS projects.","cause":"Incorrect module resolution or transpilation in TypeScript projects targeting CommonJS that try to import an ESM package.","error":"TypeError: (0 , mdast_squeeze_paragraphs_1.squeezeParagraphs) is not a function"},{"fix":"Ensure you are using a named import correctly: `import { squeezeParagraphs } from 'mdast-squeeze-paragraphs';`.","cause":"Attempting to call `mod.squeezeParagraphs` after `import mod from 'mdast-squeeze-paragraphs'` or when `squeezeParagraphs` is not correctly destructured.","error":"TypeError: squeezeParagraphs is not a function (when using a wildcard or default import)"}],"ecosystem":"npm"}