-
-
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
Changes from all commits
341f941
ee2034d
269c63b
4e727cc
550cecc
5d18950
a19c96e
e3c1ea4
fe11a1b
aca8723
1e74cf1
f81b7ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,11 @@ $ yarn add pretty-format | |
## Usage | ||
|
||
```js | ||
const prettyFormat = require('pretty-format'); // CommonJS | ||
const {format: prettyFormat} = require('pretty-format'); // CommonJS | ||
``` | ||
|
||
```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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I'd go with just There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
``` | ||
|
||
```js | ||
|
@@ -102,17 +102,18 @@ The `pretty-format` package provides some built-in plugins, including: | |
// CommonJS | ||
const React = require('react'); | ||
const renderer = require('react-test-renderer'); | ||
const prettyFormat = require('pretty-format'); | ||
const ReactElement = prettyFormat.plugins.ReactElement; | ||
const ReactTestComponent = prettyFormat.plugins.ReactTestComponent; | ||
const {format: prettyFormat, plugins} = require('pretty-format'); | ||
|
||
const {ReactElement, ReactTestComponent} = plugins; | ||
``` | ||
|
||
```js | ||
// ES2015 modules and destructuring assignment | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
// ES2015 modules and destructuring assignment | ||
import prettyFormat from 'pretty-format'; | ||
const {ReactElement, ReactTestComponent} = prettyFormat.plugins; | ||
import {plugins, format as prettyFormat} from 'pretty-format'; | ||
|
||
const {ReactElement, ReactTestComponent} = plugins; | ||
``` | ||
|
||
```js | ||
|
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