Commit graph

5378 commits

Author SHA1 Message Date
Shu Ding
3e8099e680
Fix flight loader (#36282)
* make sure `left` is defined
2022-04-19 20:14:30 +02:00
Shu Ding
90d3478c52
Use renderToStaticMarkup to render documentHTML (#36213)
There wasn't a strong reason to choose `renderToStream` over `renderToStaticMarkup` for the document wrapper. But due to problems like #35870, we can switch back to the static renderer for now.

Fixes #35870.

## 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-04-19 17:20:20 +00:00
Tim Neutkens
0e2fd9280a v12.1.6-canary.4 2022-04-19 14:44:21 +02:00
Sean Parmelee
ffdb9f847f
fix type definition for defaultGetInitialProps (#36252)
## Bug

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

This PR fixes #36247 by adding the optional `options` object to the type definition for `DocumentContext.defaultGetInitialProps`.
2022-04-19 12:37:57 +00:00
OJ Kwon
deb82802a4
fix(next-swc/ssg): less aggressive exports drop (#36199)
This PR attempts to fix #31855, by loosening conditions to determine what to drop when swc runs transform. Currently, it drops all the export declaration if it's being referenced only in getstatic* in local scope. But as `export` implies, there's no guarantee given export will be used in other modules even if it's not being used in local scope. PR tries to not to drop exports declarations as much if it's not being used locally other than getstatic*. This makes dropping bit ineffecient, but as long as we can't cross-ref across modules that's something unavoidable in my opinion.

I don't think implementation itself is quite acceptable: probably need review & revise to the logics. 

## Bug

- Attempt to close #31855

- [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`
2022-04-19 12:13:57 +00:00
Forrest
562e4283f9
Use finally to clean up seen requests (#36222)
* try-finally for router execute request references

* lint

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-04-18 13:16:39 -05:00
Jiachi Liu
d895a50abb
rsc: skip next builtin module when apply loaders (#36202)
x-ref: https://github.com/vercel/server-components-notes-demo/pull/17

Previously in #35975 we ignore handling node_modules as a workaround for 3rd party packages, but for next buildin components we should still handle them for processing client components
2022-04-17 01:38:56 +00:00
JJ Kasper
e80c48e009
v12.1.6-canary.3 2022-04-16 11:15:20 -05:00
Sukka
a001153c8b
perf(escapeStringRegexp): test before replace (#34472)
## 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-04-16 05:42:10 +00:00
Alex Page
3130ed7d48
404 page - Responsive color scheme (#32113)
* Responsive color scheme 404 page

* correct styles

* typo

* consistent spacing

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-04-16 00:05:48 -05:00
JJ Kasper
63230ebce2
Fix build activity indicator position (#36208)
* Fix build activity indicator position

`devIndicators.buildActivityPosition` introduced in
https://github.com/vercel/next.js/pull/30109 needed more tweaks to properly
position the build indicator container. The build indicator was being rendered
off screen when set to a non-default position.

* Refactor stuff for smaller diff

* add config validation

* Apply suggestions from code review

Co-authored-by: Martin Šťovíček <martin.stovicek@monitora.cz>
2022-04-15 23:53:00 -05:00
Björn
f73e7d51ad
Improve NextApiHandler type for early returns (#35166)
I would like to be able to write handlers with early returns like this:

```typescript
import { NextApiHandler } from 'next'

const handler: NextApiHandler = (req, res) => {
  const value = getStuff()
  if (value === 'branch') {
    return res.json({}) 
  }
  res.status(400)
}
```

but `NextApiHandler`'s current return type is `void | Promise<void>`, which causes compilation to fail with

```
Error:(11, 3) TS2322: Type '(req: NextApiRequest, res: NextApiResponse<any>) => Promise<NextApiResponse<any> | undefined>' is not assignable to type 'NextApiHandler<any>'.
  Type 'Promise<NextApiResponse<any> | undefined>' is not assignable to type 'void | Promise<void>'.
    Type 'Promise<NextApiResponse<any> | undefined>' is not assignable to type 'Promise<void>'.
      Type 'NextApiResponse<any> | undefined' is not assignable to type 'void'.
        Type 'NextApiResponse<any>' is not assignable to type 'void'.
```
to avoid that the above snippet needs to be written as

```typescript
  if (value === 'branch') {
    res.json({}) 
    return
  }
```
which looks odd to me. Changing the return type of `NextApiHandler` to `unknown | Promise<unknown>` would allow for shorter early returns and still communicates to users that nothing is expected to be returned from a handler.

Augmenting the type like this, makes the first snippet work:
```typescript
import { NextApiRequest, NextApiResponse } from 'next'

declare module 'next' {
  export declare type NextApiHandler<T = any> = (
    req: NextApiRequest,
    res: NextApiResponse<T>
  ) => unknown | Promise<unknown>
}
```



## 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-04-16 04:00:52 +00:00
Kiko Beats
8f8e497e1b
fix(NextResponse.json): pass options (#35367) 2022-04-15 22:23:42 -05:00
Sukka
3ae571d97b
refactor(build): no force transpile optional chaining / nullish (#35976) 2022-04-15 21:48:43 -05:00
Jiachi Liu
fe6e74dc57
Fix missing _app component of AppTree in gIP context (#36206)
## Bug

The custom app is missing in the `ctx.AppTree` that causing the issue, it was accidently missed in custom _app.server pr #35666

Fixes #36198

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-04-16 01:55:16 +00:00
JJ Kasper
9c7311b1a5
v12.1.6-canary.2 2022-04-15 14:08:42 -05:00
Steven
4c15f89b53
Add support for tsconfig moduleResolution node | node12 | nodenext (#36189)
- Fixes #35572 

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-04-15 17:09:12 +00:00
YOSHIKI
84d97b1b82
[eslint-config-next] Update @typescript-eslint/parser to v5.19.0 (#36156)
fixes #35784

## 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`
2022-04-15 15:27:17 +00:00
Steven
4c872cb2dc
Fix next/image usage in most cases of onLoad() (#36176)
Even though we never documented it, the `onLoad` prop used to work (in most cases) in Next.js 12.1.4 and broke in 12.1.5 once the code was refactored in PR #35889.

We still shouldn't document it because `onLoad` doesn't work in all cases so [`onLoadingComplete`](https://nextjs.org/docs/api-reference/next/image#onloadingcomplete) is preferred, however tests were added for the cases that do work.

Use cases that don't work with `onLoad` are Data URLs as well as `loading="eager"`.
2022-04-15 15:02:23 +00:00
Donny/강동윤
cbb64ee554
Update swc (#36187)
This PR updates swc crates to b8d9a58f13


- Closes #35811
- Closes #34811
  - I tested with https://github.com/balazsorban44/issue-34811

<img width="1840" alt="image" src="https://user-images.githubusercontent.com/29931815/163574875-d7392c4c-b1f1-4503-aac1-35a26c9d7ec2.png">

- Closes #34715
  - I tested with https://github.com/cungminh2710/nextjs-swc-mapbox

<img width="1840" alt="image" src="https://user-images.githubusercontent.com/29931815/163574677-9733dd69-9938-4e3e-b2f1-bfbd6db9e20c.png">


 - This fixes the bug reported in the comment (https://github.com/vercel/next.js/issues/36127#issuecomment-1099794402), but I didn't test the issue itself.
2022-04-15 14:34:32 +00:00
Tim Neutkens
1582e11185
Fix res.json support for string / null (#36186)
Continuation of #33592 with updates tests / changes.

Co-Authored-By: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-04-15 16:04:00 +02:00
Michael Ward
1be5f36123
Adds linting rule to avoid assignment to 'module' variable. Fixes #34859 (#35279) 2022-04-15 14:45:53 +02:00
Tommaso De Rossi
5a785e45c7
Fix symlink and copy logic to standalone directory when using outputStandalone (#35535)
* fix symlink logic with outputStandalone

* refactored and commented copy function

* faster symlink check

* removed Dockerfile

* removed console.logs from test

* fix symlinksOutsideRoot test

* removed a console.log for files out of root

* added missing types to copy

* removed custom copy function, fix symlink code

* test outputStandalone and pnpm

* appProcess is no more a promise

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-04-15 14:35:47 +02:00
Jiachi Liu
aac0559f7e
Fix text decoding for chunk (#36165)
CF worker cannot write a decoded chunk

```
Uncaught (in response) TypeError: This TransformStream is being used as a byte stream, but received a string on its writable side. If you wish to write a string, you'll probably want to explicitly UTF-8-encode it with TextEncoder.
worker.js:61 Uncaught (in promise) TypeError: This TransformStream is being used as a byte stream, but received a string on its writable side. If you wish to write a string, you'll probably want to explicitly UTF-8-encode it with TextEncoder.
    at Object.write (worker.js:61)
    at worker.js:46
```
2022-04-14 17:27:31 +00:00
JJ Kasper
6907519155
v12.1.6-canary.1 2022-04-14 10:23:58 -05:00
JJ Kasper
cb526f5797
Update to target es5 for use-subscription (#36159)
This ensures we use the `es5` target when pre-compiling the `use-subscription` dependency similar to our other pre-compiled browser dependencies. 

## 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/issues/36146
2022-04-14 15:04:42 +00:00
Jiachi Liu
a4aa1df7da
rsc: keep static page props (#36157) 2022-04-14 14:35:09 +00:00
Jiachi Liu
953cd9af33
rsc: mark next head as client component (#36138)
Follow up of #36135 

Add `next/head` as client component
2022-04-13 23:36:16 +00:00
Preston Richey
a5103d2e34
Add support for catch-all route params in NextRequest page type declaration (#36137)
fixes https://github.com/vercel/next.js/issues/36136

## 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`
2022-04-13 23:08:53 +00:00
Jiachi Liu
f74b59c48c
Reogranize the client component detection utils (#36135)
Refactor:

- group client components detction util
- add next script as rsc client component
2022-04-13 22:35:11 +00:00
Jiachi Liu
1e451ab716
Fix req.url of rsc dynamic routes pages gSSP in edge runtime (#36134)
We were feeding pathname like `/routes/[dynamic]` as `req.url` to RSC pages in edge runtime, which is not aligned with node runtime

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-13 21:31:53 +00:00
JJ Kasper
d24eeb647f
Fix only generated case in minimal mode (#36130) 2022-04-13 15:04:00 -05:00
JJ Kasper
bc40c0b530
v12.1.6-canary.0 2022-04-13 12:45:39 -05:00
Shu Ding
a4a970bafa
Support necessary headers in the web server response (#36122)
This PR adds support of `Content-Length`, `Etag` and `X-Edge-Runtime` headers to the web server.

## 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-04-13 17:14:53 +00:00
JJ Kasper
74dead2489
Add experimental onlyGenereated flag for unstable_revalidate (#36108)
* Add experimental ifGenereated flag for unstable_revalidate

* Apply suggestions from code review

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

* update ifGenerated -> onlyGenerated

* rename const as well

Co-authored-by: Steven <steven@ceriously.com>
2022-04-13 11:56:58 -05:00
Naoyuki Kanezawa
1d8165bd79
fix: do not add locale prefix to api route on NextURL (#36118)
Fixes https://github.com/vercel/next.js/issues/35694

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-13 15:30:03 +00:00
Donny/강동윤
4bf01d4ec8
feat(next-swc): Update css parser (#36114)
This only applies 81370d16cb

This fixes parsing of legacy `calc`s.
2022-04-13 09:09:52 +00:00
Shu Ding
19b625e0c5
Fix export from and native modules in server component (#36072)
This PR fixes a bunch of bugs and it now supports:
- Importing a client component from a nested server component (a.server → b.server → c.client).
- The `export from` syntax in server component (`export { default } from './a.server'`)
- Native modules in server components (currently broken)

## Buga

- [ ] 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-04-13 08:50:36 +00:00
Jiachi Liu
20600ad29f
rsc: remove router injection (#36101) 2022-04-13 10:16:29 +02:00
JJ Kasper
38d17bca0c
v12.1.5 2022-04-12 14:40:16 -05:00
JJ Kasper
9c613aaa66
v12.1.5-canary.7 2022-04-12 13:35:53 -05:00
Kiko Beats
46d3f0e216
fix(next-url): print properly using logger symbol (#36097)
Hello,

This PR adds a method to have a custom inspect for `NextURL`

closes #35519
2022-04-12 15:31:29 +00:00
LongYinan
da6f271d9b
Interpolate module.exports as default import (#36082)
fixes https://github.com/vercel/next.js/issues/34412

## 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`
2022-04-12 14:32:42 +00:00
JJ Kasper
a9d6d9f71a
v12.1.5-canary.6 2022-04-11 16:27:07 -05:00
JJ Kasper
95a8f31d86
Fix outputStandalone with optimizeCss (#36028) 2022-04-11 16:14:28 -05:00
Ethan Arrowood
8c5797959c
update @vercel/nft to 0.18.1 (#36075)
* update @vercel/nft to 0.18.1

* update-compiled

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-04-11 15:45:40 -05:00
JJ Kasper
da39e29c27
v12.1.5-canary.5 2022-04-11 12:00:35 -05:00
Naoyuki Kanezawa
93678b569b
Do not add locale to link for api route and middleware preflight (#35994)
Fixes https://github.com/vercel/next.js/issues/33578

This PR fixes `Link` component as well to not add locale for api routes since both preflight redirect and link should work the same.

Additionally, it fixes the webdriver method `browser.waitForCondition()` for playwright to not wrap with function string.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-11 15:59:07 +00:00
LongYinan
aaa823c3fa
Interpolate default exports is now unnecessary (#36065)
## 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-04-11 15:36:25 +00:00
Donny/강동윤
16f7084e7f
feat(next-swc): Update swc crates (#35996)
* Move

* Adjust

* publish = false

* Tree

* Move tests

* fixup

* Split `emotion`

* Split `styled_jsx`

* Split `styled_jsx`

* fmt

* `--fix`

* clippy

* Update crates

* fixup

* publish

* Bump

* Rename

* authors

* Update

* More update

* Oh

* Update test refs

* Update test refs

* Update again

* Fix
2022-04-11 11:59:16 +02:00