Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Request: build & publish cjs bundle #307

Closed
1 task done
aladdin-add opened this issue Dec 5, 2024 · 5 comments
Closed
1 task done

Change Request: build & publish cjs bundle #307

aladdin-add opened this issue Dec 5, 2024 · 5 comments

Comments

@aladdin-add
Copy link
Member

aladdin-add commented Dec 5, 2024

Environment

ESLint version: v9.16.0
@eslint/markdown version: v6.2.1
Node version: v22.11.0
npm version: n/a
Operating System: n/a

What problem do you want to solve?

This package only published esm, no cjs.
Image

For projects with pkg.type = "commonjs" (the node.js default) (e.g. eslint/eslint), it's not possible to use it in eslint.config.js.

const markdown = require("@eslint/markdown"); // ❌Error! 

the workaround is to convert the config file to eslint.config.mjs.

What do you think is the correct solution?

add rollup config to build cjs, and publish it to npm.

Participation

  • I am willing to submit a pull request for this change.

Additional comments

Technically, it's a feature request; not a bug - as the docs only mentioned the esm usage.

Rationality: @eslint/json has also published cjs
Image

@eslintbot eslintbot added this to Triage Dec 5, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Dec 5, 2024
@aladdin-add aladdin-add moved this from Needs Triage to Feedback Needed in Triage Dec 5, 2024
@fasttime
Copy link
Member

fasttime commented Dec 5, 2024

Makes sense to me 👍

@nzakas
Copy link
Member

nzakas commented Dec 5, 2024

This isn't possible because mdast-util-from-markdown is ESM-only. It doesn't bundle correctly.

@nzakas nzakas closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2024
@github-project-automation github-project-automation bot moved this from Feedback Needed to Complete in Triage Dec 5, 2024
@fasttime
Copy link
Member

fasttime commented Dec 6, 2024

This isn't possible because mdast-util-from-markdown is ESM-only. It doesn't bundle correctly.

That's too bad. It's another reason for supporting async parsers.

@nzakas
Copy link
Member

nzakas commented Dec 6, 2024

Yeah, although honestly, I think we're at the point where CommonJS just isn't that important anymore. Especially with Node v22 allowing require(esm), we're moving further away from it being useful to export a separate CommonJS entrypoint.

@fasttime
Copy link
Member

fasttime commented Dec 6, 2024

Yeah, although honestly, I think we're at the point where CommonJS just isn't that important anymore. Especially with Node v22 allowing require(esm), we're moving further away from it being useful to export a separate CommonJS entrypoint.

It's true, require("@eslint/markdown") works in a CommonJS config file in Node.js 22.12.0:

const { default: markdown } = require("@eslint/markdown");

module.exports = [
    ...markdown.configs.recommended
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants