Skip to content

Commit ab62a13

Browse files
authored
Add sections for Remove React Properties and Remove Console to compiler docs (#33311)
Adds docs for some experimental flags that were already shipped to stable. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
1 parent 4fc1979 commit ab62a13

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/advanced-features/compiler.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,34 @@ const customJestConfig = {
9494
module.exports = createJestConfig(customJestConfig)
9595
```
9696

97+
### Remove React Properties
98+
99+
Allows to remove JSX properties. This is often used for testing. Similar to `babel-plugin-react-remove-properties`.
100+
101+
To remove properties matching the default regex `^data-test`:
102+
103+
```js
104+
// next.config.js
105+
module.exports = {
106+
experimental: {
107+
reactRemoveProperties: true,
108+
},
109+
}
110+
```
111+
112+
To remove custom properties:
113+
114+
```js
115+
// next.config.js
116+
module.exports = {
117+
experimental: {
118+
// The regexes defined here are processed in Rust so the syntax is different from
119+
// JavaScript `RegExp`s. See https://docs.rs/regex.
120+
reactRemoveProperties: { properties: ['^data-custom$'] },
121+
},
122+
}
123+
```
124+
97125
### Legacy Decorators
98126

99127
Next.js will automatically detect `experimentalDecorators` in `jsconfig.json` or `tsconfig.json` and apply that. This is commonly used with older versions of libraries like `mobx`.
@@ -110,6 +138,34 @@ First, update to the latest version of Next.js: `npm install next@latest`. Then,
110138
}
111139
```
112140

141+
### Remove Console
142+
143+
This transform allows for removing all `console.*` calls in application code (not `node_modules`). Similar to `babel-plugin-transform-remove-console`.
144+
145+
Remove all `console.*` calls:
146+
147+
```js
148+
// next.config.js
149+
module.exports = {
150+
experimental: {
151+
removeConsole: true,
152+
},
153+
}
154+
```
155+
156+
Remove `console.*` output except `console.error`:
157+
158+
```js
159+
// next.config.js
160+
module.exports = {
161+
experimental: {
162+
removeConsole: {
163+
exclude: ['error'],
164+
},
165+
},
166+
}
167+
```
168+
113169
### importSource
114170

115171
Next.js will automatically detect `jsxImportSource` in `jsconfig.json` or `tsconfig.json` and apply that. This is commonly used with libraries like Theme UI.

0 commit comments

Comments
 (0)