Skip to content

Commit 515f851

Browse files
Emilios1995facebook-github-bot
authored andcommitted
Suggest using babel to remove console.* calls
Summary: This PR adds a suggestion to the docs to use the `transform-remove-console` babel plugin in production to remove `console.*` calls. This information was previously in the docs, but was [removed](e759573) because the babel plugin [didn't work](#10412). But now it's working well, as reported [here](#10412 (comment)), so it would be helpful to add the suggestion again. Ideally, this would be done automatically, as I suggested in #8337 Closes #13651 Differential Revision: D4954872 Pulled By: hramos fbshipit-source-id: 89ae1b813c50e678f0826f16ef88c8604e13d889
1 parent f3dbddc commit 515f851

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/Performance.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ This is unavoidable: a lot more work needs to be done at runtime to provide you
7373
When running a bundled app, these statements can cause a big bottleneck in the JavaScript thread.
7474
This includes calls from debugging libraries such as [redux-logger](https://github.com/evgenyrodionov/redux-logger),
7575
so make sure to remove them before bundling.
76+
You can also use this [babel plugin](https://babeljs.io/docs/plugins/transform-remove-console/) that removes all the `console.*` calls. You need to install it first with `npm i babel-plugin-transform-remove-console --save`, and then edit the `.babelrc` file under your project directory like this:
77+
```json
78+
{
79+
"env": {
80+
"production": {
81+
"plugins": ["transform-remove-console"]
82+
}
83+
}
84+
}
85+
```
86+
This will automatically remove all `console.*` calls in the release (production) versions of your project.
7687

7788
### `ListView` initial rendering is too slow or scroll performance is bad for large lists
7889

0 commit comments

Comments
 (0)