Commit graph

10411 commits

Author SHA1 Message Date
Tim Neutkens
df0e89984e v12.0.8-canary.22 2022-01-12 09:09:32 +01:00
Rich Haines
d291aa9134
Refactor data fetching API docs (#30615)
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-12 08:56:51 +01:00
Hiroaki Ogasawara
b6b7d85f6d
Docs: correct ignorance pattern for .env.local (#32647)
* Docs: correct ignorance pattern for env.local

In order to gitignore `.env.local`, I need to add `.env*.local` instead of `.env.*.local` to `.gitignore`.

* Update docs/basic-features/environment-variables.md

Co-authored-by: Steven <steven@ceriously.com>

* Update docs/basic-features/environment-variables.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-12 02:56:07 +01:00
Manny Becerra
36eba95227
Fixes #33153: Updating cross-references from master to main + canary (#33198)
* copy cleanup in env. variables docs

* copy cleanup in fast refresh docs

* Supplements #33153 - updating existing cross-references to `master` branch to renamed default branch of `main`

* Supplements #33153 - updating existing cross-references to `master` branch to renamed default branch of `main`

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-01-12 02:55:35 +01:00
JJ Kasper
0de84472eb
v12.0.8-canary.21 2022-01-11 15:00:27 -06:00
JJ Kasper
57a87050e7
Add util for normalizing errors (#33159)
* JSON.stringify generic errors

* Add util for normalizing errors

* lint-fix

* Add better error for null case as well

Co-authored-by: Michael Ozeryansky <mozeryansky@users.noreply.github.com>
2022-01-11 14:40:03 -06:00
kaykdm
2d0fd341a3
Fix broken yarn pnp (#32867)
x-ref [#31552 ](https://github.com/vercel/next.js/issues/31552)
x-ref https://github.com/vercel/next.js/issues/32115
x-ref https://github.com/vercel/next.js/issues/32546
x-ref https://github.com/vercel/next.js/issues/32721

Since this PR https://github.com/vercel/next.js/pull/31455 is merged, `enhanced-resolve` dependency's resolved field is changed which caused broken yarn pnp.
I am not sure how this field has been changed or this is intentional or not 
When I install webpack locally, `enhanced-resolve`'s resolved field in lock file is always `registry.yarnpkg.com` not `codeload.github.com`

## 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`


Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-11 19:46:18 +00:00
Tobias Koppers
9836429bee
drop dynamic import with ssr: false on server-side (#32606) 2022-01-11 14:46:28 +01:00
Fatih Kalifa
600f113358
next-swc: fix ssg code elimination when used in render (#32709)
* next-swc: fix ssg code elimination when used in render

* simplify logic and add more thorough tests

* comment

* remove fold_export_default and fix JSX member expression
2022-01-11 14:02:24 +01:00
Glenn Gijsberts
5f4947e5a2
Add Caveats section to custom error page (#33160)
## Desscription

This is a follow up of https://github.com/vercel/next.js/pull/32873. As discussed in #32873, currently it's not recommended to use getServerSideProps in the `Error` component, so this PR will add that caveat to the documentation page, like `Document` and `App` also have.

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-01-10 21:52:08 +00:00
JJ Kasper
3eabb7f4c7
v12.0.8-canary.20 2022-01-10 14:59:41 -06:00
Gal Schlezinger
4aa9879dcc
Allow dependencies to use environment variables in middlewares (#33141)
After discussing with @sokra, seems that the proposed solution is split in two:

* We need to make sure that the `process` polyfill uses `global.process` if available. This is because middlewares are bundled using `browser` target and therefore `process.env.MY_ENV` gets shimmed into `require('process').env.MY_ENV`.

* Allow `process.env` to be statically analyzed for dependencies so they will be exported to the manifest.

Related issues:

* should fix #33043.
2022-01-10 18:45:00 +00:00
Tobias Koppers
f0ad19aef6
use a separate webpack runtime for middleware (#33134)
it should not leak into the client runtime

cc @javivelasco 



## 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`
2022-01-10 17:41:53 +00:00
Alexandru Tenie
8ae08b94d8
No info on environment variables in the src folder (#33110) (#33136)
Proposes fix to #33110

Adds info on environment variables and the /src folder in the following docs:

- https://nextjs.org/docs/advanced-features/src-directory
- https://nextjs.org/docs/basic-features/environment-variables#loading-environment-variables

## 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
- [x] 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`


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2022-01-10 13:58:29 +00:00
Manny Becerra
213f5a43ea
docs: minor text-copy cleanup (#33120)
Proposes some minor text-copy cleanup in the following docs:

- https://nextjs.org/docs/basic-features/fast-refresh
- https://nextjs.org/docs/basic-features/environment-variables

## 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
- [x] 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`
2022-01-10 10:52:47 +00:00
Donny/강동윤
87dbd03eb0
Update swc (#33063) 2022-01-10 11:37:32 +01:00
David Babel
320986a2b8
Update next.config.js (#33091)
## Feature

We are in a Typescript context, but the `next.config.js` cannot be parsed as is, since it fails on `File is a CommonJS module; it may be converted to an ES module.ts(80001)` so it does not parse the rest of the file :


![image](https://user-images.githubusercontent.com/5599375/148612812-de50b5d9-609e-4273-9892-5b3a4ad0b282.png)

Here we should have an error because the type is not the expected one.

With a little trick, it's possible to enable the check by : 
- adding `// @ts-check` at first line
- moving the export at the end of the file

And then it works like a charm :

![image](https://user-images.githubusercontent.com/5599375/148612666-ae5350d8-f16e-45e0-84e4-b31faf07fcca.png)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-08 01:47:22 +00:00
David Fateh
3861e4b8ec
Adding Asset Component for Rich Text Renderer (#32503)
This PR accomplishes 2 things:

1. You can now add images to the rich text post of the example and see those images show up in the app. This is a good jumping off point for people who are learning how to customize the rich text renderers by adding custom components to the mapper.
2. Updating the README pictures to have a more up-to-date UI in the screenshots.

## Feature
- [x] Documentation added

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-01-07 22:51:39 +00:00
Balázs Orbán
e5e04c9039
Update using-mdx.md (#33077) 2022-01-07 00:32:31 +01:00
JJ Kasper
aeb67cc28d
v12.0.8-canary.19 2022-01-06 11:09:32 -06:00
Simon Kirsten
6f5bfc1b40
Fix middleware at root in standalone mode (#33053)
Fixes [a small bug](https://github.com/vercel/next.js/pull/32967#issuecomment-1006277236) that caused the build to crash if a _middleware is present at the root of the project and standalone mode is enabled.
2022-01-06 16:20:43 +00:00
JJ Kasper
efabf81e23
Add util for generating new tests/error documents (#33001)
* Add util for generating new tests/error documents

* update compiled

* lint-fix

* apply suggestions

* update wording

* update compiled
2022-01-06 09:45:04 -06:00
JJ Kasper
48c0bc8cd6
Remove extra config from tailwind example (#33062)
Removes extra config per https://github.com/vercel/next.js/pull/32808/files#r779282629

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-01-06 13:58:57 +00:00
Lee Robinson
52d5adf8ab
Fix link for Next.js Analytics in docs (#33049)
The relative path was not working.
2022-01-06 01:30:34 +00:00
Steven
62227ee9aa
Bump @vercel/nft to 0.17.2 (#33048)
This bumps `@vercel/nft` to the latest version and consequently bumps `graceful-fs` to the latest version.

- Fixes #33003
- Related to https://github.com/vercel/nft/pull/258
- Related to https://github.com/browserify/resolve/issues/264

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-06 00:01:37 +00:00
Lee Robinson
26ddf32f53
Update deployment documentation. (#32006)
Building off https://github.com/vercel/next.js/pull/31465 for `next export` docs.

- Clearly explains the standard output from `next build`
- Move Dockerfile snippet to example, instead of embedded directly
- Clarify both Vercel and `next start` use the Build API output spec
- Less emphasis on recommending Vercel (more neutrality)
- Mention Middleware & Edge Functions when discussing Vercel
- Add "Going to Production" link at the bottom for related reading
2022-01-05 21:56:05 +00:00
JJ Kasper
5680007fa2
v12.0.8-canary.18 2022-01-05 13:49:39 -06:00
Balázs Orbán
626955d61c
fix: ensure revalidation error is logged from response-cache (#32657)
Something [between `11.0.2-canary.5` and `11.0.2-canary.6`](https://github.com/vercel/next.js/compare/v11.0.2-canary.5...v11.0.2-canary.6) changed the behavior that logged any runtime errors in `getStaticProps` to stderr. This is only observable if `getStaticProps` has a `revalidate` value, and the build did not fail. The error has to happen in a subsequent revalidation step.


This PR reverts the change and fixes #30375.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-05 19:40:04 +00:00
David Brookton
2efc944cb9
(examples/with-next-translate) Removed Redundancies in Strings (#29501)
## `with-next-translate` Example Refactor
- [x] Linting passes

## Purpose for changes
- The existing locals folder is using a redundant string structure which continuously repeats "Change language to " in separate instances in separate languages alongside separate language translations.
- This PR is a simple refactor to extract "change language to" to it's own string, and references already existing strings defining the language translation.

## Why they might be helpful
- A user looking to implement this pattern should consider reducing redundancies as early as possible to scale an app, thus I believe it would be helpful for this example.

Notes: 
- these original translations were done via google translate
- verified that these strings still make sense and translate properly in every locale / language
- these strings are meant to be examples, translations have not been verified with a translation agency.



Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-05 18:25:00 +00:00
Rohith Gilla
551c9d6963
[chore] Update deta version in examples (#30204)
## 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`
2022-01-05 18:04:56 +00:00
Vicente Soriano
ef7e70ee5d
fix: typescript example supporting strict w/ version >= 4.4 (#33042)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`

Closes: https://github.com/vercel/next.js/pull/32023
Fixes: https://github.com/vercel/next.js/issues/32015
2022-01-05 17:58:13 +00:00
Teo Stocco
789a665a03
Avoid page double render with emotion vanilla (#30541)
> Based on https://github.com/vercel/next.js/blob/v12.0.1/packages/next/server/render.tsx#L522-L532, this avoids the need for double page render. After investigation, the potential unneeded render has been introduced in the official [example](https://github.com/vercel/next.js/pull/20228/files#diff-3976da223aaf15067ecdd0734ca277ebf4629c46d62f89d732ab392752d3572dR6) but does not exist in the earlier proposed [solution](https://gist.github.com/colinhacks/c40519a6a050a99091862319151377ec). There might a reason (layered override?) for it but I am unable to find relevant explanation.

Original discussion in https://github.com/mantinedev/mantine/pull/348.

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-01-05 17:48:12 +00:00
Kumar Deepanshu
066984e6d9
converted the old tailwind css example to typescript (#32808)
## 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`
2022-01-05 17:41:25 +00:00
Guillaume FORTAINE
4a2bfa7aa6
fix(examples/cms-contentful): add correct Content-Type + missing closing tag for html (#30321)
## 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`
2022-01-05 16:59:32 +00:00
JJ Kasper
1ee13baf00
Ensure NODE_ENV is not inlined for next/jest (#33032) 2022-01-05 09:22:22 -06:00
Hung Viet Nguyen
ce3a3d8eea
Rename api in with-redis example (#33016)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-01-05 08:24:15 -06:00
Jared Palmer
0195a6f89e
Remove unused turbo remote cache env vars (#33030) 2022-01-05 07:48:42 -06:00
JJ Kasper
cfa8ab9cbf
v12.0.8-canary.17 2022-01-04 15:29:37 -06:00
JJ Kasper
5e5f1df445
Re-enable turbo caching for swc build jobs (#32617)
* Fix build-native jobs

* Update to latest turbo

* fix extra space

* fix windows shell

* Update to latest turbo

* Bump Turbo (#32703)

* Bump turbo to canary

* Bump turbo

* Update yaml too

* add less specific restore key

* update more restore keys

* Fix non-unique key and cache wasm build

* ensure turbo is installed for new jobs

* remove old wasm cache

* update directory check

* bump

* re-add if publish checks

Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
2022-01-04 15:10:16 -06:00
Balázs Orbán
3ad2035ae6
feat(cli): introduce next info CLI command (#32972)
This PR adds a new command to the `next` CLI.

Running `next info` will print useful information to the terminal about how/where Next.js is run. This information can be added to the Bug report when opening an issue in the repository.

This makes reporting issues more accurate and doesn't require the user to guess certain details, the command will retrieve it on their behalf.

Example output:

```sh
$ npx --no-install next info

    Operating System:
      Platform: linux
      Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021
    Binaries:
      Node: 16.13.0
      npm: 8.1.0
      Yarn: 1.22.17
      pnpm: 6.24.2
    Relevant packages:
      next: 12.0.8-canary.14
      react: 17.0.2
      react-dom: 17.0.2


```

The idea is based on #32858

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [x] 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`


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-01-04 15:35:32 +00:00
Balázs Orbán
1be87040b0
fix(examples): add missing dependencies wo (#32977)
The `with-jest` example has been converted to TypeScript (#32705) , but `typescript` and `@types/react` were missing from `devDependencies`

## 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`
2022-01-04 13:49:16 +00:00
Mike K
7c8500f16d
Updated wrong link to example of gtag init in measuring-performance.md (#32974)
Updated wrong link to example of gtag init



## 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`
2022-01-04 01:57:59 +00:00
JJ Kasper
69a56759ee
v12.0.8-canary.16 2022-01-03 18:58:27 -06:00
Steven
6f10d94d90
Revert "Reduce install size for linux glibc/musl (#32850)" (#32973)
This reverts commit a5fab84840.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-01-03 18:47:48 -06:00
JJ Kasper
e01ef297e7
Ensure middleware is output in standalone mode (#32967) 2022-01-03 18:47:18 -06:00
JJ Kasper
5378db8f80
v12.0.8-canary.15 2022-01-03 15:46:09 -06:00
Steven
a5fab84840
Reduce install size for linux glibc/musl (#32850)
In Next.js [12.0.1](
https://packagephobia.com/result?p=next@12.0.1), musl support was added which caused linux to install both glibc and musl binaries.

This PR adds the `install` script to prevent installing unused binaries, reducing the install size by 47MB.

We originally thought this could be added to Node.js core and thus npm but [it was rejected](https://github.com/nodejs/node/pull/41338).

Note getReport() works on Node.js [`>=11.8.0`](https://nodejs.org/api/process.html#processreportgetreporterr) which is safe to use since Next.js requires [`"node": ">=12.22.0"`](265f71e225/packages/next/package.json (L280)).
2022-01-03 21:17:46 +00:00
Devin Wall
d0e72fd9fa
Fixes issue with makeStylesheetInert (#32027)
Fixes https://github.com/vercel/next.js/issues/32024

Fixing makeStylesheetInert.
Fixes log import.



## 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`


Co-authored-by: Devin Wall <87490815+DevinWallKcl@users.noreply.github.com>
2022-01-03 20:35:57 +00:00
JJ Kasper
52cf7fe51e
Ensure setImmediate and punycode are polyfilled (#32768)
* Ensure setimmediate and punycode are polyfilled

* update compiled
2022-01-03 13:31:23 -06:00
Javi Velasco
82adaee0cd
Allow to opt-out from preflight cache (#32767)
Fixes #32727

With this PR we introduce a new header that can be used to respond from Middleware `x-middleware-cache`. When the value of this header is set to `no-cache`, the client will **not** store the effects read from a preflight response to be used in an upcoming check.

Instead of using `Cache-Control` we are using a custom header to not mess with browser specific caching. Accepting a specific value to opt out (`no-cache`) opens the future opportunity of having other caching strategies.

This feature solves the issue of having a preflight request whose parameters can change from the client affecting the effects. For example, having a cookie that would make a middleware rewrite to one pathname or another and allowing to change that cookie from the client. In that case we'd always need to revalidate the effects on navigation synchronously.

Of course when using this feature it is possible that we add some latency on navigation so the preferred mechanism will be caching by default since it covers the most common use cases.
2022-01-03 18:13:28 +00:00