Skip to content

require() in ESM module breaks in strict ESM environments #1

@vdg

Description

@vdg

Description

The library uses require() in src/inline-renderer.ts:89 to avoid circular dependencies:

const { renderBlock } = require('./block-renderer.js');

However, require() is not available in strict ESM environments:

  • Bun
  • Deno
  • Node.js with --experimental-vm-modules
  • Bundlers in strict ESM mode

This causes a ReferenceError: require is not defined when rendering footnotes.

Steps to Reproduce

  1. Use the library in Bun or Deno
  2. Convert a Markdown document containing footnotes
  3. Error is thrown

Expected Behavior

The library should work in all ESM-compatible environments.

Suggested Fix

Replace require() with dependency injection - pass renderBlock through the RenderContext object. This maintains the circular import avoidance while being fully ESM-compatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions