markedjs/marked-extension-template

ESM vs CommonJS Build confusion

calculuschild opened this issue · 1 comments

I'm trying to build an extension using this template, but I don't fully understand all of the changes that came with the recent change to ESM. I'm assuming there's some similar small update that also needs to be carried over to this package, because when I try to build my package I get the following error :

An error occurred while running semantic-release: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/marked-> extended-tables/marked-extended-tables/release.config.js from /home/runner/work/marked-extended-tables/marked-extended-tables/node_modules/cosmiconfig/dist/loaders.js not supported.

release.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.

Instead rename release.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/runner/work/marked-extended-tables/marked-extended-tables/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

Can you recommend the preferred approach here to best follow the format that Marked.js uses?

I fixed it. just change release.config.js to release.config.cjs

Semantic-release doesn't allow esm config files yet.