Commit graph

11630 commits

Author SHA1 Message Date
Gal Schlezinger
da07c72460
[middleware] avoid fetching a chunk for api endpoints on middleware redirect (#37949)
avoid fetching a chunk for api endpoints on middleware redirect.
This still makes a request to the data endpoint, not sure if this is a good idea,
but a rewrite _can_ happen from that data request.

## Related

- Fixes #37944
- Fixes https://github.com/vercel/next.js/issues/37783



## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-27 18:18:42 +00:00
Houssein Djirdeh
82dce6ce8e
[Script] Allow next/script to be placed in _document body (#37894)
Fixes https://github.com/vercel/next.js/issues/37741. Allows `next/script` to be placed inside of `_document` body in addition to `Head`.

## Bug

- [X] Related issues linked using `fixes #number`
- [X] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-27 17:56:53 +00:00
Javi Velasco
0f33c0cbf5
Rephrase middleware location (#38073)
It is possible that users that are defining `src/pages` in their project confuse the "project root" to locate middleware with the actual project root instead of `src/middleware` so this PR rephrases the migration guide to make explicit that the it should be located **next** to the `pages` folder.
2022-06-27 17:13:19 +00:00
Steven
5ea3f6c4ab
Remove layout raw image experiment (#38006)
This PR removes experimental `layout="raw"` from `next/image` since it was moved to `next/future/image` in #37927
2022-06-27 15:11:15 +00:00
stefanprobst
42e214e508
chore: make experimental images options optional (#38030)
this makes all `experimental.images` options optional, so they can be toggled individually.

## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-27 01:23:39 +00:00
Jiachi Liu
a5f8382ee3
Rename page runtime edge to experimental-edge (#38041)
* Rename page runtime edge to experimental-edge

* fix ut

* fix lint

* PageRuntime -> ServerRuntime

* rename constant
2022-06-26 20:02:24 -05:00
JJ Kasper
252d3b72f4
Ensure we do not ignore module not found errors during build (#38026)
* Ensure we do not ignore module not found errors during build

* lint-fix
2022-06-26 19:34:58 -05:00
Max Proske
1648064d0e
Convert analyze-bundles example to TypeScript (#38040)
Converted Next.js Bundle Analyzer example over to TypeScript to align with the Examples guide.

I also replaced `faker` with `@faker-js/faker`. Faker has been forked and maintained [here](https://github.com/faker-js/faker) after the original author [deleted](https://www.theverge.com/2022/1/9/22874949/developer-corrupts-open-source-libraries-projects-affected) the library.

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-27 00:32:37 +00:00
Max Proske
1d5dd1bad3
Convert amp-story example to TypeScript (#38038)
Converted AMP Story example over to TypeScript to align with the Examples guide.

Note: Requires `v12.1.7-canary.41` or newer to build https://github.com/vercel/next.js/pull/37744#issuecomment-1159573754

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-27 00:26:34 +00:00
Steven Tey
8019cf002a
Added ESLint upgrade instructions to middleware upgrade guide (#38008)
## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-27 00:20:36 +00:00
Radu Nemerenco
83ac913950
fix(38043): replace double slashes with hashtag for comment lines in … (#38044)
…env example files



## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-27 00:04:05 +00:00
Balázs Orbán
f0b7457666
chore: compile issue validator action (#37990)
Ref:

https://github.com/vercel/next.js/runs/7042041627?check_suite_focus=true
https://github.com/vercel/next.js/runs/7042041634?check_suite_focus=true

https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github

## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-26 21:39:19 +00:00
M. Zakiyuddin Munziri
2833904b6f
Fix typo for rewrites/redirects to rewrite/redirect (#38016)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-26 16:17:34 -05:00
Jiachi Liu
948f736fac
chore: rename middleware ssr loader and flight manifest to edge related (#38042)
middleware-ssr-loader -> edge-ssr-loader
middleware-flight-manifest -> flight-manifest
2022-06-26 21:01:26 +00:00
Lee Robinson
dbfd594e8c
Add SWC plugins to version history in docs. (#38039) 2022-06-26 18:39:27 +00:00
Gal Schlezinger
22206651a6
[eslint-plugin-next] remove no-server-import-in-page rule (#38028)
This rule was good and kinda made sense when we had nested Middleware.
Now that we have a single Middleware, one might extract logic into different places
and I don't think we should limit importing `NextResponse` or `NextRequest`.

## Related

- Closes #36239
- Closes #37309



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-26 12:43:15 +00:00
Max Proske
d57342a94e
Convert amp-first example to TypeScript (#38029)
Converted AMP First Boilerplate example over to TypeScript to match the Contribution guidelines.

Note: Requires `v12.1.7-canary.41` or newer to build https://github.com/vercel/next.js/pull/37744#issuecomment-1159573754

## Documentation / Examples

- [X] Make sure the linting passes by running `pnpm lint`
- [X] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-26 11:43:36 +00:00
Mikis Woodwinter
2b451ee69a
feat(cli): allow configuration of http-server's timeout configuration (#35827)
* feat: add keep-alive timeout params for next-start

* feat: add keep-alive timeout args to next-cli's start

* docs: add docs for keep-alive timeouts

* docs: fix grammar & typos

* refactor: handle NaN for args

* test: add tests for timeout args

* revert: remove headersTimeout option

* fix: remove input validation for keepAliveTimeout arg

* feat: add input-range validation for keepAliveTimeout arg

* Error and tests for range validation

* Make sure timeout actually changes

* Fix error messsage

* Apply suggestions from code review

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

Co-authored-by: Hannes Bornö <hannes.borno@vercel.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Steven <steven@ceriously.com>
2022-06-26 13:26:51 +02:00
Aleksa Cukovic
bcd8de3262
Add *.tsbuildinfo to .gitignore of examples that use typescript (#38005)
I added ` *.tsbuildinfo` to gitignores of examples that use typescript and don't already have it. By use typescript I mean have `tsconfig` somewhere in their directory tree. 

I used the following script to update the files:

```bash
#!/bin/bash

set -eou pipefail

cd examples
examples=`git ls-files . | grep tsconfig | xargs dirname | grep -v "/"`

for example in $examples; do
    if ! grep -q tsbuildinfo $example/.gitignore; then
        gitignore="$example/.gitignore"
        echo $gitignore
        tail -c1 $gitignore | read -r _ || echo >> $gitignore
        echo -e "\n# typescript\n*.tsbuildinfo" >> $gitignore
    fi
done
```
2022-06-26 11:17:44 +00:00
JJ Kasper
6781a52559
Fix invalid warning for existing experimental flag (#38027) 2022-06-25 23:05:02 -05:00
Luis Alvarez D
02b9e8bd46
Update .gitignore to include @next/swc-wasm-nodejs (#38025)
Updated gitignore
2022-06-25 22:53:54 -05:00
william-keller
2997ff0711
Fixing bug - Can't resolve 'prop-types' (#38021)
## Bugfix

- Missing package dependency in package.json causing -> Can't resolve 'prop-types'
2022-06-26 03:12:55 +00:00
Sukka
c85c41043d
fix(#37981): handle legacy link behavior with number type children (#38013)
## Bug

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

Fixes #37981.

When handling the legacy link behavior on the current version of Next.js, it only wraps single string child in `<a>` tag. The PR fixes the issue by also wrap single number child in `<a>` tag, too.
2022-06-25 20:07:40 +00:00
JJ Kasper
a148d1426d
Add note about skipping upstream cache during revalidation (#38014)
This adds a note about ensuring requests during a revalidation don't leverage an upstream cache as it will fail to pull fresh data to update the ISR cache with if configured. 

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Fixes: https://github.com/vercel/next.js/issues/35523#issuecomment-1154687543
x-ref: https://github.com/vercel/next.js/issues/35195


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-06-25 16:26:12 +00:00
JJ Kasper
f4fb3e0377
Fix eslint-config-next peer dep issue (#38009)
It seems `npm` fails to resolve the `next` `peerDependencies` field for `eslint-config-next` and this field isn't necessarily needed so this removes it to ensure upgrading doesn't require the `--force` flag.  

## Bug

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

Fixes: https://github.com/vercel/next.js/pull/38008#discussion_r906629793
2022-06-25 12:08:14 +00:00
Damien Simonin Feugas
cb882b7e70
fix: hardcoded protocol in request url (#37925)
* fix: hardcoded protocol in request url

* test: covers custom server using https

* Apply suggestions from code review

* fix test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-24 19:31:23 -05:00
Steven
f6ee4c06b9 v12.1.7-canary.48 2022-06-24 19:56:15 -04:00
Steven
71e25d4f54
Fix npm publish to include future folder (#37999)
* Fix npm publish to include `future` folder

* Fix webpack config and add a test

* lint-fix

* Change static import to url string

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-24 18:30:30 -05:00
Lee Robinson
8ce2790026
On-demand ISR updates. (#37955)
* On-demand ISR updates.

* Apply suggestions from code review

* lint-fix

* Update docs/basic-features/data-fetching/incremental-static-regeneration.md

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-24 16:59:23 -05:00
Steven
8302a3ff7c
Move rimraf from root packages using it (#37996)
In a previous PR (#37278), the dependencies for benchmarks were moved to a subdirectory.

This ensures the same is done for other packages using `rimraf` which means we can remove it from the root package.json
2022-06-24 21:08:52 +00:00
JJ Kasper
de29dcbb62
Update expected error for middleware deploy test (#37998) 2022-06-24 15:47:46 -05:00
Lee Robinson
5646e43f83
Fix typo for rewrites to rewrite. (#38000) 2022-06-24 15:45:02 -05:00
JJ Kasper
9cac00dbfb
Update flakey prefetch test (#37997) 2022-06-24 15:27:51 -05:00
Steven
880d4fb5c9
Bump release to 6.3.1 (#37995) 2022-06-24 15:02:40 -05:00
JJ Kasper
20d6792542
Move outputStandalone config (#37994) 2022-06-24 14:58:35 -05:00
Steven
f8732d9cd7
Fix flaky onLoad() test for next/image/future (#37993)
This PR fixes flaky `onLoad()` test for `next/image/future`.

The test must modify the `src` after hydration to make sure it always works as expected.

This is because `next/image/future` uses native lazy loading and sometimes the event fires before hydration (docs were updated to mention this)
2022-06-24 19:28:48 +00:00
Steven
086746538c v12.1.7-canary.47 2022-06-24 14:58:49 -04:00
Javi Velasco
a8757135e2
Fixes for middleware compilation errors (#37984)
* Refactor `runDependingOnPageType`

* Throw specific error when the compiled middleware cannot be found

* Do not render `MiddlewareNotFoundError` on dev

* Allow to invalidate compilers by type

* Show compile errors when middleware fails to build

* Add tests
2022-06-24 13:50:49 -05:00
Balázs Orbán
a590c4e7f3
docs: return response in code example (#37985)
* Update middleware-upgrade-guide.md

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-24 11:13:40 -05:00
Balázs Orbán
90010be70d
docs: clarify NextRequest.ip (#37987)
Update server.md
2022-06-24 11:05:39 -05:00
JJ Kasper
edd798e526
Fix hard navigation guard on popstate and handle fetching fresh data (#37970)
* Fix hard navigation guard on popstate and handle fetching fresh data

* undo link changes and handle middleware cases

* update tests
2022-06-24 10:50:41 -05:00
Lee Robinson
07a6d4a880
Remove Middleware warning message. (#37973)
* Remove Middleware warning message.

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-06-24 10:43:36 -05:00
Steven
e28d03c5a4
Add experimental next/future/image component (#37927)
This PR introduces a new experimental component, `next/future/image`, which is inspired by the existing experimental `layout="raw"`.

The difference is that much of the code has been deleted in order to reduce client-side code as well as reduce complexity:

- No `layout` prop
- No `loader` config (although `loader` prop works)
- No `IntersectionObserver`, use native `loading="lazy"` 
  - No `lazyBoundary`
  - No `lazyRoot`
- No `fill` (yet) so width & height are required
- No `objectFit` (use `style` instead)
- No `objectPosition` (use `style` instead)

This improves performance because native `loading="lazy"` doesn't need to wait for React Hydration and client-side JS.

In a future PR, we will modify `next/image` to remove `layout="raw"` since this new component supersedes it.

## Feature

- [x] Integration tests added
- [x] Documentation added
- [x] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`
2022-06-24 14:56:05 +00:00
JJ Kasper
658a7f550f
Update to latest version of turbo (#37976) 2022-06-24 09:31:26 -05:00
Balázs Orbán
bee7b31549
chore: use Node 16 for issue validator action (#37982) 2022-06-24 12:27:49 +02:00
JJ Kasper
77ec56fa10
Fix issue-validator path 2022-06-23 22:31:29 -05:00
JJ Kasper
7156a28626
Ensure repo is checked out before running validate issue action (#37972) 2022-06-23 22:27:53 -05:00
JJ Kasper
8a0f86a8e8
v12.1.7-canary.46 2022-06-23 21:12:22 -05:00
JJ Kasper
57c5e2a024
Update middleware matcher test for root (#37961) 2022-06-23 15:47:58 -05:00
JJ Kasper
7bb247ca8f
Move styled-jsx type reference (#37964)
Follow-up to https://github.com/vercel/next.js/pull/37902 this moves the reference to avoid a change in `next-env.d.ts`. Also updates our doc note on the `next-env.d.ts` file to be more explicit about it being ignored.

## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-23 19:26:08 +00:00