Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dwjohnston opened this issue Nov 17, 2023 · 1 comment

Comments

@dwjohnston
Copy link

dwjohnston commented Nov 17, 2023

  • 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

@dwjohnston dwjohnston changed the title Version 10.0.0 Version 10.0.0 fails with a [ERR_REQUIRE_ESM] error of the remark-mdx-frontmatter package. Nov 17, 2023
@CottonCandyZ
Copy link
Contributor

10.0.1 fix it. 92d09f7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants