Commit graph

10841 commits

Author SHA1 Message Date
Hassan El Mghari
ae2d901eed
Improve rewrites documentation (#34725)
This is a PR to update the rewrites documentation. This is after struggling to get rewrites to work with `trailingSlash` for a customer as this wasn't documented. The main culprit was the `:path*` wildcard not catching trailing slashes. The changes made to for this commit were:

- [x] Added example for redirecting to blog and docs
- [x] Expanded on original code example for external URLs
- [x] Added code example for using rewrites with `trailingSlash`

### Context

For a reproduction of the `:path*` wildcard not catching trailing slashes as expected, see below. Click on the "not working" demo link below, navigate to a specific blog post, then reload the page. It will redirect infinitely.

- [Not working demo of main repo with `:path*`](https://redirect-demo-git-not-working-nutlope.vercel.app/blog/)
- [Working demo of main repo with `:path(.+)`](https://redirect-demo.vercel.app/blog/)

If you want to take a look at the code, here are the full repos. They both have `trailingSlash: true`:

- [not working main repo](https://github.com/Nutlope/redirect-demo/tree/not-working) 
- [working main repo](https://github.com/Nutlope/redirect-demo)
- [blog repo](https://github.com/Nutlope/starter-blog-example)
2022-02-24 22:25:56 +00:00
Shu Ding
ceecf91225
Refactor entries generation in hot-reloader (#34733)
* refactor entries generation of hot-reloader

* change parameter name
2022-02-24 14:19:53 -08:00
Keen Yee Liau
fbb8536956
collect telemetry for ESLint rules (#34564)
This commit adds functionality to track usage of `@next/next/*` ESLint rules and their severity levels.

## 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`
- [x] Integration tests added
- [ ] Documentation added
- [x] 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-02-24 20:43:28 +00:00
Eungyeol
58ab94bef7
feat(create-next-app): add @types/react-dom to TS template (#34623)
* Add @types/react-dom devDependencies

* fix: eslint error

* fix: eslint error 2
2022-02-24 21:04:15 +01:00
Shu Ding
c9863c8794
Reduce the size of web server (#34767)
By moving `setRevalidateHeaders` to a separate file we can shake off the dependency of `etag` and a polyfill for `Buffer` from the web server (which brings hundreds of kilobytes).

## 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-02-24 19:53:17 +00:00
Gal Schlezinger
1a0d149c9f
produce source maps for middlewares (#34409)
This PR will generate source maps for middlewares. It's not under any flag (should it be?)

Closes #34523
2022-02-24 15:56:40 +00:00
Shu Ding
cc5345bba8
Add proper headers to responses in web server (#34723)
This PR adds the `X-Powered-By` and `Content-Type` headers to responses sent by the web server. The latter enables compression for the Edge runtime. Still, the web server doesn't have `Content-Length` and `ETag` as the response is usually dynamic.

Part of #31506.

## 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-02-24 12:43:22 +00:00
LongYinan
5d7c4dce9f
Upgrade @napi-rs/triples to support android arm platform (#34752)
Fix https://github.com/vercel/next.js/discussions/33530

`Android arm` is supported in https://github.com/vercel/next.js/pull/34481, but `@napi-rs/triples` was forgotten to upgrade in the previous pull request.
2022-02-24 10:15:51 +00:00
JJ Kasper
b8b9d3f663
v12.1.1-canary.2 2022-02-23 18:34:34 -08:00
Shu Ding
586616c4cb
chore: Move test for streaming and RSC (#34724) 2022-02-23 13:06:28 -06:00
Brody Dingel
33d961510e
Convert with-redis example to TypeScript (#34720)
With the recent push to get the examples in TypeScript, I thought I'd convert this `with-redis` example over.

## 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-02-23 18:52:57 +00:00
Pauldic
68e48a0809
Fix typo in documentation (#34734)
## 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-02-23 18:29:12 +00:00
Lengxu
c74d76540e
Fix create-next-app Multiple calls to the function 'makeDir' (#34669)
This PR fixes the Fix the create-next-app Multiple calls to the function 'makeDir'.
Currently, no execution errors are generated, but redundant execution exists.

## 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-02-23 13:00:26 +00:00
Reuben
70cd01015d
Fix CSS Loader Detection False Positives (#34584)
`test.css`, `test.scss` etc. will falsely match on a loader that searches for the string `test`


fixes #34583



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] 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-02-23 12:28:17 +00:00
JJ Kasper
99ee2225c1
Normalize image optimizer error status codes (#34699) 2022-02-22 19:29:53 -06:00
Kara
b3f2b38844
Remove page-specific font example from docs (#34694)
The Font Optimization docs have an outdated example that recommends
adding fonts via `next/head`. This is an anti-pattern that Next.js
has already warned about through ESLint for a while (see
https://nextjs.org/docs/messages/no-page-custom-font) and is now
starting to warn about through the console because it won't work
well with streaming architecture.

This change removes the outdated example from the docs.
Fixes #34693



## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-02-22 23:17:01 +00:00
Rishabh Poddar
037f79d51f
Updates with-supertokens example (#34679)
* add-supertokens-to-authentication.md

* bump supertokens deps

* update SuperTokens Auth doc

* Update docs/authentication.md

Co-authored-by: Lee Robinson <me@leerob.io>

* Update docs/authentication.md

Co-authored-by: Lee Robinson <me@leerob.io>

* updates supertokens dependency and optimises for serverless execution

* runs prettier-fix

* adds supertokens to 'Bring Your Own Database' section as well

* does not show home page if not logged in

* extracts config into its own file and calls it in all serverless functions

* removes need for backend init in app.jsx

* simplifies use of dynamic

* refreshes page after getServerSideProps

* removes unnecessary check in API

* update to docs pertaining SuperTokens

* adds placeholder secrets so that the UI loads on first run

* changes to readme

* updates version of supertokens frontend and backend SDK, and a few other fixes

* Update docs/authentication.md

Co-authored-by: Lee Robinson <me@leerob.io>

* updates to readme for supertokens example

* updates version of dependency

* updates dependency version

* updates to dependencies

* removes unnecessary config on frontend

* changes how redirection is done post signout

* update to dependency

* updates examples

* updates code to use for new package

* updates dependencies

* updates auth-react package

* with-supertokens example updated to use supertokens-node v7

* updates dependency

* updates supertokens-node version

* Update examples/with-supertokens/package.json

Co-authored-by: Lee Robinson <me@leerob.io>

* updates based on check-examples.sh script

* linter fix

* updates supertokens-auth-react dependency version

* adds development OAuth key to example

* removes section from README

* removes unnecessary file

* updates dependency versions

* with-supertokens: reduced bundle size by removing node lib from bundle

Linting fix

* Removed accidentally added config file

* adds sign in with apple

* extracted oauth keys to .env file

* fixes node init issue race condition

* removes unnecessary file

* updates supertokens-auth-react dependency

* updates superttokens-node dependency

* adds a cap to react dependency

* updates eslint-config-next version

* removes unnecessary dev dependency

Co-authored-by: NkxxkN <kevin@supertokens.io>
Co-authored-by: NkxxkN <kevin.antoine@protonmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Rishabh <rishabh@supertokens.io>
Co-authored-by: Bhumil Sarvaiya <sarvaiyabhumil@gmail.com>
Co-authored-by: jscyo <joelsteve97@hotmail.com>
Co-authored-by: Mihaly Lengyel <mihaly.lengyel@tresorit.com>
2022-02-22 10:37:47 -06:00
JJ Kasper
5f1536b3c5
Lock yarn pnp version in tests (#34688) 2022-02-22 10:29:46 -06:00
Steven
ea532c7b5c
Update CODEOWNERS to include renamed files (#34686)
* Update CODEOWNERS to include renamed files

* Add wildcard

* Reduce number of lines
2022-02-22 16:15:38 +01:00
Balázs Orbán
6178e7cf6d
fix: make sure image-config gets transpiled (#34677) 2022-02-22 09:27:18 -05:00
khuezy
8f65c38e20
Update testing.md (#34661)
https://playwright.dev/docs/ci#running-headed
Playwright runs headless by default.



## 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-02-22 03:06:03 +00:00
Noam Nol
7ec5d29d1f
Add .git to .dockerignore in docker examples (#34628)
* Add .git to .dockerignore in with-docker-multi-env

* Add .git to .dockerignore in with-docker
2022-02-21 21:53:56 +01:00
Jon Espen Kvisler
31d83852f8
Sentry example: add js types to SentryWebpackPluginOptions (#28726)
* Add js types to SentryWebpackPluginOptions

Enables code completion in Visual Studio Code (and perhaps other editors)

* Use partial type for SentryWebpackPluginOptions

This matches the expected type in e71454ef78/packages/nextjs/src/config/webpack.ts (L38)

* inline sentry config
2022-02-21 21:51:36 +01:00
Thijs-Jan
dc20805433
Provide more detail to static folder placement (#34651)
## 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`


I felt the current documentation was somewhat vague on where exactly the directories would need to go, when serving the `public` and/or `static` directory with the standalone mode.
2022-02-21 20:07:54 +00:00
JJ Kasper
3f9142f5de
Ensure rust-check skips on docs only change (#34648) 2022-02-21 13:45:40 -06:00
mxgnus
7d98537f95
added styled-components & replay support in swc (#34647)
styled-components & relay is supported in swc since nextjs 12.1
2022-02-21 12:28:38 -06:00
Balázs Orbán
30b434b533
fix: match redirect and rewrite destination types (#34617) 2022-02-21 12:21:54 -06:00
JJ Kasper
411a9b84d8
Add note about public folder with standalone mode (#34646) 2022-02-21 12:14:11 -06:00
Tim Neutkens
5c8e787803
Clarify test types during scaffolding (#34638) 2022-02-21 12:09:32 -06:00
Jiachi Liu
f110a3735b
Fix rsc bootstrap buffer missing in the future renders (#34631)
## Bug

If there's upcoming streaming data from server components, should safely skip the bootstrap process. Previously we deleted the buffer then it will cause the buffer is missing in the later re-renders. Now we mark it as empty array, so it can safely skip the boostrap phase

x-ref: #34475

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-02-21 12:40:59 +00:00
LongYinan
0243e6e95d
Add cargo clippy and cargo fmt to CI (#34625)
Run `cargo fmt` and `cargo clippy` and add them to CI.
2022-02-21 09:24:49 +00:00
Abhishek Garg
5a16b1a26f
removing redundant/unnecessary lines as these are defaults (#34587)
## 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-02-21 00:24:38 +00:00
Amirhossein Beigi
bf8b835e2e
fix: change showcase url (#34590)
## 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-02-19 22:33:32 +00:00
Tobias Koppers
94ad03385b
remove commons chunk config (#34445)
This removes the config for the `commons` chunk.

I think the idea was that modules are that in all pages are put into a `commons` chunk, but that breaks when next/dynamic comes into play, which also creates chunks. So the `totalPages` condition is broken and could lead to too many modules placed into the commons chunk.

Example: 2 pages, each has one next/dynamic. Both on demand chunks include module A. page 1 includes module B and next/dynamic on page 2 includes module B. A and B are placed into commons. commonjs chunk is loaded in page 1 and both next/dynamic. Page 1 would load module A even while it doesn't need it.

## 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-02-19 22:26:54 +00:00
Shu Ding
b701de60cd
Improve type imports in server/render and optimize the Edge SSR loader (#34552)
* reorganize imports

* code refactoring

* remove unused variables

* fix test

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-02-19 22:13:48 +01:00
Luis Alvarez D
27affb4141
Don't import internally from types in next-env.d.ts (#34394)
* Move type to image component

* Add types/global.d.ts to excludes too

* Undo global exclude as it's using internally

* Don't add root imports for module augmentations
2022-02-19 04:25:49 +01:00
JJ Kasper
4613e3be62
v12.1.1-canary.1 2022-02-18 17:19:57 -06:00
JJ Kasper
46d7f45dea
Update to latest version of jscodeshift (#34563)
* Update to latest version of jscodeshift

* update-compiled
2022-02-18 17:15:54 -06:00
Jiachi Liu
6ed281df8e
Support trailingSlash in middleware SSR (#34544)
## Bug

Fixes #34527 

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-02-18 22:39:28 +00:00
Steven
a4f5463eb5
Improve next/image warnings to avoid printing more than once (#34562)
Currently, we print warnings during `next dev` for every render of `next/image`, which can quickly fill the console making it really unfriendly to developers trying to read the logs.

This PR changes the behavior so that each unique warning prints at most once.

- Related to #33007 
- Related to #31340
2022-02-18 22:02:03 +00:00
Ephraim Atta-Duncan
2c80444f87
Simplify .env.local gitignores (#34471)
* ignore all .env files in default template

* ignore all .env files in typescript template

* ignore all local .env files in default template

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

* ignore all local .env files in typescript template

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-18 15:26:17 -06:00
Neeraj Dalal
71aa01902b
Updated head, img -> Image, type { NextPage } as default next-app (#34513)
Everything updated in accordance to latest yarn create next-app



## 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-02-18 21:15:25 +00:00
Nate Wienert
97b964a18f
feat(react-dev-overlay): export getErrorByType and add preventDisplay prop (#34237)
Report full parsed runtime errors over error bus, accepts preventDisplay prop to avoid showing error messages inline, while still reporting errors over the bus.

Basically, we want to handle the parsed error/stack differently in Next Live, showing a modal that sits above the content and allows users to report the issue to us. We want to have that stack trace in the issue report, so I added a new event `unhandled-error-full`.

The `preventDisplay` prop then just lets us output our own modal instead of showing the error inline, but still renders the `<RuntimeErrors />` component so it can fetch the stack and report it over the bus.

This isn't *beautiful* code per-se, but I think doing it really right would require a pretty intense re-structure of this module. I think ideally we'd have export a function to fetch of the stack that we can just expose separately - that fetch currently happens in a sub-sub-component (DevOverlay > Errors > RuntimeError). But that re-write is pretty high effort, would still require much of what we do here anyway, and would just to get a slightly less awkward API in a not very high-use area. So leaving it as-is for now, happy to revisit though if we want.

## Feature

- [x] Related issues linked using `fixes #number`

Fixes an issue with Next Live #290.

## Documentation / Examples

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-18 21:09:09 +00:00
Gal Schlezinger
e251a8b2d8
Add test for multiple cookies coming from middleware (#34465)
This PR adds a test that ensures that we can set multiple cookies in a middleware response
2022-02-18 20:35:22 +00:00
JJ Kasper
271dff5be8
Update swc crates (#34491)
* Revert "Revert swc css bump temporarily (#34440)"

This reverts commit 01524ef20f.

* Update css crates

Co-authored-by: Donny/강동윤 <kdy1997.dev@gmail.com>
2022-02-18 14:02:54 -06:00
Javi Velasco
8752464816
Allow reading request bodies in middlewares (#34294) (#34519)
This PR brings back @Schniz awesome contribution to bring in bodies to middleware. It was reverted to leave it out of the stable release and to have some time to test it out in canary before officially releasing it. This PR is simply a `cherry-pick` of his original work.

Closes: #30953 
Closes: https://github.com/vercel/next.js/pull/34490

Co-authored-by: Gal Schlezinger <2054772+Schniz@users.noreply.github.com>
2022-02-18 19:43:43 +00:00
Gerald Monaco
204a95586d
Remove useMaybeDeferContent hook (#34506) 2022-02-18 13:07:19 -06:00
Mitchell Abbott
670eb03841
Convert custom-server-hapi Example to Typescript (#34507)
In the contributing doc, it mentions "Examples should be TypeScript first, if possible" so I thought about converting some examples to be typescript along with updating a couple in my free time. Let me know if that would be an issue.

## 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-02-18 18:51:02 +00:00
Steven
9e77ef4ec6
Fix next/image incorrectly warning for position: absolute parent (#34551)
- Fixes #33007 
- Fixes #31340
2022-02-18 18:44:32 +00:00
JJ Kasper
44bc4d92f5
v12.1.1-canary.0 2022-02-18 12:02:13 -06:00