-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
chore: migrate pretty-format to ESM #10515
Conversation
5a321d0
to
0e91708
Compare
Why not have |
can do a default export, sure. Just as breaking for CJS peeps, but no biggie. Do you want both named and default, or just default? |
Note that today people do import prettyFormat from 'pretty-format';
const plugins = prettyFormat.plugins; That I wanna break regardless. It's so weird that doing this uncovered a bug in |
I'd go with both default and named.
I don't mind breaking this use case, it's wrong usage of ESM and should be fixed anyway. |
Cool! 👍 I'll make the change before landing. No timeline on 27, so I'll just leave this as is for now (unless I get bored (again)) |
0e91708
to
00315b9
Compare
00315b9
to
341f941
Compare
``` | ||
|
||
```js | ||
import prettyFormat from 'pretty-format'; // ES2015 modules | ||
import {format as prettyFormat} from 'pretty-format'; // ES2015 modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm purposefully not using default import here, since real ESM only works with named exports (in node impl) as it's still CJS under the hood
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go with just format
in examples, without aliasing to prettyFormat
. No need for extra mental overhead here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the difference between "copy the example and run it" vs "copy example, but get weird errors". I think it's worth it to keep as is?
@thymikee thoughts on it now? |
import prettyFormat = require('pretty-format'); | ||
import { | ||
Plugin as PrettyFormatPlugin, | ||
Plugins as PrettyFormatPlugins, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use import type
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we import plugins
below, so no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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. |
Summary
Changed export from a "default" (CJS) export to a named function called
format
.We can remove the patch when making a new release (as at that point the version range won't match@testing-library/dom
and it'll pull in a compatible version)Test plan
Green CI