Skip to content
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

[docs] Modularize Imports for Nextjs #35457

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,26 @@ Modify your `package.json` commands:
}
```

If you are using Next.js >= v13.1, you can make use of their [Modularize Imports](https://nextjs.org/docs/advanced-features/compiler#modularize-imports) feature.
This does not require adding Babel configuration, so you can still use [SWC](https://nextjs.org/docs/advanced-features/compiler#why-swc) if you prefer.

Create a `next.config.js` file in the root directory:

```js
/* next.config.js */
/** @type {import('next').NextConfig} */
const nextConfig = {
...
modularizeImports: {
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}'
}
}
}

module.exports = nextConfig
```

Enjoy significantly faster start times.

#### 2. Convert all your imports
Expand Down