Skip to content

fix: ESM conversion part 1#4966

Draft
nicolethoen wants to merge 5 commits intopatternfly:mainfrom
nicolethoen:esm-conversion
Draft

fix: ESM conversion part 1#4966
nicolethoen wants to merge 5 commits intopatternfly:mainfrom
nicolethoen:esm-conversion

Conversation

@nicolethoen
Copy link
Collaborator

Closes: #4961

Removes all deprecated API usage and private/internal imports from the unified/remark ecosystem in the
documentation-framework build scripts. This makes the code resilient to patch/minor version changes and is a
prerequisite for eventually upgrading to the latest ESM-only versions of these packages.

Changes

Phase 1: Replace deprecated remark plugin APIs

  • remove-comments.js — Replaced deprecated this.Parser.prototype.blockTokenizers + eat() API with a self.parse wrapper
    that strips HTML comments from raw markdown before parsing
  • auto-link-url.js — Replaced deprecated this.Parser.prototype.inlineTokenizers + eat() API with a self.parse wrapper
    that converts https://... autolinks to standard markdown link syntax

Phase 2: Inline private API imports

  • mdx-hast-to-jsx.js — Inlined 5 private APIs: serializeTags and serializeMdxExpression from remark-mdx/lib/serialize/,
    indentStr from remark-mdx/lib/util/, toTemplateLiteral from @mdx-js/util, and replaced hast-to-hyperscript +
    fakeReactCreateElement with a simple hastToProps function
  • mdx-ast-to-mdx-hast.js — Inlined all and one from mdast-util-to-hast/lib/all (private subpath)
  • Removed @mdx-js/util and hast-to-hyperscript from package.json since they are no longer imported

Validation

All 230 markdown files in the documentation-site processed successfully with zero diff in generated output.

Future work

These changes are a prerequisite for upgrading the unified/remark ecosystem to the latest ESM-only versions (unified
v11, remark-parse v11, remark-mdx v3, etc.). That upgrade is a larger coordinated effort requiring ESM conversion of the
build scripts and AST node type updates.

nicolethoen and others added 5 commits March 11, 2026 10:59
…e wrapper

Replace this.Parser.prototype.blockTokenizers/eat() approach with a
self.parse wrapper that strips HTML comments from raw vfile contents
before parsing. Compatible with both unified v9 (current) and v11 (target).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…wrapper

Replace this.Parser.prototype.inlineTokenizers/eat() approach with a
self.parse wrapper that converts <https://...> autolinks to standard
[url](url) markdown syntax before parsing. This prevents remark-mdx
from interpreting autolinks as JSX elements.

Compatible with both unified v9 (current) and v11 (target).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… APIs

Replace private imports from remark-mdx/lib/serialize/ and @mdx-js/util
with inlined equivalents:
- serializeTags (from remark-mdx/lib/serialize/mdx-element)
- serializeMdxExpression (from remark-mdx/lib/serialize/mdx-expression)
- toTemplateLiteral (from @mdx-js/util)
- hastToProps replaces hast-to-hyperscript + fakeReactCreateElement

Generated output is identical. Removes dependencies on private internal
APIs that won't exist in newer remark-mdx versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…all API

Replace `require('mdast-util-to-hast/lib/all')` with inlined `all` and
`one` functions. This removes the last private API import, making the
code resilient to internal restructuring in newer mdast-util-to-hast
versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove @mdx-js/util and hast-to-hyperscript since their functionality
was inlined in the previous commits. These packages are no longer
imported anywhere.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[docs-framework] Rewrite custom remark plugins & Fix private API dependencies

1 participant