Unverified Commit ab62a13d authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

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`
parent 4fc19792
...@@ -94,6 +94,34 @@ const customJestConfig = { ...@@ -94,6 +94,34 @@ const customJestConfig = {
module.exports = createJestConfig(customJestConfig) module.exports = createJestConfig(customJestConfig)
``` ```
### Remove React Properties
Allows to remove JSX properties. This is often used for testing. Similar to `babel-plugin-react-remove-properties`.
To remove properties matching the default regex `^data-test`:
```js
// next.config.js
module.exports = {
experimental: {
reactRemoveProperties: true,
},
}
```
To remove custom properties:
```js
// next.config.js
module.exports = {
experimental: {
// The regexes defined here are processed in Rust so the syntax is different from
// JavaScript `RegExp`s. See https://docs.rs/regex.
reactRemoveProperties: { properties: ['^data-custom$'] },
},
}
```
### Legacy Decorators ### Legacy Decorators
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`. 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, ...@@ -110,6 +138,34 @@ First, update to the latest version of Next.js: `npm install next@latest`. Then,
} }
``` ```
### Remove Console
This transform allows for removing all `console.*` calls in application code (not `node_modules`). Similar to `babel-plugin-transform-remove-console`.
Remove all `console.*` calls:
```js
// next.config.js
module.exports = {
experimental: {
removeConsole: true,
},
}
```
Remove `console.*` output except `console.error`:
```js
// next.config.js
module.exports = {
experimental: {
removeConsole: {
exclude: ['error'],
},
},
}
```
### importSource ### importSource
Next.js will automatically detect `jsxImportSource` in `jsconfig.json` or `tsconfig.json` and apply that. This is commonly used with libraries like Theme UI. Next.js will automatically detect `jsxImportSource` in `jsconfig.json` or `tsconfig.json` and apply that. This is commonly used with libraries like Theme UI.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment