markedjs/marked-gfm-heading-id

Importing into a non-ESM Node.js environment throws an error.

NotTimTam opened this issue ยท 2 comments

Like the title says, importing into a non-ESM node module causes an error.

Here is my code:

const { marked } = require("marked");
const { gfmHeadingId } = require("marked-gfm-heading-id");

marked.use(
	{
		langPrefix: "",
		mangle: false,
		headerIds: false,
	},
	gfmHeadingId()
);

// ...

const convertedData = marked.parse(existingData);

Here is the output at runtime:

D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs:3
var GithubSlugger = require('github-slugger');     
                    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module D:\Code\extrusive-test-env\extrusive.md\node_modules\github-slugger\index.js from D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs not supported.
Instead change the require of index.js in D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs to a dynamic import() which is available in all CommonJS modules.        
    at Object.<anonymous> (D:\Code\extrusive-test-env\extrusive.md\node_modules\marked-gfm-heading-id\lib\index.cjs:3:21)
    at Object.<anonymous> (D:\Code\extrusive-test-env\extrusive.md\resources\scripts\build_app.js:6:26)
    at Object.<anonymous> (D:\Code\extrusive-test-env\extrusive.md\index.js:6:19) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.16.0

Let me know if you need more information.

๐ŸŽ‰ This issue has been resolved in version 3.0.2 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

Thanks for reporting this! ๐Ÿ’ฏ