Commit graph

10776 commits

Author SHA1 Message Date
Cody Olsen
f14f62838a
docs(examples): add on-demand ISR to cms-sanity (#35220)
Documents how to setup GROQ webhooks that revalidates ISR routes on-demand.
It's trivial to do this for posts as you only need to lookup the `slug` based on the `id` you receive in the webhook payload.
When editing authors the GROQ query demonstrates how you can do a reverse lookup (find all pages that reference the edited author) then invalidate their routes.

This work is based on https://github.com/sanity-io/structured-content-2022/pull/105, thanks @j0nas! 🎉 

[Test **Deploy with Vercel**](https://vercel.com/new/git/external?repository-url=https://github.com/stipsan/next.js/tree/add-on-demand-ISR-to-cms-sanity/examples/cms-sanity&project-name=cms-sanity&repository-name=cms-sanity&env=NEXT_PUBLIC_SANITY_PROJECT_ID,SANITY_API_TOKEN,SANITY_PREVIEW_SECRET,SANITY_STUDIO_REVALIDATE_SECRET&envDescription=Required%20to%20connect%20the%20app%20with%20Sanity&envLink=https://vercel.link/cms-sanity-env)

## Documentation / Examples

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



Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-03-10 23:14:36 +00:00
Jiachi Liu
088354d4f7
Render resolved streaming content for static render result (#35221)
* Fix the static streaming render result isn't the resolved streaming rendering content (resolve suspense)
* Update readable stream polyfill to fit the w3c standard
2022-03-10 21:34:40 +00:00
chemicalkosek
7ce5d3f240
Re-add _document to with-styled-components example (#35163)
`_document.js` was removed from the styled components swc example
I have tested with and without the custom `_document.js`
Unfortunately without `_document.js` there is FOUC (Flash of unstyled content) on initial request.



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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-10 18:12:23 +00:00
Steven
ceb7bfb29d v12.1.1-canary.9 2022-03-10 08:22:40 -08:00
Huzaifa Arif
ea87415fd9
[Fix] Adds try/catch to gracefully handle performance observer exception (#35202)
* fix: add try/catch to gracefull handle performance observer exception on older browsers

* fix: run prettier

Co-authored-by: Steven <steven@ceriously.com>
2022-03-10 11:06:50 -05:00
Steven
0355e5f63f
Fix next/image when src is webp but browser doesnt support it (#35190)
* Fix `next/image` when src is webp but browser doesnt support it

* Exclude old sharp since it doesnt support AVIF
2022-03-10 15:02:13 +01:00
Eric Ponto
84720697e4
Convert server.js to module.exports (#35181)
If different contexts (using Jest, using Nx, etc), server.js is getting imported when using middleware and throwing the error: "SyntaxError: Unexpected token 'export'".

fixes #32848



## 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: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-09 22:50:07 +00:00
Jiachi Liu
9bff48b9d5
Adopt react 18 rc2 (#35161)
* Adopt react 18 rc2

* execute shouldUseReactRoot only once

* update test

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-03-09 21:12:36 +01:00
Jiachi Liu
81276e213d
Disable the functions manifest plugin (#35155)
Disable the plugin introduced in #33770, will rewrite when manifest consuimg part becomes stable
2022-03-09 15:22:54 +00:00
Jiachi Liu
21994ce591 v12.1.1-canary.8 2022-03-09 14:06:29 +01:00
JJ Kasper
acbd54322f
Ensure mjs files are transformed with jest (#34698)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-03-09 13:49:58 +01:00
Jiachi Liu
6646ffad75
Change to loadBindings for swc parse (#35171)
CI test `TEST_WASM=true xvfb-run node run-tests.js test/integration/production/test/index.test.js` is aways failing in recent PRs

`loadBindingsSync` does not import `next-swc/wasm` unlike `loadBindings`

x-ref: https://github.com/vercel/next.js/runs/5479076388?check_suite_focus=true
x-ref: https://github.com/vercel/next.js/runs/5471650765?check_suite_focus=true
2022-03-09 12:21:01 +00:00
Jiachi Liu
55c063eaac
Delay prefix flushing (#35170)
Only happened with SSR without suspense case

Similar reason to #34474, the prefix (script parts) might be flushed during the render stream causing bad HTML. Use the same tricky to delay the prefix flushing

#### Expected
```html
<div>content</div> <!-- render stream --> 
<script>...</script> <!-- prefix --> 
```


#### Observed
```html
<!-- prefix choked the render stream --> 
<div <script>...</script> >content</div>
```


Test sample:
https://next-react-server-components-r5xocii9r-huozhi.vercel.app/ssr
2022-03-09 11:06:37 +00:00
Shu Ding
201f98e81a
Per-page runtime (#35011)
Partially implements #31317 and #31506. There're also some trade-offs made with this PR: since we can't know if a certain runtime will be used or not beforehand, we have to start both runtime compilers (Node.js and Edge) and then generate entrypoints correspondingly.

Note that with this PR, the global runtime is still required to use the per-page runtime.

## Bug

- [ ] 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`
2022-03-08 20:55:14 +00:00
Naoyuki Kanezawa
9e4724dea2
fix: hard-navigate when preflight request fails (#35145)
fixes https://github.com/vercel/next.js/issues/34199

Also fixes response code to return `500` when showing error page of preflight request failure on dev mode

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 19:51:08 +00:00
Leyan Lo
d3cd00cfcf
[examples] Use more semantic footer element (#35033)
Use more semantic footer element for example blog footer. Also remove unused styles. No visual changes.



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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-08 19:31:24 +00:00
Naoyuki Kanezawa
eb878459de
fix post request hangs when no body is consumed on middleware (#35131)
fixes https://github.com/vercel/next.js/issues/34966

Wait for reading original request body before overwriting the request properties with `originalBody?.finalize()` call since it caused the problem when middleware does not read request body

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 19:24:58 +00:00
Naoyuki Kanezawa
d141376772
[next] Fix to not call middleware with shallow push, fix middleware call wit… (#35047)
…h query parameter

Fixes https://github.com/vercel/next.js/issues/32655 and fixes https://github.com/vercel/next.js/issues/35006

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 19:03:14 +00:00
Steven
f8a2350157
Add next/image docs section for animated images (#35123)
- Related to #34807
2022-03-08 18:42:32 +00:00
OJ Kwon
8d0561ebf8
feat(trace): postprocess trace reporter for datadog (#35032)
* feat(trace): include clocktime for span

* build(package): bump up devdependencies

* feat(trace): postprocess trace reporter for datadog

* build(package): update precompile pkgs

* update compiled

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-03-08 08:15:09 -08:00
Tobias Koppers
292636d249
watch node_modules (#35140)
next.js doesn't HMR when installing node_modules.

This fixes it.

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-03-08 14:12:50 +00:00
Luis Alvarez D
4c6c4904d7
Update shallow routing caveat (#35052)
Minor change to improve caveat clarity of doing shallow routing

## Documentation / Examples

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


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-03-07 23:29:07 +00:00
Jiachi Liu
c130fd67be v12.1.1-canary.7 2022-03-07 22:47:55 +01:00
Steven
b25f7f84b1
Fix animated png bypass from Image Optimization API (#35120)
- Fixes #34807
- Related commit 69dad3cdf9

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-07 20:29:11 +00:00
Artur Kornakov
0e5e8881c0
Normalize root path according to trailingSlash option in default next/image loader #21337 (#22453)
* fix(next/image): normalize root path according to trailingSlash option in defaul loader

* test(image-optimizer): trailingSlash support

* chore(next/image): prettier

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-03-07 18:55:39 +01:00
Gerald Monaco
a666591555
Split up & tweak next/client initialization (#33838)
For streaming, we want the main bundle to be loaded with `async` rather than `defer`. As the first step to doing that, we need an explicit initialization step, rather than occurring as a side effect of being loaded.

For now, I've just split the logic into a `initialization` and `hydrate` (previously `initNext`) functions and called them as a side effect of `next/client/next` and `next/client/next-dev` as before. A follow-up PR will move that to a separate script tag [as recommended](https://github.com/reactwg/react-18/discussions/114).
2022-03-07 17:09:55 +00:00
Jiachi Liu
ff6b75027b
Enable import assertion syntax parsing (#33750)
## Feature

Enable import assertion syntax parsing for ecmascript/typescript. Since webpack has already supported it, enable import assertion parsing and leave them to webpack to handle

#### Upgration
* tooling: `@swc/core`, `@swc/cli`, prettier to support importAssertion related flags
* typescript related: `typescript` >= 4.5
* babel related: `@babel/plugin-syntax-import-assertions`
* lint parser: `@typescript-eslint/parser`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-06 20:41:22 +00:00
F. Hinkelmann
3dfb66fc19
Fix missing parenthesis for link in docs (#35090)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-03-06 16:57:44 +00:00
Brian Noguchi
01268f61ce
dep: upgrade @swc/core v1.2.148 , @swc/cli v0.1.55 (#35054)
## Feature

Upgrades `@swc/core` to `1.2.148`, which includes this critical fix https://github.com/swc-project/swc/pull/3824

Also upgrades `@swc/cli` to `v0.1.55`
2022-03-05 21:45:30 +00:00
James Perkins
b5cc91e2ba
[examples] Add Tina CMS blog starter (#35045)
## Documentation / Examples

- Adding TInaCMS example using the traditional CMS example 


Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2022-03-05 17:08:49 +00:00
Chris Midgley
946f465a6e
fix(examples/with-docker): add npm comment for yarn build (#35040)
There was an `npm` equivalent for `yarn install` (`npm ci`) but not one for `yarn build`. I've added `npm run build` as a commented out option.

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-03-04 17:59:57 +00:00
Jiachi Liu
7083dcfe44
Generate static html for bots (#35004)
* Generate static html for bots

* fix lint

* refactor error handling against comment

* fix streaming on edge for bots

* inline doResolve
2022-03-03 23:39:26 -08:00
Balázs Orbán
62c33c1eb7
feat: support pnpm with create-next-app (#34947)
* feat: support `pnpm` with `create-next-app`

* test: add `--use-pnpm` tests

* docs: mention `--use-pnpm` flag in docs

* test: remove `only`

* Update test/integration/create-next-app/index.test.ts

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

* chore: add pnpm action setup to tests

* chore: use latest pnpm

* chore: debug

* chore: debug

* fix: fall back to `yarn` instead of `npm`

* test: run all tests

Co-authored-by: Steven <steven@ceriously.com>
2022-03-04 00:49:24 +01:00
io
2c7f8b3d7b
Support colons in Middleware NextResponse.rewrite path (#32543)
* Add failing colon rewrite test

* add test fixture

* better colon rewrite tests

* middleware rewrite colon tests with query parameters

* fix #31523

this addresses the symptom but the real systemic issue is that prepareDestination is called on rewrite/redirect URLs, which have no defined special behavior for colons and they should not be compiled at all

* hack around prepareDestination to skip compiling x-middleware-rewrite

this is a bit nicer than just escaping colons, but ideally we find a way to obviate prepareDestination

* obviate prepareDestination for x-middleware-rewrite handling

* don't clobber rewrite query data

* omit redundant type

* catch up to main

* It looks like newUrl should contain only pathname

Co-authored-by: Naoyuki Kanezawa <naoyuki.kanezawa@gmail.com>
2022-03-03 11:36:53 -08:00
Balázs Orbán
728d82663c
feat: allow dotenv default expansion (#34765)
We currently use `dotenv-expand@5` in `@next/env`, which does not support default expansion. It was added in v6 (https://github.com/motdotla/dotenv-expand/pull/39).

Upgrading to the latest version of `dotenv-expand` and fixing an import, the added test passed.

Fixes #34718

## 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-03-03 16:52:20 +00:00
Rishabh Poddar
5fb6980c44
Update supertokens demo app (#35007)
New version of supertokens-auth-react.

Co-authored-by: Bhumil Sarvaiya <21988812+bhumilsarvaiya@users.noreply.github.com>
Co-authored-by: Joel Coutinho <6310783+jscyo@users.noreply.github.com>
2022-03-03 16:29:56 +00:00
JJ Kasper
81c50f4a87
Handle de-duping revalidations in minimal mode (#34935)
* Handle de-duping revalidations in minimal mode

* fix type

* remove header check

* update other tests

* update test
2022-03-02 15:06:54 -08:00
JJ Kasper
e51d2627d0
Update to re-use cache while revalidate is erroring (#34931) 2022-03-02 14:09:40 -08:00
Steven
937ab16b78
Fix typescript 4.6.2 randomUUID() (#34976)
This PR fixes the latest version of `typescript` (4.6.2) that was failing with the following:

```
Type error: Overload signatures must all be optional or required.
  207 |       array: T
  208 |     ): T
> 209 |     randomUUID?(): string
      |     ^
  210 |   }
  211 | }
```

https://github.com/vercel/next.js/runs/5376232868?check_suite_focus=true#step:8:106

- Related to https://github.com/PeculiarVentures/webcrypto/issues/44

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-02 21:51:15 +00:00
Jiachi Liu
e3d0d645af
Adopt react 18 rc1 (#34972)
### Changes

* Remove top-level suspense boundary
* Pipe stream resolved from returned promimse of `renderToReadableStream`
* Remove jsx-runtime alias hack

### Test Changes

Since top level suspense boundary is removed, now content are filled in 1st SSR
2022-03-02 21:21:18 +00:00
Shu Ding
1f1632979c
Fix named export missing from client components (#34974)
Closes #33538.

## 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`
2022-03-02 20:57:50 +00:00
JJ Kasper
1b17070a29
v12.1.1-canary.6 2022-03-02 12:12:15 -08:00
Steven
65e704daa4
Fix next/image noscript when blur and priority (#34973)
Fixes a bug where browsers with scripts disabled did not work with `<Image placeholder="blur" priority />`.

- Introduced in #32918
2022-03-02 19:59:02 +00:00
Shu Ding
a518036246
Refactor export marks of server components (#34945)
* refactor rsc export marks

* fix failed test
2022-03-02 19:29:54 +01:00
Jiachi Liu
d9d494adaf
Provide page runtime parsing utils (#34922)
* parse runtime config

* add test

* fix typing

* fix lint warning

* change branch purging condition

* dont fallback to global runtime
2022-03-02 09:41:41 -08:00
Gal Schlezinger
7b2fb70a67
Expose WASM bindings in Middleware (#34437)
This PR introduces a way to use WASM in middlewares.
Next.js will find all `.wasm` imports in middlewares and load them as `WebAssembly.Module` objects, which then can be later instantiated.
The metadata will be stored in `middleware-manifest.json`

## 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-03-02 15:09:36 +00:00
Sacha
b579a35e83
[examples] Update styled-components to use SWC (#34770)
* rename example with-styled-components to with-styled-components-babel

* update with-styled-components references

* update docs on react hydratation erros for styled components

* clone with-styled-components-babel without babel config

* add styledComponents to compiler options in next.config

* replace babel dependency with Next.js SWC compiler

* upgrade example typescript version

example with-typescript-styled-components had a typescript dependency
lower than the recommended version. Upgraded from 4.2.4 to 4.5.5.

* Apply suggestions from code review

* update readme for with-styled-components-babel

remove Notes section since it describes a workaround which is no longer
required to work with `next/link`.

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-02 03:43:34 +01:00
Lydia Hallie
abe4936701
Update cms-wordpress example (#34944)
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-03-02 01:48:05 +00:00
Cody Olsen
21c07ebf9e
docs: update cms-sanity example (#34898)
Upgrades `next-sanity` to the latest version and applies breaking changes.
Improves the docs for the Sanity example.

## Documentation / Examples

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



Co-authored-by: even westvang <172952+evenwestvang@users.noreply.github.com>
2022-03-01 23:42:00 +00:00
Shu Ding
9c0c93eb16
Optimize component type filters (#34941)
Since we are applying this loader to more files, and these two simple RegExp filters will be executed ~70 times per entry, it's an easy optimization to move the RegExp creation outside and merge related testers into the RegExp.

## 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-03-01 23:28:34 +00:00