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

feat: add ESM export #5221

Closed
wants to merge 2 commits into from
Closed

feat: add ESM export #5221

wants to merge 2 commits into from

Conversation

brettz9
Copy link

@brettz9 brettz9 commented Oct 8, 2024

PR Checklist

Overview

Adds an ESM export through a new mocha.mjs file (making the regular file to be ESM would be a breaking change). It is not entirely modular, as the base script still sets a global Mocha and mocha, but it does export mocha.

@brettz9 brettz9 changed the title feat: add ESM export; fixes #5211 feat: add ESM export Oct 8, 2024
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sending this! Let's talk about the direction?

@@ -4,6 +4,9 @@ docs/images/supporters
docs/api
mocha.js
mocha.js.map
esm/mocha.js
esm/mocha.js.map
esm/package.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh 😬 I didn't think adding support for ESM would require an entirely new output file. This file is pretty huge: 600k+ characters, 620K on disk. We can't add such a large addition to package size for all users.

I had assumed the entry point would be a minimal shim, i.e.:

import "./mocha.js"

const { mocha } = globalThis;

const describe = mocha.describe.bind(mocha);
const it = mocha.it.bind(mocha);
const setup = mocha.setup.bind(mocha);

export { describe, it, setup };

Is that not doable for some reason?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I'm unfortunately dealing with some health problems, so I think I will just nix this PR.

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author waiting on response from OP - more information needed label Oct 30, 2024
@brettz9 brettz9 closed this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author waiting on response from OP - more information needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 Feature: Ability to import mocha from ESM in the browser
2 participants