Skip to content

Version 10.0.0 fails with a [ERR_REQUIRE_ESM] error of the remark-mdx-frontmatter package.  #217

@dwjohnston

Description

@dwjohnston
  • mdx-bundler version: 10.0.0
  • node version: 18.18.2
  • npm version: 9.8.1

Relevant code or config

Not applicable / see repro.

What you did:

I have working code mdx-bundler@9.2.1

When we upgrade to mdx-bundler@10.0.0 it errors.

What happened:


/Users/davidjohnston/git-workspace/example-remix-app/node_modules/mdx-bundler/dist/index.js:11
var _remarkMdxFrontmatter = _interopRequireDefault(require("remark-mdx-frontmatter"));
                                                   ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/davidjohnston/git-workspace/example-remix-app/node_modules/mdx-bundler/node_modules/remark-mdx-frontmatter/index.js from /Users/davidjohnston/git-workspace/example-remix-app/node_modules/mdx-bundler/dist/index.js not supported.
Instead change the require of /Users/davidjohnston/git-workspace/example-remix-app/node_modules/mdx-bundler/node_modules/remark-mdx-frontmatter/index.js in /Users/davidjohnston/git-workspace/example-remix-app/node_modules/mdx-bundler/dist/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/davidjohnston/git-workspace/example-remix-app/node_modules/mdx-bundler/dist/index.js:11:52)

Reproduction repository:

This commit has a basic Remix@1.9.3 application with mdx-bundler@9.2.1 working.

dwjohnston/example-remix-app@193bd84

Run

npm i 
npm run dev

Navigate to any of the links to see some MDX being rendered fine.

This commit dwjohnston/example-remix-app@359efc5

Just upgrades mdx-bundler to 10.0.0.

When we run npm run dev we now get the [ERR_REQUIRE_ESM].

Problem description:

The problem appears to be that remark-mdx-frontmatter@4.0.0 publishes its packages as an ESM module and mdx-bundler@10 still requires this.

Suggested solution:

Not sure. Is this actually a bug with remark-mdx-frontmatter@4.0.0?

Workaround

Downgrade to 9.2.1

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