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

fix: add ESM exports of all modules manually #14661

Merged
merged 12 commits into from
Oct 30, 2023

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Oct 30, 2023

Summary

This is to work around nodejs/cjs-module-lexer#88. We don't need to rely on a lexer as we can just check our exports at build time and create manual ESM export.

This should avoid the dual package hazard as the wrapper is pretty much their recommendation.

Test plan

Green CI

@netlify
Copy link

netlify bot commented Oct 30, 2023

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 34af7f3
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/653f7827d5e3ae0008df972d
😎 Deploy Preview https://deploy-preview-14661--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -117,17 +132,6 @@ export function getPackages() {
});
}

export function adjustToTerminalWidth(str) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this has been unused since we added the webpack build

scripts/build.mjs Outdated Show resolved Hide resolved
@@ -13,6 +13,8 @@
"exports": {
".": {
"types": "./build/index.d.ts",
"require": "./build/index.js",
Copy link
Member Author

Choose a reason for hiding this comment

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

I've included require here so that bundlers/runtimes who understand both can go straight to it - no need to use the ESM wrapper

@@ -26,6 +25,14 @@ const require = createRequire(import.meta.url);
export const OK = chalk.reset.inverse.bold.green(' DONE ');
export const ERROR = chalk.reset.inverse.bold.red(' BOOM ');

export const typeOnlyPackages = new Set([
'babel-preset-jest',
Copy link
Member Author

Choose a reason for hiding this comment

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

this isn't types only, but there's also no build step 🤷

export default class CustomSequencer extends Sequencer.default {
export default class CustomSequencer extends Sequencer {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is very nice, but also makes it a breaking change for people who have used Jest's modules in native ESM before. Which is probably fine, but we need to call this out in the upgrade guide

@SimenB SimenB enabled auto-merge (squash) October 30, 2023 10:40
@SimenB SimenB merged commit 79a4ff4 into jestjs:main Oct 30, 2023
72 of 73 checks passed
@SimenB SimenB deleted the add-ESM-exports-manually branch October 30, 2023 11:07
@SimenB
Copy link
Member Author

SimenB commented Oct 30, 2023

Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant