Open camcam-lemon opened 2 days ago
I'm for it! Would you like to make a PR?
I'd also be happy to make the PR as well, but if I do make a PR, would you mind if I added a Co-authored-by: camcam-lemon <your-email>
to the commit so you also get credit for the feature (see https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors)
Is your feature request related to a problem? Please describe. The current mermaid-cli uses 'require' to reference package.json.version. When using 'require', module bundlers(e.g. Rollup) fail to parse it, resulting in an error when referencing package.json. So I copy package.json manually every time. Since JSON modules are now stable, I believe it's a good time to update this.
https://nodejs.org/docs/latest/api/esm.html#json-modules
https://github.com/mermaid-js/mermaid-cli/blob/master/src/index.js#L9C1-L12C39
Describe the solution you'd like
Describe alternatives you've considered By using JSON modules, module bundlers can embed the values from package.json into the built source code.
Additional context
This is the source code rewritten with JSON modules and built with Rollup. (it's built to CJS for various reasons) The package.json.cjs has been created.