Commit graph

12000 commits

Author SHA1 Message Date
Duc Tran
b7997105a0
fix: use if...else in dockerfile (#39263)
* fix: use if-else in dockerfile

* fix: remove typo
2022-08-02 17:01:24 -05:00
JJ Kasper
cd3e054f14
Ensure middleware has single data fetch on query hydration with valid props (#39210)
* Ensure middleware has single data fetch on query hydration with valid props

* re-add check

* fix redirect case
2022-08-01 21:39:58 -05:00
Colin McDonnell
c4e8d7d7a3
Update edgedb.toml (#39243)
Update `with-edgedb` to use `2.0`.
2022-08-02 02:31:04 +00:00
Matt DuLeone
0e5a0ec4e0
Clear up rewrites documentation (#39238)
## Documentation / Examples

This PR specifically calls out in more clear language how the rewrites function behaves. This tripped me up recently as I recently came looking for more information, and the documentation left me with more questions than answers. This is an attempt to clear up the confusion I walked away with for anyone who comes in after me.

- [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-08-02 02:18:21 +00:00
Gal Schlezinger
e3181c2d77
Export URLPattern from next/server (#39219)
This commit allows the users to import URLPattern from `next/server`,
by defining a key that uses `global.URLPattern`.

Why is this any good? or: why don't we add URLPattern to the global namespace?

URLPattern is exposed as global on Edge Runtime _only_. This means that if we define a
constructor in global namespace in our TypeScript definitions, people might
have runtime errors in their Node.js functions.

Importing from `next/server` enables users to get the constructor without
risking in runtime errors and wrong type definitions.

Keep in mind, that with the current implementation, we do not check if the
constructor actually exists, but `next/server` shouldn't be imported in
Node.js functions, AFAIK.

## Related

- Fixes #38131

## Bug

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-02 02:04:08 +00:00
JJ Kasper
ad75204b34
v12.2.4-canary.9 2022-08-01 17:51:35 -05:00
JJ Kasper
7c0a504a16
Handle assetPrefix in app (#39236)
This ensures we properly leverage the `assetPrefix` for `app`. Note for reviewing the test changes are mostly spacing so hiding that may help. 

## Bug

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

Fixes: [slack thread](https://vercel.slack.com/archives/C035J346QQL/p1659387244559979)
2022-08-01 22:34:23 +00:00
Steven
d56aadae5b
Update tests to use random directory (#39230)
This PR fixes an issue where tests fail because the generated tmp directory already exists. This is likely caused from two tmp dirs being generated in the same millisecond.

```
Failed to create next instance [Error: EEXIST: file already exists, mkdir '/tmp/next-repo-1659368089063/packages'] {
  errno: -17,
  code: 'EEXIST',
  syscall: 'mkdir',
  path: '/tmp/next-repo-1659368089063/packages'
}
```

https://github.com/vercel/next.js/runs/7615808051?check_suite_focus=true
2022-08-01 19:05:48 +00:00
Alex Castle
cbaaaeb076
Add "fill" mode to next/future/image (#38855)
This PR adds a `fill` attribute to the future image component, that behave similarly to the fill mode on the existing image component.

Functionally, it mainly adds `position: "absolute"` and `object-fit: "contain"` to the image element, along with `height: "100%"` and `width: "100%"` to preserve the image aspect ratio. All of these can be overwritten by the user, except for `position: "absolute"`, which will throw an error. This is because changing that property without height and width is likely to cause layout shift.

Because we no longer have the wrapper element, this new version of `fill` requires that the user set `overflow: "hidden"` on the parent element themself, if they want that behavior.

This PR also includes several runtime checks to catch instances where the fill mode may provide unexpected results. These runtime checks warn if:
* The image doesn't have the `sizes` attribute and loads much smaller than the viewport
* The containing element does not have `position: "relative"`
* The image height value is 0

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-08-01 18:21:36 +00:00
Jiachi Liu
e9d23d709c
fix: react dev bundle is picked in prod mode (#39221)
When we detect if `reactRoot` rendering should be enabled we `require` the require to check the version. But at that time the `NODE_ENV` isn't set yet. Then the react dev build stays in the `require.cache` that any future require of react will get the wrong build. In that case, React dev bundle is picked in production mode.

Fun fact: if you're using hooks, that seem not to effect you, but context consumer works different then you couldn't get the proper context from provider.

Fixes #38176
Fixes #38765
Fixes #38332

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-01 14:21:42 +00:00
Jiachi Liu
582cb3766d
Fix: only contain middleware in dev middleware manifest (#39217)
x-ref #39199

The change in #39199 isn't correct. Middleware manifest should only contain middleware route, so that when router navigates, it only try to apply middleware instead of checking all edge routes. This PR also changes the middleware manifest global value from array to object for easier access

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-01 13:23:24 +00:00
NikhilNama18
f0df2c274d
Replaces getStaticProps with getStaticPaths (#39218)
In `Generating paths on-demand` section 
It was mentioned that `getStaticProps` allows you to control which pages are generated during the build. 
But `getStaticPaths` will allows us to control which pages are generated during the build.



## 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-08-01 12:48:06 +00:00
John Daly
0c734543a6
examples/with-msw-typescript (#39196)
## Documentation / Examples

Updating the `with-msw` example to use TypeScript

- [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-07-31 15:54:30 +00:00
Santi Dalmasso
de6fc1cf35
fix: Update testing.md (#39195)
Update `e2e/example.spec.ts` ([/docs/testing](https://nextjs.org/docs/testing#creating-your-first-playwright-end-to-end-test) page) to fix the failed test. Fixes: #39194
## 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

- [ ] 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?rgh-link-date=2022-07-13T09%3A09%3A13Z#adding-examples)
2022-07-31 15:30:38 +00:00
Jiachi Liu
e42c88d8a9
Fix missing edge routes in dev middleware manifest (#39199)
## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-07-31 15:20:32 +00:00
Jessica Franco
97ab23fb6f
Add missing @napi-rs/cli devDependency to next-swc (#39164)
Otherwise build-native fails with "napi: command not found.".

Alternatively, this is missing from this package's devDependencies.



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

P.S.: local copy fails `pnpm lint` due to the `target` subfolder with intermediate rust build artifacts... should I add a `.prettierignore` update to exclude `/packages/next-swc/target/`?

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-30 22:08:50 +00:00
Jiachi Liu
9a1b756def
refactor: simplify middleware execution (#39192)
* refactor: simplify middleware execution

* remove ssr prop from RoutingItem

* fix build
2022-07-30 16:45:58 -05:00
Severin Ibarluzea
dce8c0ce9d
fix(#11930): rewritten api routes can correctly handle cors in dev mode (#38937)
* fix(#11930): rewritten api routes can correctly handle cors in dev mode

* test that request matches hot reloader middleware instead of api https://github.com/vercel/next.js/pull/38937#pullrequestreview-1055957698

* remove unnecessary imports

* remove unused constant

* remove api route import
2022-07-29 21:39:43 -05:00
Jiachi Liu
960693b920
refactor: return single middleware from getMiddleware in dev server (#39177)
Previous next versions supported nested version of middleware, now we simplify it to one global middleware. This PR clarify the middleware and edge functions usage in dev server
2022-07-29 23:37:59 +00:00
Baris Sayil
801acad17a
Fix typo in with-docker-compose README (#39176)
- [x] Simply fix a typo.
2022-07-29 20:00:18 +00:00
JJ Kasper
9fed522c42
Fix default error style overrides (#39169) 2022-07-29 13:09:41 -05:00
JJ Kasper
860c0281b1
Add exportPathMap config type/schema field (#39171) 2022-07-29 12:59:00 -05:00
Jiachi Liu
b1a5821ee0
Add shared dynamic api (#39163)
Add `next/dist/client/components/shared/dynamic` as shared api which server and client components can both support. 
Dynamic imports will be part of flight on server side.
This pr doesn't contain preloading part for client components.
2022-07-29 11:03:05 +00:00
JJ Kasper
48405e6bd7
v12.2.4-canary.8 2022-07-28 23:34:07 -05:00
JJ Kasper
d12272a6fa
Fix incorrect component cache for middleware cases (#39159) 2022-07-28 23:33:17 -05:00
Donny/강동윤
eb0e161f2e
Update swc minifier (#39158)
This PR applies

 - https://github.com/swc-project/swc/pull/5333
   - Closes https://github.com/vercel/next.js/issues/39090
2022-07-29 03:26:28 +00:00
JJ Kasper
cf729edc9d
Add caveat note about shallow routing with middleware (#39154) 2022-07-28 21:28:34 -05:00
JJ Kasper
d091c818c5
v12.2.4-canary.7 2022-07-28 20:24:34 -05:00
JJ Kasper
a154c15799
Fix middleware + afterFiles SSG rewrite case (#39153) 2022-07-28 20:23:18 -05:00
Tim Neutkens
c567d7d2da
Refactor Flight plugins to use types. (#39136)
Cleans up both Flight plugins and leverages type inference more.
- Rename plugin
- Update name
- Remove note on webpack5
- Add types for Flight manifest
- Use webpack5 type and tapPromise
- Remove any



## 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-07-28 22:35:52 +00:00
JJ Kasper
a08415be32
v12.2.4-canary.6 2022-07-28 16:03:26 -05:00
JJ Kasper
e3efc030cd
Ensure we hard navigate for failed _next/data with middleware (#39148)
* Ensure we hard navigate for failed _next/data with middleware

* fix-lint
2022-07-28 15:48:26 -05:00
Houssein Djirdeh
a8186065b8
[Script] Adds onReady prop to next/script (#38849)
Closes: #30962

This PR adds a new `onReady` prop to `next/script` to handle shortcomings of the current `onLoad` prop. Some third-party providers and widgets require initialization code to run after the script's `load` event and every time the component is mounted. The `onReady` should solve that use case.

For more details, refer to the discussion in #30962.

CC @janicklas-ralph

## Bug

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-28 20:42:52 +00:00
Keen Yee Liau
85b00b2cca
Collect telemetry for next/future/image (#39046)
* test: cleanup telemetry integration test

Instead of constantly parsing the console output, parse the output
once, convert the entries in JavaScript objects, then compare them
logically rather than textually.

* Collect telemetry for next/future/image

Track adoption of next/future/image and add relevant test.
2022-07-28 15:03:24 -05:00
JJ Kasper
ec2f0a8c4b
v12.2.4-canary.5 2022-07-28 12:00:28 -05:00
Donny/강동윤
4eac75bbc9
feat(next-swc): Update swc (#39055)
## 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-07-28 16:04:02 +00:00
Lafif Astahdziq
377fddfaa9
fix: missing semicolon on Dockerfile (#39142)
The commit 0a781dd675 changes the docker examples to use `if..elif..else`

it is working fine tor the `with-docker` example, but not working for the `with-docker-compose` and `with-docker-multi-env` examples due to a missing semicolon.

Fix #39085



## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-28 15:23:11 +00:00
Tim Neutkens
70e4cf6d28 v12.2.4-canary.4 2022-07-28 10:49:03 +02:00
JJ Kasper
f1aac90c7b
Fix unhandled rejections with edge runtime (#39091)
This corrects some unhandledRejection errors showing when a connection is canceled with the edge runtime since the changes needed for 14463ddd10. This also adds a regression test to ensure we don't have these class of errors in our middleware tests. 

## Bug

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

Fixes: [slack thread](https://vercel.slack.com/archives/C03Q1UU3Z4H/p1658960102013969)
2022-07-28 07:50:51 +00:00
nasso
c4d41255fe
Convert the Cypress config to ESM Module syntax (#39036)
This seems to be what is recommended by the Cypress documentation:
https://docs.cypress.io/guides/references/configuration



## 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-07-28 05:39:47 +00:00
JJ Kasper
541d8c663d
Update pre-compiled to fix check (#39089) 2022-07-27 20:44:39 -05:00
JJ Kasper
84fcbd56bc
v12.2.4-canary.3 2022-07-27 20:00:50 -05:00
JJ Kasper
3a31b96f26
Ensure query is updated correctly with shallow and middleware (#39086)
This ensures we properly update the query when doing a shallow navigation with middleware present and expands our test coverage of this kind of navigation. This also adds middleware rewrite coverage for the case described in https://github.com/vercel/next.js/issues/38405  and ensures we properly resolve dynamic middleware rewrites which was causing https://github.com/vercel/next.js/issues/39049

Test deployment with fix can be seen [here](https://middleware-i18n-redirect-repro-8jd3x47j9-ijjk-testing.vercel.app/gsp/first) and [here](https://nextjs-middleware-rewrite-l6q20cwo3-ijjk-testing.vercel.app/)

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/38495
Fixes: https://github.com/vercel/next.js/issues/39049
Fixes: https://github.com/vercel/next.js/issues/38405
2022-07-28 00:52:56 +00:00
Shu Ding
600bdb1eb5
Remove RSC rendering from render (#39045)
(For context, the logic and tests have been moved to `app-render`.)

## 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-07-27 22:11:02 +00:00
Max Proske
e955850dd4
Convert cms-agilitycms example to TypeScript (#38976)
Converted `cms-agilitycms` example to TypeScript to match Contribution docs.

## 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-07-27 19:24:54 +00:00
Thuy Doan
44b5534b85
feat(with-mux-video): Update mux-player scope and version to latest. (#39079)
# Description
Updates `with-mux-video` example to use latest scope and version of `@mux/mux-player-react` 🌈
2022-07-27 16:52:29 +00:00
JJ Kasper
889481e85f
Update delayed test output handling (#39078) 2022-07-27 11:41:42 -05:00
Balázs Orbán
34f5236f57
fix: show asPath on large page data warning (#39071)
Fixes #39057

Will now show:
```
Warning: data for page "/[[...slug]]" (path "/some-page") is 256 kB which exceeds the threshold of 128 kB, this amount of data can reduce performance.
See more info here: https://nextjs.org/docs/messages/large-page-data
```

## 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-07-27 15:15:37 +00:00
Balázs Orbán
0a781dd675
fix: use if..elif..else in docker examples (#39072)
* fix: use `if..elif..else` in docker examples

* fix missing devDependencies for build

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-07-27 09:54:04 -05:00
Kiko Beats
0ebd53fdb5
fix: print Request & Response properties (#38903)
* Add inspect symbol for request

WIP

* Add inspect symbol for response

* build: upgrade edge-runtime
2022-07-27 09:16:16 -05:00