You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced-features/compiler.md
+83Lines changed: 83 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -233,6 +233,89 @@ module.exports = {
233
233
234
234
If you have feedback about `swcMinify`, please share it on the [feedback discussion](https://github.com/vercel/next.js/discussions/30237).
235
235
236
+
### Modularize Imports
237
+
238
+
Allows to modularize imports, similar to [babel-plugin-transform-imports](https://www.npmjs.com/package/babel-plugin-transform-imports).
Similar to `babel-plugin-transform-imports`, but the transform is templated with [handlebars](https://docs.rs/handlebars) and regular expressions are in Rust [regex](https://docs.rs/regex/latest/regex/) crate's syntax.
This transform uses [handlebars](https://docs.rs/handlebars) to template the replacement import path in the `transform` field. These variables and helper functions are available:
314
+
315
+
1.`matches`: Has type `string[]`. All groups matched by the regular expression. `matches.[0]` is the full match.
316
+
2.`member`: Has type `string`. The name of the member import.
317
+
3.`lowerCase`, `upperCase`, `camelCase`: Helper functions to convert a string to lower, upper or camel cases.
318
+
236
319
## Unsupported Features
237
320
238
321
When your application has a `.babelrc` file, Next.js will automatically fall back to using Babel for transforming individual files. This ensures backwards compatibility with existing applications that leverage custom Babel plugins.
This example shows how to use the `modularizeImports` config option.
4
+
5
+
## Preview
6
+
7
+
Preview the example live on [StackBlitz](http://stackblitz.com/):
8
+
9
+
[](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/modularize-imports)
10
+
11
+
## Deploy your own
12
+
13
+
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
14
+
15
+
[](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/modularize-imports&project-name=modularize-imports&repository-name=modularize-imports)
16
+
17
+
## How to use
18
+
19
+
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
0 commit comments