Bring back cjs support
As part of v16 : https://github.com/markedjs/marked/pull/3687 the support of cjs files was removed.
Can I ask to bring it back?
I do not see any mis advantage in doing so, just supporting more projects like mine. I have not migrated to esm just yet, I am using node20+.
But currently I cannot use marked without async import which is not the best way to go for me.
I've created a fork for now
npm info marked-cjs
[email protected] | MIT | deps: none | versions: 1
A markdown parser built for speed
https://marked.js.org
keywords: markdown, markup, html
bin: marked
dist
.tarball: https://registry.npmjs.org/marked-cjs/-/marked-cjs-17.0.3.tgz
.shasum: eb4dfda462a271c3ef89b1d9512e73c18cb32919
.integrity: sha512-VNOw/BBFMbHmohsG/+gk1c6aIzy/c3lMlVFs+IlMUKOcebMzOaycvvKAsuxR3+0TljveTyUXKYkeQU/F4ZwSNw==
.unpackedSize: 626.1 kB
dist-tags:
latest: 17.0.3
Node 20+ is able to load esm with require('marked') so there would be no benefit to using cjs
see https://nodejs.org/docs/latest/api/modules.html#loading-ecmascript-modules-using-require
Hey @UziTech , thanks I've read that as they were clearly mentioned in the docs,
Yet it does not solve the problem in case you want to support server side rendering + client hydartion.
So indeed during ssr require('marked') works. yet for the client it does not, then it requires to do conditional import depends on the client / server side and still forcing the await import..
require('marked') does not work on client side anyway. Browsers don't have a require function.
If you are using a framework that does bundling and hydration your should create an issue with them to support require with esm like node.