Commit graph

3893 commits

Author SHA1 Message Date
Tobias Koppers
dc1e906eb2
update webpack to 5.52.0 (#28771) 2021-09-06 10:59:23 +02:00
Tobias Koppers
289edaea16
mini-css-extract-plugin should not bundle webpack code (#28822) 2021-09-06 10:53:06 +02:00
Tim Neutkens
16d6eba1c9
Reuse warning from postcss-loader (#28727)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-09-05 14:22:34 +02:00
Gerald Monaco
7f83e6d15d
Add RenderResult class (#28776) 2021-09-04 09:41:06 -05:00
JJ Kasper
85366a0244
v11.1.3-canary.8 2021-09-03 16:48:00 -05:00
Pablo Espinosa
a8088bfd67
feat: Adding generic typing for previewData (#28668)
on GetServerSidePropsContext and GetStaticPropsContext

As discussed on #21574 having a generic type will give it more flexibility and remove linting errors.

## 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 #21574 
- [ ] 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`
2021-09-03 21:27:17 +00:00
JJ Kasper
14a999ed73
Ensure build trace handles mixed modules (#28770) 2021-09-03 11:30:00 -05:00
Steven
1eb3bd9240 v11.1.3-canary.7 2021-09-02 19:09:08 -04:00
Steven
31fef9ae5d v11.1.3-canary.6 2021-09-02 18:24:42 -04:00
jj@jjsweb.site
2c27f995e4
v11.1.3-canary.5 2021-09-02 16:48:25 -05:00
Steven
7980bcd453 v11.1.3-canary.4 2021-09-02 17:32:48 -04:00
Jiachi Liu
7f09df3483
Fix typings of dynamic suspense (#28740)
x-ref: https://github.com/vercel/next.js/pull/27611#issuecomment-911743160
2021-09-02 16:14:48 +00:00
Tim Neutkens
d310009c9b v11.1.3-canary.3 2021-09-02 13:40:21 +02:00
Tim Neutkens
5a2634e015
Update css-loader runtime to use compiled files (#28735) 2021-09-02 13:39:19 +02:00
Tim Neutkens
eaea8cb294
Remove .next/traces directory as it's not used (#28728)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-02 13:28:51 +02:00
Tim Neutkens
3693ed2e0e v11.1.3-canary.2 2021-09-02 08:55:58 +02:00
Tim Neutkens
9a56fdba82
Use consistent postcss version for all transforms (#28529)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-09-02 08:45:35 +02:00
jj@jjsweb.site
899683c3d5
v11.1.3-canary.1 2021-09-01 14:44:53 -05:00
JJ Kasper
2d1cb8fe8b
Ensure @babel/core is not duplicated (#28716)
Follow-up to https://github.com/vercel/next.js/pull/28713 this ensures we also don't duplicate `@babel/core` in our `babel-packages` bundle. This was occurring from us re-using the `@babel/core` package name which causes us to remove it from the externals [here](77c0e09371/packages/next/taskfile-ncc.js (L18-L21)).
2021-09-01 19:29:35 +00:00
JJ Kasper
77c0e09371
Ensure @babel/types is not duplicated (#28713)
This is a follow-up to https://github.com/vercel/next.js/pull/28174 to ensure we de-dupe `@babel/types` correctly as this increased the compiled `babel` packages quite a bit.
2021-09-01 17:46:50 +00:00
Jiachi Liu
ed9b8863b4
fix: should allow nullable param for res.end (#28694)
## Bug
Fixes #28693

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-09-01 17:01:00 +00:00
JJ Kasper
9a6542ba68
Ensure build trace is correct with extra entries (#28667)
* Ensure build trace is correct with extra entries

* lint-fix

* fix check on windows
2021-09-01 10:56:04 -05:00
jj@jjsweb.site
c1a97e557b
v11.1.3-canary.0 2021-08-31 16:11:16 -05:00
Steven
acf65f92dc
Fix TS type conflict for <img> tag (#28672)
This type was added in PR #28269 but doesn't need to be public and was causing conflicts with `@types/react@17`.

We currently use `@types/react@16` so ideally we should upgrade to `@types/react@17` and then remove the `ts-ignore`.

Fixes #28647
2021-08-31 19:03:08 +00:00
Tobias Koppers
f6d8a112df
fix esm externals edge case with "module" condition (#28612)
prefer commonjs externals even if "module" condition is used in package.json



## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-08-31 08:32:33 +00:00
Tim Neutkens
97456e81ce v11.1.2 2021-08-31 07:15:17 +02:00
jj@jjsweb.site
248b34105b
v11.1.2-canary.0 2021-08-30 21:48:53 -05:00
JJ Kasper
ff9dcc6a47
Ensure custom app regex is correct for Windows (#28631)
* Ensure custom app regex is correct for Windows

* lint-fix

* update test for ie

* update test

* lint-fix
2021-08-30 20:09:48 -05:00
Kara
9be387c7f4
getServerSideProps should support props value as Promise (#28607)
Previous to this change, getServerSideProps could only return plain objects
for props, e.g.:

```javascript
export async function getServerSideProps() {
  return {
    props: {
      text: 'some value',
    }
  }
}
```

With this commit, the props object can also be a Promise, e.g.

```javascript
export async function getServerSideProps() {
  return {
    props: (async function () {
      return {
        text: 'promise value',
      }
    })(),
  }
}
```

For now, the framework simply waits for the results of the props Promise to resolve,
but this small change sets the groundwork for later allowing props to be streamed (cc @devknoll).

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. -- *This is part of @devknoll's ongoing work to support streaming.*
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not. *not sure if this applies here*
- [ ] Errors have helpful link attached, see `contributing.md`
2021-08-30 19:52:15 +00:00
Jiachi Liu
8c553e8dc0
chore: upgrade styled-jsx to 4.0.1 (#28626)
Fix warning of peer dep on yarn (berry version) install
2021-08-30 19:15:14 +00:00
Steven
804971fd9a v11.1.1 2021-08-30 14:24:52 -04:00
jj@jjsweb.site
194d70f068
v11.1.1-canary.19 2021-08-30 13:20:57 -05:00
Steven
a60690f59b v11.1.1-canary.18 2021-08-30 13:06:42 -04:00
Steven
7afc97c574
Add CSP to Image Optimization API (#28620)
Add CSP header to Image Optimization API
2021-08-30 16:51:47 +00:00
JJ Kasper
f1dbc9260d
Ensure dev server side errors are correct (#28520) 2021-08-27 14:29:30 +02:00
Gerald Monaco
2cc2cb4f77
Support for functional Document components (#28515) 2021-08-26 10:05:01 -05:00
Steven
d8093ec4b4
Update warning when parent styles break next/image (#28517)
- Follow up to #28221 
- Fixes #27644
2021-08-26 00:09:04 +00:00
Steven
ed6ce1ae27 v11.1.1-canary.17 2021-08-25 15:25:53 -04:00
Steven
d835402f28 v11.1.1-canary.16 2021-08-25 12:53:06 -04:00
JJ Kasper
ead10f1f81
Fix handling for 204 status code with a body (#28479)
This ensures we handle 204 and 304 status codes correctly in API routes.  

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/28464
2021-08-25 15:52:43 +00:00
JJ Kasper
f21685549a
Update i18n locales limit to warning (#28429)
* Update i18n locales limit to warning

* update version -> versions

* bump

* Use Log.warn instead

* Apply suggestions from code review

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


Co-authored-by: Lee Robinson <me@leerob.io>
2021-08-25 08:54:38 -05:00
Tim Neutkens
c65248d732 Remove unused imports 2021-08-25 11:11:45 +02:00
Tim Neutkens
a509d906a6 v11.1.1-canary.15 2021-08-25 10:49:43 +02:00
Tim Neutkens
9316dc0a8e
Add default trace format that is exported automatically (#28461)
Co-authored-by: Steven <steven@ceriously.com>
2021-08-25 10:47:16 +02:00
JJ Kasper
706547e0c3
Ensure error is shown correctly for empty headers field (#28430)
* Ensure error is shown correctly for empty headers field

* Apply suggestions from code review

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

Co-authored-by: Steven <steven@ceriously.com>
2021-08-24 19:26:33 -05:00
Janicklas Ralph
fd1c56e66a
next/script fix duplicate scripts (#28428)
* Fix #27747

* Fix lint error

* Add data attribute to script component

* Fix #28036

* Fix tests

* Fix tests

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-08-24 11:07:38 -05:00
jj@jjsweb.site
ee462442c8
v11.1.1-canary.14 2021-08-24 09:54:07 -05:00
Mateusz Burzyński
c1a09471ff
Add missing typescript property to NextConfig (#28459)
This is similar to https://github.com/vercel/next.js/pull/27126 , https://github.com/vercel/next.js/pull/27446 and https://github.com/vercel/next.js/pull/27974

## 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
2021-08-24 14:08:18 +00:00
JJ Kasper
ece79a4e00
Update test config to leverage swc (#28400)
This updates our `jest` configuration to no longer use `babel-jest` and instead uses `@swc/jest` which is much faster. This also updates to the latest version of `jest`, fixes our `tsconfig.json` used for tests (previously types in `node_modules` weren't resolved correctly), and ensures `next/dist` isn't un-necessarily transpiled in `jest`. 

Timings for `yarn testheadless test/unit/` on CI
- before: 3m 30s - 4m ([example run](https://github.com/vercel/next.js/runs/3394701995))
- after: under 1m ([example run](https://github.com/vercel/next.js/pull/28400/checks?check_run_id=3395161621))

Timings for `yarn testheadless test/unit/` locally on m1 mac 
- before: 90.16 seconds
- after: 29.92 seconds
2021-08-23 18:36:56 +00:00
Houssein Djirdeh
80921b6a54
enables eslint caching by default (#28349)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-08-23 12:56:21 -05:00
vcnc-hex
00f1519ae7
Fix forked NODE_OPTIONS except for inspect (#28420) 2021-08-23 12:14:17 -05:00
JJ Kasper
83209a4be4
Ensure @babel/core is de-duped when nccing (#28384)
* Ensure @babel/core is de-duped when nccing

* lint-fix

* ncc babel packages together

* remove un-needed env

* bump
2021-08-22 14:06:58 -05:00
Janicklas Ralph
26255a685d
Add data attribute to script component (#28310)
Add data attribute `data-nscript` to the script component
2021-08-20 20:48:48 +00:00
Alex Castle
a0f64ba4a5
Add layout to data-nimg attribute (#28312) 2021-08-20 14:43:44 +02:00
Jiachi Liu
b74ffffa96
Fix next env vars injection in dynamic (#28309)
* Treat `next/dynamic` as non external modules
* add feature flags to webpack cache version
2021-08-20 03:50:11 +00:00
jj@jjsweb.site
52b858a4ea
v11.1.1-canary.13 2021-08-19 12:27:49 -05:00
Houssein Djirdeh
4e7691139f
[ESLint] Adds process.exit to next lint success output (#28299)
This PR ensures that `next lint` always exits after the process is complete. This fixes #28194.
2021-08-19 17:16:59 +00:00
jj@jjsweb.site
517ea6dc20
v11.1.1-canary.12 2021-08-19 11:25:39 -05:00
Tobias Koppers
426d732feb
upgrade webpack to 5.51.1 (#28291)
https://github.com/webpack/webpack/releases/tag/v5.51.0
2021-08-19 15:32:17 +00:00
JJ Kasper
9b09b92a14
Ensure adding _app/_document HMRs correctly (#28279)
This is a follow-up to https://github.com/vercel/next.js/pull/28227 to ensure `_app` and `_document` HMR correctly when you start the dev server and then add `_app` and `_document`. 

## Bug

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

x-ref: https://github.com/vercel/next.js/issues/27888
2021-08-19 08:12:12 +00:00
Steven
53f0973aba
Fix next/image blur placeholder when JS is disabled (#28269)
This PR does a few things:

- Moves `<noscript>` usage below the blur image since so that the `<noscript>` image renders on top of the blur image
- Remove the `isVisible` check for `<noscript>` since we can't rely on client-side JS
- Add `loading=lazy` to the `<noscript>` image to take advantage of native lazy loading (can't rely on JS lazy loading)

Fixes #28251
2021-08-19 04:26:07 +00:00
jj@jjsweb.site
f4b85dc9e8
v11.1.1-canary.11 2021-08-18 11:30:31 -05:00
JJ Kasper
15e8019263
Update generating next-server dependencies (#28223)
* Update generating next-server dependencies

* Update tests

* ensure stale cache is not used
2021-08-18 10:41:40 -05:00
Tim Neutkens
e920dbc6e6
Add relationship between issuer and module to traces (#28192) 2021-08-18 14:22:53 +02:00
JJ Kasper
17d7e59339
Fix HMR when custom _app or _document is removed (#28227)
This adds the fallback webpack alias handling to handle a custom `_app` or `_document` being removed in development gracefully. 
 
## Bug

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

Fixes: https://github.com/vercel/next.js/issues/27888
2021-08-18 11:01:02 +00:00
Gerald Monaco
51559f5c64
Use zen-observable library (#28214)
Our `Observable` use has gotten sufficiently complex that it makes sense to just use a 3rd party implementation and not worry about maintaining it ourselves. As a bonus, it doesn't rely on Node APIs.
2021-08-18 03:29:43 +00:00
Steven
ce187563ef
Add warning when parent styles break next/image (#28221)
Fixes #27644
2021-08-18 02:05:10 +00:00
Jiachi Liu
7ea7c23866
Document usage of suspense option of next/dynamic (#28210)
## Documentation / Examples

- [x] Make sure the linting passes
- [x] Errors have helpful link attached, see `contributing.md` (for #28165, #27611)
- [x] Update test case
2021-08-18 01:21:22 +00:00
Chris Lloyd
52c2f8b4dd
Avoid fs write next-env.d.ts on read-only filesystems (#28206)
Next.js currently writes the TS type declarations on startup, regardless of the existing content of the file. This is good for ensuring the file content stays consistent. However, if the file content is already correct, this will perform an unnessecary write.

When running Next in read-only filesystems (such as the Bazel sandbox) this can cause the build to fail even if the content of the type declaration file is already correct.

This fixes this by only writing the contents of the file if the current contents don't match.

## Test Plan

Added an integration test for the general behavior of writing `next-env.d.ts`.
2021-08-18 00:41:51 +00:00
Tobias Koppers
b594f5bcc0
let loaders automatically infer source map setting (#28204)
These loaders automatically use the global source map setting when this option is omitted
2021-08-17 17:48:48 +00:00
dave
1b2e0799c3
fix development mode bug with pages with "+" and other special characters (#28122)
* add encodeURIComponent so certain characters don't bug out (fixes #22099)

* add integration test for pr #28122
2021-08-17 12:13:33 -05:00
Tim Neutkens
71cecc2ba7 v11.1.1-canary.10 2021-08-17 10:41:02 +02:00
Tim Neutkens
2b7d4619ed
Improve jaeger traces (#28168)
Co-authored-by: Harsh Karande <harshskarande@gmail.com>
2021-08-17 09:18:47 +02:00
JJ Kasper
5544adc481
Update to latest babel versions (#28174) 2021-08-17 09:18:08 +02:00
jj@jjsweb.site
4dad4fb7bf
v11.1.1-canary.9 2021-08-16 17:45:02 -05:00
Tim Neutkens
f28b965add
Add module type to build-module trace (#28128)
Add `-js` `-ts` `-tsx` `-css` to `build-module` in traces to allow for easier filtering. 

## 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
2021-08-16 20:05:57 +00:00
JJ Kasper
24b09ad4f8
Add entrypoint tracing (#25538)
This adds tracing entrypoints directly after they have have been transpiled to allow us to trace before the webpack runtime has been added to the modules. This should allow for more accurate tracing of entrypoints and allow the trace step to be cached. 

## Bug

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


x-ref: https://github.com/vercel/next.js/issues/24700
x-ref: https://github.com/vercel/next.js/issues/26200
x-ref: https://github.com/vercel/next.js/issues/23894
x-ref: https://github.com/vercel/next.js/issues/25431
2021-08-16 19:29:11 +00:00
Jiachi Liu
531342691d
Enable pure client suspense in blocking rendering (#28165)
Do not fallback to loadable component when `reactRoot` is enabled but without `concurrentFeatures`. Thus we can enable pure client suspense:

`fallback` is always rendered on server side, but client side can work with fully functional suspense.

Closes #28117
2021-08-16 15:06:39 +00:00
Tim Neutkens
76cc01f6b5
Add support for Jaeger trace target (#28129)
Adds support for Jaeger next to Zipkin as a trace target.

## 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
2021-08-15 19:26:02 +00:00
Maia Teegarden
ebe3d93f59
v11.1.1-canary.8 2021-08-15 11:46:11 -07:00
Jiachi Liu
4cdb585962
Fix: wrong link error message (#28127)
Fixes: #28126

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2021-08-15 11:49:21 +00:00
JJ Kasper
039735350c
Add proper error when failing to load next.config.js (#28099)
This adds a proper error when we fail to load a user's `next.config.js` as the default node error can be confusing on its own and makes it seem like something failed internally in Next.js. We can expand on the included error doc added and potentially also add better syntax errors by parsing with acorn when we fail to load this file in the future. 

<details>

<summary>screenshot</summary>

<img width="962" alt="Screen Shot 2021-08-13 at 21 46 09" src="https://user-images.githubusercontent.com/22380829/129432211-6d858062-eea0-4bb9-8725-5bde98bdc47b.png">

</details>
2021-08-14 13:52:18 +00:00
JJ Kasper
169785253e
Fix revalidate for initial notFound: true paths (#28097)
This fixes revalidation not occurring correctly when `notFound: true` is returned during build, additional tests have been added to ensure this is working correctly for dynamic and non-dynamic pages returning `notFound: true` during build and then revalidating afterwards.  

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/21453
2021-08-14 13:11:40 +00:00
jj@jjsweb.site
a1889798d8
v11.1.1-canary.7 2021-08-13 21:23:09 -05:00
Gerald Monaco
500b3f6e15
Remove duplicate doctypes (#28089)
* Remove duplicate doctypes

* Fix lint

* Add test for DOCTYPE

* Fix lint
2021-08-13 19:12:02 -05:00
Eiji Kitamura
73b5d69e27
Update util to 0.12.4 (#27939)
Chrome 92 started to disable `SharedArrayBuffer` without cross-origin isolation which can be enabled by sending [the page with special HTTP headers](https://web.dev/cross-origin-isolation-guide/). This change causes Chrome to emit a warning in DevTools console and [developers are confused with the message](https://github.com/vercel/next.js/issues/21708). `util` is one of the libraries that uses `SharedArrayBuffer` and is causing the warning to appear in the console.

Luckily, the issue in `util` has been resolved in [v0.12.4] and I would like to propose applying the fixed version to this library.

For fixing #21708



## 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
2021-08-14 00:04:07 +00:00
Tim Neutkens
eddf2054c2
Bypass webpack compilation for precompiled @next/polyfills-nomodule (#27596)
Removes the extra webpack handling that was previously done, this ensures the file which is already minified and compiled does not get passed through minification again.

Largely based on #21418
Closes #21418

The polyfill loading already has tests so no other changes are necessary.



## 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
2021-08-13 22:40:45 +00:00
stefanprobst
daadfd347f
Handle blob urls in image component (#27975)
This PR resurrects #23622 which has not been updated in a while. Makes the `Image` component handle `blob:` object urls.

closes #23622
fixes #19291

credits: @sdn90 

## 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
2021-08-13 22:03:20 +00:00
Jiachi Liu
d14da39fd6
Support suspense in next dynamic (#27611)
### Changes
#### Feature
* Adopt `React.lazy` into `next/dynamic`, enable it when `options.suspense` is `true`
* Support `next/dynamic` with `suspense=true` in SSR and SSG

#### Tests

| Scenario | Case | Behavior |
|:----:|:----:|:----:|
| basics | react 17 or 18 by default | dev/build error or pass |
| blocking rendering | `reactRoot: true` + `concurrentFeatures: false` | dev/build pass |
| concurrent rendering | `reactRoot: true` + `concurrentFeatures: true` | dev/build pass | 


## Feature

- [x] 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
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`
2021-08-13 21:08:45 +00:00
Gerald Monaco
c969b8172a
Add support for dynamic HTML (#28085)
Implements `renderToString` in terms of a new `renderToStream`. The former is used for legacy documents that generate the body HTML as part of `getInitialProps`. The latter will be used directly in #27794 when streaming dynamic HTML.

Since we're exposing an actual streaming response for dynamic HTML (instead of buffering with `resultFromChunks`), we use `multiplexResult` to buffer and multiplex the underlying result to multiple subscribers.
2021-08-13 19:57:04 +00:00
Gerald Monaco
d2551bbbc7
Render as a concatenation of streams (#28082)
Return the `RenderResult` as a concatenation of streams, rather than a concatenation of strings.
2021-08-13 16:40:12 +00:00
Maia Teegarden
2a83012def
v11.1.1-canary.6 2021-08-12 21:10:04 -07:00
Gerald Monaco
08a24780b0
Clean up Document in preparation for streaming (#28032)
We generate the HTML for a document in two steps: First, we generate the body (i.e. everything under `<div id="__next">`). Then we generate the rest of the document and embed the body in it.

This doesn't work when the body is a stream, because React can't render the body for us unless we buffer it, and buffering it means not streaming. This PR takes the existing approach for AMP and uses it for all scenarios: instead of rendering HTML, we just render a placeholder that we can replace with HTML later. This will be used in a follow-up PR to let us know where to concatenate the body stream.

I also used the opportunity to split out `HtmlContext` from `DocumentProps`, as these will not be the same thing with functional document components.
2021-08-13 03:36:54 +00:00
Maia Teegarden
ea6a0f0eda
v11.1.1-canary.5 2021-08-12 19:08:44 -07:00
Steven
b11bd49239
Fix image optimization encoding url (#28045)
- Fixes #27973 
- Reverts #27671 


The problem with PR #27671 is that it was encoding too often when it really only needed to solve the bug for `next build && next start` since `next dev` was already working.

This PR uses the alternative solution mentioned here https://github.com/vercel/next.js/issues/27210#issuecomment-890305204
2021-08-13 00:31:51 +00:00
즈눅
1552b8341e
Fix generateBuildId type that can be async function (#28040)
[The current documentation ensures it can be async function](https://github.com/vercel/next.js/blob/v11.1.1-canary.1/docs/api-reference/next.config.js/configuring-the-build-id.md?plain=1#L13), so this PR fixes the TypeScript type of it.
2021-08-12 22:26:44 +00:00
Maia Teegarden
1302067c74
v11.1.1-canary.4 2021-08-12 14:01:16 -07:00
Maia Teegarden
ff5e444284
Use @next scope for native packages (#28046) 2021-08-12 13:59:53 -07:00
Tobias Koppers
8bbb1cd353
use a shared worker pool for collecting page data and static page generation (#27924)
this avoid loading all code twice and hopefully improving performance
2021-08-12 19:54:49 +00:00
Maia Teegarden
b6411408c0
v11.1.1-canary.3 2021-08-12 10:55:41 -07:00
Maia Teegarden
2d38efa7b5
v11.1.1-canary.2 2021-08-12 10:21:01 -07:00
stefanprobst
9bf322503b
Add missing fields to NextConfig type (#27974)
This PR adds the `poweredByHeader` and `webpack` fields to the public `NextConfig` type.

## 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
2021-08-12 15:42:57 +00:00
Tim Neutkens
06e08accde v11.1.1-canary.1 2021-08-12 17:07:36 +02:00
Tim Neutkens
965a280bc2
Ensure config file message is only shown once (#28017)
Fixes #27982



## 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
2021-08-12 14:33:25 +00:00
Maia Teegarden
b2c7b316cb
Next swc publish flow (redo) (#27984)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-08-12 12:22:50 +02:00
jj@jjsweb.site
988c0c7fd3
v11.1.1-canary.0 2021-08-11 12:13:30 -05:00
Tim Neutkens
ce4adfc02d v11.1.0 2021-08-11 17:52:20 +02:00
Tim Neutkens
092a476feb v11.0.2-canary.31 2021-08-11 17:49:46 +02:00
Tim Neutkens
ebb6a30370 Revert "Add warning during next build when sharp is missing (#27933)"
This reverts commit 51a2a028dd.
2021-08-11 17:47:16 +02:00
Tim Neutkens
52486ceccf v11.0.2-canary.30 2021-08-11 15:59:00 +02:00
Tim Neutkens
8ac3254d25 Revert "Next swc publish flow (#27932)"
This reverts commit 94fc6f0832.
2021-08-11 15:48:15 +02:00
Tim Neutkens
6014b6e0f8 v11.0.2-canary.29 2021-08-11 12:46:11 +02:00
Maia Teegarden
94fc6f0832
Next swc publish flow (#27932) 2021-08-11 11:03:16 +02:00
Steven
51a2a028dd
Add warning during next build when sharp is missing (#27933)
Follow up to #27346 

![image](https://user-images.githubusercontent.com/229881/128935917-ca6da384-91f4-43d3-8059-4e06220fbc19.png)
2021-08-11 04:03:57 +00:00
Gerald Monaco
459b391775
Add experimental concurrentFeatures config (#27768)
Allows opting in to support for new concurrent features, like server-side Suspense.

**!!! DO NOT USE !!!**
This is highly experimental. We **will** be gating additional breaking changes behind this same flag. 
**!!! DO NOT USE !!!**

Also resolves suspense for static pages (i.e. `getStaticProps` or `next build`/`next export`) since we can't currently support streaming for those cases anyway.
2021-08-11 03:06:42 +00:00
Alex Castle
12eb812243
Add data-nimg attribute to image component (#27899)
This PR adds a single data attribute to the image element generated by the image component `data-nimg`) which just serves to signal that this image element is from the component. Currently it's hard to quickly/programmatically determine with certainty whether an image is from the component or not, so this change should make it easier for us to diagnose and improve performance issues related to the image component.
2021-08-11 00:58:15 +00:00
Steven
b4be678e35
Remove duplicate type for StaticImageData (#27931)
Follow up to #27916 

This interface was defined twice so I removed the private one and kept the global/public one.

eb871d3091/packages/next/image-types/global.d.ts (L4-L9)

b881d65c12/packages/next/client/image.tsx (L60-L65)
2021-08-11 00:13:35 +00:00
Tobias Koppers
681d298bdf
update to webpack 5.50.0 (#27929)
* performance improvements for cache serialization
* disabled cache compression by default (next.js is using webpack default again)
* support hashbang
2021-08-10 19:20:50 +00:00
Janicklas Ralph
43393d53be
Fix next/script unhandled promise rejection (#27903)
## Bug

- [x] fixes #27747
- [x] Integration tests added
2021-08-10 17:41:26 +00:00
stefanprobst
eb871d3091
Replace placeholder with blurDataURL in global StaticImageData type (#27916)
I think the global `StaticImageData` type does not currently match what actually gets imported, and what the `Image` component expects (see [here](https://github.com/vercel/next.js/blob/canary/packages/next/client/image.tsx#L60-L65)). This PR changes `placeholder` to `blurDataURL`.

## 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
2021-08-10 15:51:08 +00:00
Tim Neutkens
8cbaa409ca v11.0.2-canary.28 2021-08-10 11:01:53 +02:00
Jiachi Liu
9d3e895124
Upgrade styled-jsx to v4 (#27890)
Upgrade styled-jsx to v4 for supporting concurrent mode in react 18 


## 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
2021-08-09 17:57:11 +00:00
Nick Kelly
b60c943750
Remove extraneous fs.stat calls (#27779)
## Performance improvement

- [x] Performance improvement

Uses `fs.readdir`'s  `withFileTypes` option, added in NodeJS version 10,  to simultaneously read the target directories files and their stats, removing the need to call `fs.stat` on each of the files individually.

Similar to #27769, applies the same change to `recursiveCopy` and `recursiveDelete`.
2021-08-09 15:28:00 +00:00
Tobias Koppers
c6ba688c40
disable cache compression as it slows down the build (#27887) 2021-08-09 14:13:50 +00:00
Tim Neutkens
331fed89f3
Add Import trace for requested module when it fails to resolve (#27840)
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-08-09 14:38:26 +02:00
Tim Neutkens
04bbea2cbe Add sourceFileName for SWC compiled core files
Fixes the vscode debugger breakpoints. Thanks @kdy1 for implementing the `sourceFileName` option in SWC.
2021-08-06 22:02:08 +02:00
JJ Kasper
e57b959e17
v11.0.2-canary.27 2021-08-06 13:45:57 -05:00
Maia Teegarden
7992b14a78
Add next dynamic swc transform (#27745)
Ported `packages/next/build/babel/plugins/react-loadable-plugin.ts` to swc
2021-08-06 16:53:32 +00:00
JJ Kasper
b24cd1eaba
Use @vercel/fetch for run-tests requests (#27815)
* Use @vercel/fetch for run-tests requests

* update precompileld
2021-08-06 10:20:05 -05:00
Tim Neutkens
d2f43b718f
Add experimental SWC minify and SWC loader options (#27664) 2021-08-06 16:07:36 +02:00
Tobias Koppers
e3e7e0840d
update webpack to 5.49.0 (#27813)
https://github.com/webpack/webpack/releases/tag/v5.49.0
2021-08-06 12:49:21 +00:00
Jiachi Liu
567d47b65c
Upgrade styled-jsx (#27782)
* Update styed-jsx to latest version, containing bugfixes for babel plugin and typings.
* Use `/// <reference>` instead of redeclaring types


## 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
2021-08-05 18:04:38 +00:00
JJ Kasper
fa01a1593e
Update client error to show link in console (#27789)
* Update client error to show link in console

* Apply suggestions from code review
2021-08-05 10:38:06 -05:00
Sjors Smits
d313855978
Wrap last return statement in else to fix tree shaking (#27788)
## Bug

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

fixes #27744
2021-08-05 13:34:22 +00:00
JJ Kasper
f15d05754d
v11.0.2-canary.26 2021-08-04 22:15:26 -05:00
Nick Kelly
0593dbb260
remove unecessary fs.stat calls from recursive-readdir (#27769)
## Performance improvement

- [x] Performance improvement

Removes unnecessary `fs.stat` calls in `recursiveReadDir`.

`fs.readdir` had an option `withFileTypes: boolean` added NodeJS version 10. It can be used to read the directory contents and fetch its stats simultaneously, removing the need to read individual file stats after reading the directory contents.
2021-08-04 23:06:06 +00:00
Houssein Djirdeh
7a1c9eb17e
[ESLint] Introduce a new setup process when next lint is run for the first time (#26584)
This PR introduces an improved developer experience when `next lint` is run for the first time.

### Current behavior

`eslint-config-next` is a required package that must be installed before proceeding with `next lint` or `next build`:

![image](https://user-images.githubusercontent.com/12476932/123468791-43088100-d5c0-11eb-9ad0-5beb80b6c968.png)

Although this has helped many developers start using the new ESLint config, this has also resulted in a few issues:

- Users are required to install the full config (`eslint-config-next`) even if they do not use it or use the Next.js plugin directly (`eslint-plugin-next`).
  - #26348

- There's some confusion  on why `eslint-config-next` needs to be installed or how it should be used instead of `eslint-plugin-next`.
  - #26574
  - #26475
  - #26438

### New behavior

Instead of enforcing `eslint-config-next` as a required package, this PR prompts the user by asking what config they would like to start. This happens when `next lint` is run for the first time **and** if no ESLint configuration is detected in the application.

<img src="https://user-images.githubusercontent.com/12476932/124331177-e1668a80-db5c-11eb-8915-38d3dc20f5d4.gif" width="800" />

- The CLI will take care of installing `eslint` or `eslint-config-next` if either is not already installed
- Users now have the option to choose between a strict configuration (`next/core-web-vitals`) or just the base configuration (`next`)
- For users that decide to create their own ESLint configuration, or already have an existing one, **installing `eslint-config-next` will not be a requirement for `next lint` or `next build` to run**. A warning message will just show if the Next.js ESLint plugin is not detected in an ESLint config. 

  <img width="682" alt="Screen Shot 2021-06-25 at 3 02 12 PM" src="https://user-images.githubusercontent.com/12476932/123473329-6cc4a680-d5c6-11eb-9a57-d5c0b89a2732.png">

---

In addition, this PR also:

- Fixes #26348
- Updates documentation to make it more clear what approach to take for new and existing ESLint configurations
2021-08-04 21:53:15 +00:00
JJ Kasper
bce06f500d
Update has query encoding when used in path (#27762)
This is a follow-up to https://github.com/vercel/next.js/pull/26963 which after discussion changes to interpolate the decoded variant of the value into the path. 

x-ref: https://github.com/vercel/next.js/issues/24775

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-08-04 20:31:12 +00:00
Steven
2061d6c4fe
Fix html validation for Image component sizer (#27767)
According to [MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-hidden_attribute#deciding_between_aria-hiddentrue_rolepresentation_and_rolenone):


- `aria-hidden="true"` will remove the entire element from the accessibility API. 
- `role="presentation"` will remove the semantic meaning of an element while still exposing it to assistive technology. 

We don't need both so we'll keep `aria-hidden="true"` since the element is used for sizing, not content that should be read.

Fixes #27163
2021-08-04 18:42:59 +00:00
Steven
3ab5d600d3
Add missing removeHeader() function to image optimizer mock res (#27763)
- Related to #27724 
- Related to #19309 
- Related to #23140
2021-08-04 17:01:20 +00:00
Maia Teegarden
204445ff2f
Add/amp attribute patcher (#27700)
* Add amp attribute transform

* Add amp attribute unit tests

* Fix ci if statements

* Checkout code in rust tests

* Add rust fixtures to eslintignore

* Add cargo config

* Configure toolchain for cross compilation
2021-08-03 09:54:57 -07:00
JJ Kasper
4ab41efdbf
Add handling for repeated slashes (#27738)
This adds handling for repeated forward/back slashes in Next.js, when these slashes are detected in a request to Next.js we will automatically remove the additional slashes redirecting with a 308 status code which prevents duplicate content when being crawled by search engines. 

Fixes: https://github.com/vercel/next.js/issues/13011
Fixes: https://github.com/vercel/next.js/issues/23772
Closes: https://github.com/vercel/next.js/pull/15171
Closes: https://github.com/vercel/next.js/pull/25745
2021-08-03 15:06:26 +00:00
강동윤
61586eda6a
Port next-ssg getStaticProps/getServerSideProps tree shaking Babel transform to rust (#27552) 2021-08-03 14:02:23 +02:00
JJ Kasper
ca0c122f63
v11.0.2-canary.25 2021-08-02 20:00:21 -05:00
Steven
46e7658f7e
Add next.config.js option to override default keepAlive (#27709)
Follow up to #27376 so users can disable keep-alive.

See comment https://github.com/vercel/next.js/pull/27376#issuecomment-885415623
2021-08-03 00:38:42 +00:00
Tobias Koppers
b36c66a40f
update webpack-sources to 3.2.0 for bugfixes and performance (#27673) 2021-08-03 00:01:43 +00:00
Steven
b05cdb1f64
Add naturalWidth/naturalHeight to onLoadingComplete() callback (#27695)
Resolves #27213
2021-08-02 23:14:38 +00:00
JJ Kasper
b3c959b2c2
Enforce source/destination limit for custom routes (#27703)
This ensures we enforce a limit for `source`/`destination` values on rewrites, redirects, and headers since these being too long can affect routing performance. 

Closes: https://github.com/vercel/next.js/issues/27696
2021-08-02 22:34:44 +00:00
Gerald Monaco
79e30f9cb6
More React 17 clean up (#26775)
Remove unnecessary `React.Suspense` checks, as the minimum supported version is `react@>=17.0.1`. Also removes some files from the `react-18` integration test that are no longer necessary as of #26664.
2021-08-02 19:14:31 +00:00
stefanprobst
63aeddbbe0
URI-encode url parameter in image optimizer (#27671)
fixes #27210
maybe related: #19668

currently, the image optimizer returns 400 when an image url contains non-ascii characters. this pr uri-encodes the `url` query parameter to fix it. also see https://github.com/vercel/next.js/issues/27210#issuecomment-890305204

## 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
2021-08-02 17:03:45 +00:00
JJ Kasper
26981aa54c
Undo sourcemap change (#27690)
This undoes the change from https://github.com/vercel/next.js/pull/27623 since it appears to be breaking source maps from changing the sources field in the generated source map to a relative path causing it to break jest's source map handling as can be seen in the `test-unit` CI job [here](https://github.com/vercel/next.js/runs/3214076727). 

This reverts commit f9ebc7772f.
2021-08-02 15:45:39 +00:00
Tim Neutkens
f9ebc7772f
Ensure Next.js core development sourcemaps use correct input file (#27623)
Noticed while debugging that the error output lines did not make sense and found that `sourceFileName` is not supported in SWC yet. This is a temporary fix until @kdy1 adds the option.
2021-08-01 16:08:06 +02:00
JJ Kasper
dd7a54c509
v11.0.2-canary.24 2021-07-29 21:15:13 -05:00
Tim Neutkens
e6d12a9d94
Update Terser (#27600)
Fixes #27593



## 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
2021-07-29 18:08:14 +00:00
Tim Neutkens
77c385af06
Update report to leverage new variables (#27084)
## 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
2021-07-29 17:35:25 +00:00
Tobias Koppers
fabaaa903a
persistent cache need to be invalidated when source-maps are enabled (#27607) 2021-07-29 16:59:41 +00:00
Tobias Koppers
4b33cef977
upgrade to webpack 5.47.0 and webpack-sources 3.1.1 (#27538)
* improve source-map performance
* improve watch performance
* bugfixes
* improvements to Data URIs
2021-07-29 16:10:51 +00:00
JJ Kasper
c63bfbe773
v11.0.2-canary.23 2021-07-28 15:19:07 -05:00
Tim Neutkens
c7e2a1df6a
Use SWC for Next.js core client files (#27196)
Replaces Babel with SWC for Next.js core client-side 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
2021-07-28 15:10:51 +00:00
Paweł Tymczuk
36b81f989c
Fix: Added the content-disposition header (#27521)
In this PR I've added the `Content-Disposition` header to the response of the image `/_next/image` route. That header is used by the browser when showing the dialog for the `Save image as...` action. 

There are some differences between the browsers, ex:
When requesting the image `test.jpg`,  the response header `Content-Type: image/webp` - in FF the filename from the `Save image as...` dialog would be `test.webp` but in Chrome `test.jpg` even if the `Content-Disposition: inline; filename="test.webp"` is present in the headers.  The same about png images, the rest types are fine.  It looks like FF is checking the `Content-Type` for the extension but the Chrome does not and is doing another type of check.

Fixes #26737

## Bug

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

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-27 23:22:48 +00:00
JJ Kasper
5eaca0ffe5
Document i18n locale limit (#27542)
Add check for i18n locale count and ensure the limit is documented

## Documentation / Examples

- [x] Make sure the linting passes
2021-07-27 20:09:36 +00:00
Gerald Monaco
707afe1d4d
Add RenderResult (#27319)
Adds `RenderResult`, replacing the `string` that `renderToHTML` used to return, with an `Observable`-like API that callers can use to subscribe and get a callback when chunks are available to flush, etc.

This is the last architectural change needed for streaming. There are, however, other things currently standing in the way of streaming. For example, it is common to mutate `res` in `getServerSideProps` to do routing work, or write headers, before fetching page data. This pattern effectively nullifies any advantages of streaming. I may do a follow-up PR that adds an experimental alternative for applications not using React 18, but the main purpose for this support is for Suspense and Server Components.

For that reason, there's no actual streaming here yet: instead we just flush a single chunk. A follow-up PR will add support for streaming suspense boundaries in React 18.
2021-07-27 19:18:21 +00:00
Maia Teegarden
4172a4c0a6
Add initial next swc package with first transform (#27355)
* Set up next-swc package with no custom transforms

* Add hook_optimizer transform

* Fix lint

* Build next-swc on CI

* Add toolchain in rust action

* Build binaries in manual workflow

* Commit from GitHub Actions (Build next-swc native binaries)

* Update dependencies

* Update swc and use stable rust

* Build next-swc binaries

* Test compiled code

* Dedupe @node-rs/helper

* Add workflow to check next-swc binaries

* Fix check native

* PR feedback

* PR feedback

* Pr feedback

* Build next-swc binaries

* Combine native workflows

* Add docs for contributors on less common platforms

* PR feedback

* Compare JsWord instead of converting to string

* Fix workflow formatting

* Add docs for building binaries for CI

* Build next-swc binaries

* Fix workflow if syntax

* Add license info to copied code

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-07-27 17:07:28 +02:00
Aurélien MANCA
97a140f733
fix(critical CSS): use the assetPrefix in the critters config (#27506)
This PR fixes #25927 bug which prevents to use `assetPrefix` config with the experimental critical CSS feature.

Fixes: #25927



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-07-26 21:00:47 +00:00
Sojin Park
23ac4351f4
fix: Make router ready in case of custom _app getInitialProps (#27473)
From https://github.com/vercel/next.js/pull/20628,  when the page is rendered server-side, `Router`'s `isReady` field needs to be initially set to `true`. However, when `_app` has custom `getInitialProps`, it seems that it is not the case, even though the page is rendered on the server. 

This leads to a bug that `Router.isReady` is never set to `true`.

This pull request fixes the problem by fixing the initial calculation logic of `isReady` of `Router`.

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

- [x] Make sure the linting passes
2021-07-26 20:25:55 +00:00
JJ Kasper
7c0f707b06
v11.0.2-canary.22 2021-07-26 12:48:27 -05:00
stefanprobst
622f63867a
Update eslint doc comment (#27478)
the behavior of the `eslint.dirs` config option was changed in #26401. this pr adjusts the doc comment accordingly.

## 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
2021-07-25 13:48:46 +00:00
Artur Muller
c88898be12
Clarify error message in isSerializableProps (#22856)
I recently received the "Props must be returned as a plain object" error when I accidentally dropped an array directly inside `props`. This is a trivial error to fix once you know what you did, but I spent good 30 minutes looking in all the wrong places. I hope that this slight clarification in the error message would save someone from wasting their time if they make a similar mistake like myself.
2021-07-25 06:08:30 +00:00
brijendravarma
74b159c850
Updated the Error message describing the alternative and added styles… (#14652)
The error message indicates better alternatives and added styles.css sample snippet for good visibility.

![Global_error_msg](https://user-images.githubusercontent.com/38159218/85950309-ac3bc100-b979-11ea-9a8d-4a356cb8007c.JPG)
![CSS-Global](https://user-images.githubusercontent.com/38159218/85950319-b2ca3880-b979-11ea-829a-24335fcfc93d.JPG)
2021-07-25 04:53:33 +00:00
Michał Bundyra
7fe8a001e2
ESLint: custom directories from next.config.js (#26401)
Attempt to fix #26393

~~Sorry, I wasn't able to run tests on local, but I hope at least test should be valid.~~
Edit: Tests are working correctly on my local :) 

fixes #26393



## Bug

- [x] Related issues linked using `fixes #26393`
- [x] Integration tests added
2021-07-25 04:11:29 +00:00
JJ Kasper
2cf9b462ae
v11.0.2-canary.21 2021-07-24 12:10:01 -05:00
Houssein Djirdeh
078cfb59f9
[ESLint] Adds --format flag to next lint (#27052)
Adds `--format` support to `next lint` to allow defining of additional formatters. Fixes #26387.
2021-07-24 01:35:56 +00:00
Steven
9065cdf836
Add warning when next/image component has style prop (#27441)
We've never supported the `style` prop as seen in the docs https://nextjs.org/docs/api-reference/next/image#other-props

TS users already get a build error but JS users were left in the dark.

This PR adds a warning so its clear during `next dev`.
2021-07-23 22:53:27 +00:00
JJ Kasper
c54f168d9a
Add config check for invalid duplicate locale domains (#27451) 2021-07-23 17:16:14 -05:00
Tobias Järvelöv
ee605cb653
Wait for getFilesForRoute promise to fulfill before timeout in dev mode (#27395)
The fix in PR #25749 only works some of the time. The reason why it
doesn't work all of the time is because the `devBuildResolve` function
is called when the assets have been built, but this can happen before
the `getFilesForRoute` promise chain has completed, and thus the
`cancelled` variable could not yet have been updated.

To fix this we wait for the `getFilesForRoute` promise chain to be
fulfilled and then resolve the `devBuildPromise` promise afterwards.
This allows the `getFilesForRoute` promise chain to be fulfilled before
and the `cancelled` variable can be updated accordingly.

If an error is thrown somewhere in the `getFilesForRoute` promise chain,
i.e. due to a failed fetch request, then that will also resolve the
`devBuildPromise` and the error will bubble up to ultimately become a
`routeChangeError` which will reload the page.

With this fix the need to listen for HMR events has become obsolete as
regardless of when the HMR build/sync events complete we still want to
ensure that the `getFilesForRoute` promise chain has been fulfilled
before resolving the `devBuildPromise`.

Co-authored-by: Tobias Järvelöv <tobias.jarvelov@oderland.se>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-23 15:56:14 -05:00
stefanprobst
046f7164db
Add eslint config options to NextConfig type (#27446)
This adds missing eslint config options to the public `NextConfig` type.

## 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
2021-07-23 19:15:26 +00:00
JJ Kasper
a8b9c3a3ed
Ensure generateBuildId is not required in config type (#27443) 2021-07-23 12:14:25 -05:00
Yubin
4e74db2d55
Add lazyBoundary prop to Image component (#27258)
This PR adds `lazyBoundary` prop on Image Component.
This feature is to load the images earlier.
I'm not good at English. So, I couldn't explain enough in the documentation what `lazyBoundary` is.

Feature request: https://github.com/vercel/next.js/discussions/24552

## Feature

- [x] 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
- [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
2021-07-23 14:44:38 +00:00
Steven
1d347ba5dc
Fix typo in error message (#27438)
Fixes typo mentioned in https://github.com/vercel/next.js/pull/27346#discussion_r675477904
2021-07-23 14:07:09 +00:00
JJ Kasper
bb779eceeb
v11.0.2-canary.20 2021-07-22 18:21:12 -05:00
Alex Castle
1b733423d6
Use Sharp if available for Image Optimization (#27346)
* Use sharp for image transformations when available

* Refactor resizeImage and add sharp warning

* only show sharp warning once per instance

* Modify sharp error message

* Add documentation for optional sharp dependency

* Update docs/basic-features/image-optimization.md

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

* Import types for sharp

* Update lockfile

* Add testing against sharp

* use fs-extra for node 12

* Rename test sharp path variable

* Apply suggestions from code review

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

* update squoosh specific test

* Apply suggestions from code review

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

* update tests

* Apply suggestions from code review

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

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-22 18:11:17 -05:00
Gerald Monaco
1651129429
Don't cache null responses (#27403)
It's possible for `renderToHTML` to return `null` if `res.finished || res.headersSent` is `true` after `getInitialProps` or `getServerSideProps`. In such cases, we can't generate a valid `ResponseCacheEntry` or `ResponsePayload`, so we shouldn't try.

I took the opportunity to add an invariant for when we expected a cacheable response, but didn't get one. This could happen because Next.js or an application erroneously mutated the underlying `res` during the rendering of a page with `getStaticProps`. This shouldn't normally be possible because `res` isn't exposed in such cases, but it's theoretically possible with a custom server, so it seemed worth flagging.
2021-07-22 21:04:58 +00:00
JJ Kasper
888c7002d6
Fix external redirect with i18n domains (#27415)
This corrects a case when redirecting with i18n locale domains configured the locale domain would be prefixed on external redirects un-necessarily. 

Fixes: https://github.com/vercel/next.js/issues/27405

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2021-07-22 18:32:12 +00:00
Steven
79ed8e13b0
Add keepAlive to node-fetch polyfill (#27376)
Fixes #27109 

This PR adds a default `agent` as described in the [`node-fetch` docs](https://github.com/node-fetch/node-fetch#custom-agent).

We should see about 2x perf according to some [benchmarks](https://github.com/Ethan-Arrowood/undici-fetch/blob/main/benchmarks.md#fetch).
2021-07-22 14:34:33 +00:00
JJ Kasper
52ae69ac33
Rename spr config to ISR (#27379) 2021-07-21 21:42:33 -05:00
JJ Kasper
5dc5a3fba8
v11.0.2-canary.19 2021-07-21 13:57:48 -05:00
Stefan Becker
dbfce34ead
Add configuration for ISR Memory Cache Size (#21535) (#27337)
This allows the user to adjust the LRU cache size according to the
application need:

- optimize the cache size based on average page HTML & JSON size
- disable the memory cache by setting the size to 0

The hard-coded default of 50MB has been moved from the code to the
default configuration object.

Fixes #21535
See also #27325



## Bug

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

## Feature

- [X] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [X] 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
2021-07-21 17:39:38 +00:00
Javi Velasco
e65c56e7e6
Refactor i18n checks on request handling (#27328)
Currently there is a lot of mutation in the Next.js Server and the checks for Locale are directly coded in the general request handler. Ideally, we should have a function where we just pass the request input (url + headers + config) and generate a bunch of metadata that analyzes it generating all metadata we might require for both the URL and i18n + basePath information.

This PR brings:
- A new parsing function `parseUrl` that joins parsing an absolute/relative URL into a data structure compatible with the Node parsing output but missing redundant properties.
- A wrapper `parseNextURL` that extends `parseUrl` analyzing `i18n` and `basePath` based on the provided configuration, url and headers. This function is pure and stateless so it can be used outside of the Next.js context.
- Types improvements and reuse.
- Refactors `next-server.ts` request handling using the above mentioned functions so that the code there just apply effects to the `req` object and the `parsedUrl.query` leaving the code much more straightforward.
- Refactors `getRouteRegex` decomposing in two different functions where `getParametrizedRoute` can be used to retrieve the serializable data that is used to generate the Regex.
2021-07-21 16:12:33 +00:00
Andres Barbaro
bdcb8b0a71
Allow enabling worker threads on dev server (#23027)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-20 19:12:57 -05:00
fabb
8e34902fb9
Update NextConfig type to not require experimental or future fields (#25517)
when typechecking next.config.js as described [in the docs](https://github.com/vercel/next.js/blob/canary/docs/basic-features/typescript.md#type-checking-nextconfigjs), an error would be thrown if `future` and `experimental` are missing. When using `Partial<>` in the type definition instead, it works as expected.

Fixes #25498

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-07-20 18:42:29 +00:00
JJ Kasper
a972579304
v11.0.2-canary.18 2021-07-20 12:36:49 -05:00
Jamie
7c408e7a0f
Fix ISR page re-rendering after revalidate expiry (Fork of #24807) (#27335)
Fixes: #24806 
Fixes: #26689
Fixes: #27325
Closes: #24807

@tommarshall has done us a huge favor with his PR https://github.com/vercel/next.js/pull/24807 which outlines exactly the issue and a pragmatic solution.

I'm not trying to "steal their work", however, the PR seems to have been stuck for some months. I think there's huge value in this for myself and others as essentially **ISR is broken** for people running Next.js at scale 😱 

This PR has cherry-picked @tommarshall's fine fix and added some integrations tests around page revalidation and the edge case when the cache size is exhausted.

✏️ Edits are enabled, so feel free great Vercel staff and other maintainers to improve my bad tests or surrounding code 🙇 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
2021-07-20 17:01:42 +00:00
Gerald Monaco
ade52553b6
Add RequestContext (#27303)
How a page is rendered depends on whether or not we're streaming. For example, if we're just rendering to a `string` or we're generating a response for a crawler or other robot, we don't want React 18 to dynamically flush `<script>` tags to update Suspense boundaries as they resolve. Instead, we just want to wait for the full HTML to resolve and return a result similar to `renderToString`.

This is what `RequestContext` and the new/refactored `pipe` and `getStaticHTML` methods allow.  They add a `requireStaticHTML` option that gets passed down. A follow-up PR will make sure this is `true` when serving a robot, and also ensure React is invoked appropriately.
2021-07-20 16:04:31 +00:00
Mikhail Tsyplakov
2a282a4081
fix type NextWebVitalsMetric (#24780)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-19 20:39:24 -05:00
Steven
5cd37d9b32
Fix placeholder=blur inside <noscript> (#27311)
We shouldn't be setting `placeholder=blur` styles when JS is disabled because we'll have no way to know when the image is loaded and it will be stuck in blur permanently as mentioned in [this comment](https://github.com/vercel/next.js/pull/19052#issuecomment-882886068).

This PR avoids blur styles on the `<noscript>` version of the image.
2021-07-20 01:23:16 +00:00
JJ Kasper
198046360d
v11.0.2-canary.17 2021-07-19 18:31:57 -05:00
JJ Kasper
1effbae67a
Fix default server host value causing issues on Windows (#27306)
This fixes a case where the HMR connection for fast refresh would fail to connect on Windows due to a change being made to the default host being listened to. Previously we didn't set a default for the `host` value when calling `server.listen` which allowed the default listening behavior to be used although in https://github.com/vercel/next.js/pull/20409 a default of `0.0.0.0` was added which causes conflicts for some set-ups mainlly on Windows it seems. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/27298
Fixes: https://github.com/vercel/next.js/issues/27254
Fixes: https://github.com/vercel/next.js/issues/4456#issuecomment
Fixes: https://github.com/vercel/next.js/pull/20409#issuecomment-849933092
x-ref: https://github.com/vercel/next.js/pull/20409
2021-07-19 23:12:27 +00:00
Steven
b123942694
Fix minimumCacheTTL so it doesn't affect browser caching (#27307)
In a previous PR (#27200), we added `minimumCacheTTL` to configure the time-to-live for the cached image. However, this was setting the `max-age` header.

This PR ensures that `minimumCacheTTL` doesn't affect browser caching, only the upstream header can affect browser caching.

This is a bit safer in case the developer accidentally caches something that shouldn't be and the cache needs to be invalidated. Simply delete the `.next/cache/images` directory.

- Related to #19914
- Related to #22319
2021-07-19 22:38:03 +00:00
Janicklas Ralph
dda23f5d9b
Fix inline scripts being duplicated when used with next/script component (#27218)
Fixes inline scripts being duplicated when used with `next/script` component

## Bug

- [x] fixes #26860 
- [x] Integration tests added


## Documentation / Examples
 Updated docs to indicate that `id` is needed for inline scripts
2021-07-16 18:58:34 +00:00
Houssein Djirdeh
6645248d41
[ESLint] Remove error when file patterns are unmatched + ESLint setup changes (#27119)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-07-16 20:19:08 +02:00