Skip to content

Commit bc34f21

Browse files
committed
Squashed commit of the following:
commit f16ee05 Author: hiro <[email protected]> Date: Thu Mar 24 10:02:40 2022 +0900 Fix typo in docs (vercel#35561) The following files have been modified. - `docs/api-reference/next.config.js/rewrites.md` - `docs/basic-features/script.md` ## Documentation / Examples - [x] Make sure the linting passes by running `yarn lint` commit ef7b535 Author: Steven <[email protected]> Date: Wed Mar 23 18:33:47 2022 -0400 Fix `next info` accidentally printing stderr (vercel#35556) I noticed a few issues that had "Output from `next info`" with the first line as ``` /bin/sh: pnpm: command not found ``` This was because `execSync()` was still printing to stderr when a command was not found. Changing to `execFileSync()` fixed it so we no longer print to stderr when a command is not found. commit 59905c1 Author: LongYinan <[email protected]> Date: Thu Mar 24 04:47:44 2022 +0800 Fix styled transform in next-swc/emotion (vercel#35527) Fix vercel#35525 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` commit ebe1b4c Author: Shu Ding <[email protected]> Date: Wed Mar 23 20:20:36 2022 +0100 Upgrade react-server-dom-webpack (vercel#35524) There're some changes since our last update that we'll need (e.g. server context). ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` commit 432261a Author: JJ Kasper <[email protected]> Date: Wed Mar 23 13:43:12 2022 -0500 Add link for revalidate from notFound section (vercel#35553) commit 2cf6696 Author: Jiachi Liu <[email protected]> Date: Wed Mar 23 16:19:58 2022 +0100 Merge rsc queries handling (vercel#35545) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> commit 9fef0d5 Author: JJ Kasper <[email protected]> Date: Wed Mar 23 09:28:04 2022 -0500 Normalize ssgCacheKey for /index with minimalMode de-duping (vercel#35536) * Normalize ssgCacheKey for /index * apply test changes to i18n suite as well commit 72478c5 Author: JJ Kasper <[email protected]> Date: Tue Mar 22 13:58:55 2022 -0500 Update next/link error when no children are provided (vercel#35453) * Update next/link error when no children are provided * update manifest * Apply suggestions from code review Co-authored-by: Balázs Orbán <[email protected]> commit 6da7691 Author: Malte Ubl <[email protected]> Date: Tue Mar 22 07:54:05 2022 -0700 Reduce hello-world middleware bundle size from 128k to 88k (vercel#35512) Moves two utility functions from `server/router.ts` into their own file. This avoids the middleware pulling in the full Next.js router into its bundle. There are probably more opportunities like this, but this is a good start. Middleware should likely be bundled by a non-chunking optimizing compiler. commit 860c97c Author: Heyang Zhou <[email protected]> Date: Tue Mar 22 21:20:57 2022 +0800 SWC import modularization plugin (vercel#34969) commit 78831c3 Author: Steven <[email protected]> Date: Tue Mar 22 09:00:31 2022 -0400 v12.1.1-canary.17 commit a2accb2 Author: JJ Kasper <[email protected]> Date: Tue Mar 22 00:03:42 2022 -0500 Update trace ignore check to check reasons correctly (vercel#35511) commit c261924 Author: OJ Kwon <[email protected]> Date: Mon Mar 21 17:09:03 2022 -0700 feat(telemetry): report swc target triple to telemetry (vercel#35420) commit af95b0c Author: Luka Hartwig <[email protected]> Date: Tue Mar 22 00:54:43 2022 +0100 Server component docs use wrong next version (vercel#35313) The docs for the react server components preview refer refer to `next@latest` which doesn't work. The linked demo uses `canary` so I replaced it in the install command. commit 92da36f Author: JJ Kasper <[email protected]> Date: Mon Mar 21 18:33:48 2022 -0500 v12.1.1-canary.16 commit cd47984 Author: Thiago M <[email protected]> Date: Mon Mar 21 14:06:04 2022 -0300 clarify use of Script (vercel#35491) Leave more clear that <Script> component can't be used inside Head. Current it says "without need", which don't implies it can't be used. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [x] Make sure the linting passes by running `yarn lint` commit da3760b Author: JJ Kasper <[email protected]> Date: Mon Mar 21 10:00:07 2022 -0500 Use check on prerender test assertion (vercel#35482) commit 40a5c94 Author: Nelo <[email protected]> Date: Mon Mar 21 15:24:19 2022 +0100 Fix typo in getServerSideProps doc page (vercel#35467) While reading the documentation, I noticed that this paragraph was not correctly written and was hard to read. I fixed it adding a dot. ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
1 parent a9f8ded commit bc34f21

File tree

80 files changed

+2088
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2088
-360
lines changed

docs/advanced-features/compiler.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,89 @@ module.exports = {
233233

234234
If you have feedback about `swcMinify`, please share it on the [feedback discussion](https://github.com/vercel/next.js/discussions/30237).
235235

236+
### Modularize Imports
237+
238+
Allows to modularize imports, similar to [babel-plugin-transform-imports](https://www.npmjs.com/package/babel-plugin-transform-imports).
239+
240+
Transforms member style imports:
241+
242+
```js
243+
import { Row, Grid as MyGrid } from 'react-bootstrap'
244+
import { merge } from 'lodash'
245+
```
246+
247+
...into default style imports:
248+
249+
```js
250+
import Row from 'react-bootstrap/lib/Row'
251+
import MyGrid from 'react-bootstrap/lib/Grid'
252+
import merge from 'lodash/merge'
253+
```
254+
255+
Config for the above transform:
256+
257+
```js
258+
// next.config.js
259+
module.exports = {
260+
experimental: {
261+
modularizeImports: {
262+
'react-bootstrap': {
263+
transform: 'react-bootstrap/lib/{{member}}',
264+
},
265+
lodash: {
266+
transform: 'lodash/{{member}}',
267+
},
268+
},
269+
},
270+
}
271+
```
272+
273+
Advanced transformations:
274+
275+
- Using regular expressions
276+
277+
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.
278+
279+
The config:
280+
281+
```js
282+
// next.config.js
283+
module.exports = {
284+
experimental: {
285+
modularizeImports: {
286+
'my-library/?(((\\w*)?/?)*)': {
287+
transform: 'my-library/{{ matches.[1] }}/{{member}}',
288+
},
289+
},
290+
},
291+
}
292+
```
293+
294+
Cause this code:
295+
296+
```js
297+
import { MyModule } from 'my-library'
298+
import { App } from 'my-library/components'
299+
import { Header, Footer } from 'my-library/components/App'
300+
```
301+
302+
To become:
303+
304+
```js
305+
import MyModule from 'my-library/MyModule'
306+
import App from 'my-library/components/App'
307+
import Header from 'my-library/components/App/Header'
308+
import Footer from 'my-library/components/App/Footer'
309+
```
310+
311+
- Handlebars templating
312+
313+
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+
236319
## Unsupported Features
237320

238321
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.

docs/advanced-features/react-18/server-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Server Components allow us to render React components on the server. This is fun
77
To use React Server Components, ensure you have React 18 installed:
88

99
```jsx
10-
npm install next@latest react@rc react-dom@rc
10+
npm install next@canary react@rc react-dom@rc
1111
```
1212

1313
Then, update your `next.config.js`:

docs/api-reference/data-fetching/get-static-props.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Learn more about [Incremental Static Regeneration](/docs/basic-features/data-fet
8585

8686
### `notFound`
8787

88-
The `notFound` boolean allows the page to return a `404` status and [404 Page](/docs/advanced-features/custom-error-page.md#404-page). With `notFound: true`, the page will return a `404` even if there was a successfully generated page before. This is meant to support use cases like user-generated content getting removed by its author.
88+
The `notFound` boolean allows the page to return a `404` status and [404 Page](/docs/advanced-features/custom-error-page.md#404-page). With `notFound: true`, the page will return a `404` even if there was a successfully generated page before. This is meant to support use cases like user-generated content getting removed by its author. Note, `notFound` follows the same `revalidate` behavior [described here](/docs/api-reference/data-fetching/get-static-props.md#revalidate)
8989

9090
```js
9191
export async function getStaticProps(context) {

docs/api-reference/next.config.js/rewrites.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ module.exports = {
323323
}
324324
```
325325

326-
If you're using `trailingSlash: true`, you also need to insert a trailing slash in the `source` paramater. If the destination server is also expecting a trailing slash it should be included in the `destination` parameter as well.
326+
If you're using `trailingSlash: true`, you also need to insert a trailing slash in the `source` parameter. If the destination server is also expecting a trailing slash it should be included in the `destination` parameter as well.
327327

328328
```js
329329
module.exports = {

docs/basic-features/data-fetching/get-server-side-props.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function getServerSideProps(context) {
2121
- When you request this page directly, `getServerSideProps` runs at request time, and this page will be pre-rendered with the returned props
2222
- When you request this page on client-side page transitions through [`next/link`](/docs/api-reference/next/link.md) or [`next/router`](/docs/api-reference/next/router.md), Next.js sends an API request to the server, which runs `getServerSideProps`
2323

24-
It then returns `JSON` that contains the result of running `getServerSideProps`, that `JSON` will be used to render the page. All this work will be handled automatically by Next.js, so you don’t need to do anything extra as long as you have `getServerSideProps` defined.
24+
`getServerSideProps` returns JSON which will be used to render the page. All this work will be handled automatically by Next.js, so you don’t need to do anything extra as long as you have `getServerSideProps` defined.
2525

2626
You can use the [next-code-elimination tool](https://next-code-elimination.vercel.app/) to verify what Next.js eliminates from the client-side bundle.
2727

docs/basic-features/script.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ description: Next.js helps you optimize loading third-party scripts with the bui
2525

2626
</details>
2727

28-
The Next.js Script component, [`next/script`](/docs/api-reference/next/script.md), is an extension of the HTML `<script>` element. It enables developers to set the loading priority of third-party scripts anywhere in their application without needing to append directly to `next/head`, saving developer time while improving loading performance.
28+
The Next.js Script component, [`next/script`](/docs/api-reference/next/script.md), is an extension of the HTML `<script>` element. It enables developers to set the loading priority of third-party scripts anywhere in their application, outside `next/head`, saving developer time while improving loading performance.
2929

3030
```jsx
3131
import Script from 'next/script'
@@ -166,7 +166,7 @@ There are a number of trade-offs that need to be considered when loading a third
166166

167167
Although the `worker` strategy does not require any additional configuration to work, Partytown supports the use of a config object to modify some of its settings, including enabling `debug` mode and forwarding events and triggers.
168168

169-
If you would like to add additonal configuration options, you can include it within the `<Head />` component used in a [custom `_document.js`](/docs/advanced-features/custom-document.md):
169+
If you would like to add additional configuration options, you can include it within the `<Head />` component used in a [custom `_document.js`](/docs/advanced-features/custom-document.md):
170170

171171
```jsx
172172
import { Html, Head, Main, NextScript } from 'next/document'

errors/link-no-children.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# No children were passed to <Link>
2+
3+
#### Why This Error Occurred
4+
5+
In your application code `next/link` was used without passing a child:
6+
7+
For example:
8+
9+
```js
10+
import Link from 'next/link'
11+
12+
export default function Home() {
13+
return (
14+
<Link href="/about"></Link>
15+
// or
16+
<Link href='/about' />
17+
)
18+
}
19+
```
20+
21+
#### Possible Ways to Fix It
22+
23+
Make sure one child is used when using `<Link>`:
24+
25+
```js
26+
import Link from 'next/link'
27+
28+
export default function Home() {
29+
return (
30+
<Link href="/about">
31+
<a>To About</a>
32+
</Link>
33+
)
34+
}
35+
```

errors/manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@
514514
"title": "future-webpack5-moved-to-webpack5",
515515
"path": "/errors/future-webpack5-moved-to-webpack5.md"
516516
},
517+
{
518+
"title": "link-no-children",
519+
"path": "/errors/link-no-children.md"
520+
},
517521
{
518522
"title": "link-multiple-children",
519523
"path": "/errors/link-multiple-children.md"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Modularize Imports Example
2+
3+
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+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](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+
[![Deploy with Vercel](https://vercel.com/button)](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:
20+
21+
```bash
22+
npx create-next-app --example modularize-imports modularize-imports-app
23+
# or
24+
yarn create next-app --example modularize-imports modularize-imports-app
25+
```
26+
27+
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

Comments
 (0)