From f0aa10b2165e661c6ed2494787eab31891115065 Mon Sep 17 00:00:00 2001 From: Shu Uesugi Date: Fri, 23 Dec 2022 12:46:18 -0800 Subject: [PATCH] Remove experimental for modularizeImports from docs and example (#44311) When `modularizeImports` was moved out of experiimental [on this PR](https://github.com/vercel/next.js/pull/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) --- docs/advanced-features/compiler.md | 71 +++++++++++----------- examples/modularize-imports/next.config.js | 8 +-- 2 files changed, 37 insertions(+), 42 deletions(-) diff --git a/docs/advanced-features/compiler.md b/docs/advanced-features/compiler.md index ce0a8ebc66386..062e6d401615c 100644 --- a/docs/advanced-features/compiler.md +++ b/docs/advanced-features/compiler.md @@ -9,6 +9,7 @@ description: Learn about the Next.js Compiler, written in Rust, which transforms | Version | Changes | | --------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| `v13.1.0` | Modularize Imports [stable](https://nextjs.org/blog/next-13-1#import-resolution-for-smaller-bundles). | | `v13.0.0` | SWC Minifier enabled by default. | | `v12.3.0` | SWC Minifier [stable](https://nextjs.org/blog/next-12-3#swc-minifier-stable). | | `v12.2.0` | [SWC Plugins](#swc-plugins-Experimental) experimental support added. | @@ -264,30 +265,6 @@ module.exports = { } ``` -## Experimental Features - -### Minifier debug options - -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. - -```js -// next.config.js - -module.exports = { - experimental: { - swcMinifyDebugOptions: { - compress: { - defaults: true, - side_effects: false, - }, - }, - }, -} -``` - -If your app works with the options above, it means `side_effects` is the problematic option. -See [the SWC documentation](https://swc.rs/docs/configuration/minification#jscminifycompress) for detailed options. - ### Modularize Imports 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: ```js // next.config.js module.exports = { - experimental: { - modularizeImports: { - 'react-bootstrap': { - transform: 'react-bootstrap/lib/{{member}}', - }, - lodash: { - transform: 'lodash/{{member}}', - }, + modularizeImports: { + 'react-bootstrap': { + transform: 'react-bootstrap/lib/{{member}}', + }, + lodash: { + transform: 'lodash/{{member}}', }, }, } @@ -336,11 +311,9 @@ The config: ```js // next.config.js module.exports = { - experimental: { - modularizeImports: { - 'my-library/?(((\\w*)?/?)*)': { - transform: 'my-library/{{ matches.[1] }}/{{member}}', - }, + modularizeImports: { + 'my-library/?(((\\w*)?/?)*)': { + transform: 'my-library/{{ matches.[1] }}/{{member}}', }, }, } @@ -371,6 +344,30 @@ This transform uses [handlebars](https://docs.rs/handlebars) to template the rep 2. `member`: Has type `string`. The name of the member import. 3. `lowerCase`, `upperCase`, `camelCase`, `kebabCase`: Helper functions to convert a string to lower, upper, camel or kebab cases. +## Experimental Features + +### Minifier debug options + +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. + +```js +// next.config.js + +module.exports = { + experimental: { + swcMinifyDebugOptions: { + compress: { + defaults: true, + side_effects: false, + }, + }, + }, +} +``` + +If your app works with the options above, it means `side_effects` is the problematic option. +See [the SWC documentation](https://swc.rs/docs/configuration/minification#jscminifycompress) for detailed options. + ### SWC Trace profiling 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=). diff --git a/examples/modularize-imports/next.config.js b/examples/modularize-imports/next.config.js index 11c2a73e74134..e866dc917e361 100644 --- a/examples/modularize-imports/next.config.js +++ b/examples/modularize-imports/next.config.js @@ -4,11 +4,9 @@ * @type {import('next').NextConfig} **/ const nextConfig = { - experimental: { - modularizeImports: { - '../components/halves': { - transform: '../components/halves/{{ member }}', - }, + modularizeImports: { + '../components/halves': { + transform: '../components/halves/{{ member }}', }, }, }