Skip to content

Commit f0aa10b

Browse files
authored
Remove experimental for modularizeImports from docs and example (#44311)
When `modularizeImports` was moved out of experiimental [on this PR](#44240), `docs` and `examples` were not updated. - Update `modularize-imports` example by removing `experimental` from `next.config.js`, as it's currently failing when deployed - For docs: https://nextjs.org/docs/advanced-features/compiler#modularize-imports - Move `Modularize Imports` section outside of `Experimental Features` section - Remove `experimental` from code snippets - Added to version history, just like when SWC Minifier became stable. ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm build && pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 44548dd commit f0aa10b

File tree

2 files changed

+37
-42
lines changed

2 files changed

+37
-42
lines changed

docs/advanced-features/compiler.md

+34-37
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description: Learn about the Next.js Compiler, written in Rust, which transforms
99

1010
| Version | Changes |
1111
| --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
12+
| `v13.1.0` | Modularize Imports [stable](https://nextjs.org/blog/next-13-1#import-resolution-for-smaller-bundles). |
1213
| `v13.0.0` | SWC Minifier enabled by default. |
1314
| `v12.3.0` | SWC Minifier [stable](https://nextjs.org/blog/next-12-3#swc-minifier-stable). |
1415
| `v12.2.0` | [SWC Plugins](#swc-plugins-Experimental) experimental support added. |
@@ -264,30 +265,6 @@ module.exports = {
264265
}
265266
```
266267

267-
## Experimental Features
268-
269-
### Minifier debug options
270-
271-
While the minifier is experimental, we are making the following options available for debugging purposes. They will not be available once the minifier is made stable.
272-
273-
```js
274-
// next.config.js
275-
276-
module.exports = {
277-
experimental: {
278-
swcMinifyDebugOptions: {
279-
compress: {
280-
defaults: true,
281-
side_effects: false,
282-
},
283-
},
284-
},
285-
}
286-
```
287-
288-
If your app works with the options above, it means `side_effects` is the problematic option.
289-
See [the SWC documentation](https://swc.rs/docs/configuration/minification#jscminifycompress) for detailed options.
290-
291268
### Modularize Imports
292269

293270
Allows to modularize imports, similar to [babel-plugin-transform-imports](https://www.npmjs.com/package/babel-plugin-transform-imports).
@@ -312,14 +289,12 @@ Config for the above transform:
312289
```js
313290
// next.config.js
314291
module.exports = {
315-
experimental: {
316-
modularizeImports: {
317-
'react-bootstrap': {
318-
transform: 'react-bootstrap/lib/{{member}}',
319-
},
320-
lodash: {
321-
transform: 'lodash/{{member}}',
322-
},
292+
modularizeImports: {
293+
'react-bootstrap': {
294+
transform: 'react-bootstrap/lib/{{member}}',
295+
},
296+
lodash: {
297+
transform: 'lodash/{{member}}',
323298
},
324299
},
325300
}
@@ -336,11 +311,9 @@ The config:
336311
```js
337312
// next.config.js
338313
module.exports = {
339-
experimental: {
340-
modularizeImports: {
341-
'my-library/?(((\\w*)?/?)*)': {
342-
transform: 'my-library/{{ matches.[1] }}/{{member}}',
343-
},
314+
modularizeImports: {
315+
'my-library/?(((\\w*)?/?)*)': {
316+
transform: 'my-library/{{ matches.[1] }}/{{member}}',
344317
},
345318
},
346319
}
@@ -371,6 +344,30 @@ This transform uses [handlebars](https://docs.rs/handlebars) to template the rep
371344
2. `member`: Has type `string`. The name of the member import.
372345
3. `lowerCase`, `upperCase`, `camelCase`, `kebabCase`: Helper functions to convert a string to lower, upper, camel or kebab cases.
373346

347+
## Experimental Features
348+
349+
### Minifier debug options
350+
351+
While the minifier is experimental, we are making the following options available for debugging purposes. They will not be available once the minifier is made stable.
352+
353+
```js
354+
// next.config.js
355+
356+
module.exports = {
357+
experimental: {
358+
swcMinifyDebugOptions: {
359+
compress: {
360+
defaults: true,
361+
side_effects: false,
362+
},
363+
},
364+
},
365+
}
366+
```
367+
368+
If your app works with the options above, it means `side_effects` is the problematic option.
369+
See [the SWC documentation](https://swc.rs/docs/configuration/minification#jscminifycompress) for detailed options.
370+
374371
### SWC Trace profiling
375372

376373
You can generate SWC's internal transform traces as chromium's [trace event format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview?mode=html#%21=).

examples/modularize-imports/next.config.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
* @type {import('next').NextConfig}
55
**/
66
const nextConfig = {
7-
experimental: {
8-
modularizeImports: {
9-
'../components/halves': {
10-
transform: '../components/halves/{{ member }}',
11-
},
7+
modularizeImports: {
8+
'../components/halves': {
9+
transform: '../components/halves/{{ member }}',
1210
},
1311
},
1412
}

0 commit comments

Comments
 (0)