Skip to content

Add sections for Remove React Properties and Remove Console to compiler docs #33311

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

Merged
merged 2 commits into from
Jan 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions docs/advanced-features/compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,34 @@ const 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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows [Next.js] to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This transform allows" to follow on the one below it?


To remove properties matching the default regex `^data-test`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, to remove...


```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

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`.
Expand All @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, to remove...


```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

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