Support ESM config file
See original GitHub issue📚 Documentation
Remark and Rehype are ES6 Modules only now and the documentation imports them as CommonJS modules.
Page that that does work as described: https://docusaurus.io/docs/next/markdown-features/plugins
The documentation just says to install those packages
yarn add remark-images
and import them as
const remarkImages = require('remark-images');`
The remark-images package is ESM only and is not able to be required. The docusaurus.config.js is a CJS module and can’t include that package.
If it is just an older version of those plugins need to be specified, then that makes sense, but might be nice to have in the docs.
Edit: added more details
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10
Top Results From Across the Web
Support for ESM config files (with "type": "module") · Issue #3677
I'm wondering if there would be interest in supporting ESM config files in addition to CJS (and the other currently supported flavors).
Read more >Support ESM in next.config.js - Stack Overflow
1 Answer 1 · 3. having next.config.mjs and type: 'module' in package.json results in error: require() of ES Module /usr/app/.next/server/pages/_ ...
Read more >ESM Support | ts-jest - GitHub Pages
ESM Support. To use ts-jest with ESM support: Check ESM Jest documentation. Enable useESM true for ts-jest config.
Read more >rollup.js
Rollup can be used either through a command line interface with an optional configuration file, or else through its JavaScript API. Run rollup...
Read more >Change ESM Configuration File Options - TechDocs
Use this procedure to change ESM configuration file options. The options appear together toward the end of the installed common ESM configuration file....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

After #5812, we are in a good position to consider how we are going to support ESM in our code base.
TypeScript 4.5 is also focusing on prioritizing ESM support, so maybe we can wait till its stable release to test out how that can aid us in the migration.
@lukejgaskell I don’t know if the doc’s wrong in this sense, but at least here we did explicitly state the version: https://docusaurus.io/docs/next/markdown-features/math-equations#configuration. I guess it makes sense to update the doc section you mentioned and explicitly warn that the version matters.
For your question—https://github.com/remarkjs/remark-images/releases/tag/3.0.0
remark-imagesbecame ESM inv3, so you can use^2.0.0in yourpackage.jsonfor now.