Commit graph

3523 commits

Author SHA1 Message Date
Tim Neutkens
d746db6f5c v10.2.1-canary.9 2021-05-17 14:16:14 +02:00
Tobias Koppers
3bf4ae3767
performance improvement of static generation (#25035)
### move all access to built pages into worker pool

to allow parallelizing and avoid loading the bundles in the main thread

This improves performance of the static check step a bit and helps reducing memory load in main thread

### enable splitChunks for server build in webpack 5

This improves performance for static generation by loading less code due to reduced duplication
2021-05-17 12:04:06 +00:00
JJ Kasper
a4420532b9
Update @hapi/accept to latest (#24283)
Updates to the latest version of `@hapi/accept`, opening this one instead of https://github.com/vercel/next.js/pull/23142 since it has unrelated changes and is stale. 

Close: https://github.com/vercel/next.js/pull/23142
Fixes #20488
2021-05-16 19:01:24 +00:00
Alexander Kachkaev
e5da204aab
Upgrade browserslist to 4.16.6 (#24692)
## Bug

- [x] Related issue: [CVE-2021-23364](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23364)
- ~Integration tests added~ (N/A)
2021-05-16 18:30:02 +00:00
JJ Kasper
68ecbddd14
Re-add strip-ansi babel include (#25146) 2021-05-16 14:05:58 +02:00
JJ Kasper
659dae0425
v10.2.1-canary.8 2021-05-14 15:41:49 -05:00
JJ Kasper
ec9ed57487
Remove import type syntax (#25145)
* Remove import type syntax

* Update build-output test
2021-05-14 13:42:36 -05:00
Tobias Koppers
84d5766f43
Disable suggesting incremental type checking (#25144)
It have performance characteristics that might not work for everyone.
You can still enable it manually.
2021-05-14 19:08:06 +02:00
Tim Neutkens
d9000d073b v10.2.1-canary.7 2021-05-14 16:41:54 +02:00
Tobias Koppers
0750092cf1
add experimental.gzipSize flag which allows to switch to uncompressed sizes (#25028)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-05-14 16:29:49 +02:00
Tim Neutkens
c1528e4f3d
Remove experimental-modern-preset option (#25100) 2021-05-14 15:55:24 +02:00
JJ Kasper
5bff9eac08
Ensure rewrites work with manual href/as correctly (#25112)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-14 12:50:41 +02:00
JJ Kasper
e6a05ee940
Fix export worker threads options (#25063)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-14 12:50:29 +02:00
Yamagishi Kazutoshi
7f73b65849
Escape href when detecting already existing preload tags (#20782)
When Image Optimization is enabled, if the URL of the image is not correct as a regular expression (e.g. `/image.png?lang=c++`), Next.js will give an error and fail to build.
2021-05-14 02:40:20 +00:00
Tim Neutkens
7cb00b841f
Remove leftover babel include regex (#25101)
This regex is no longer needed since it no longer matches with the strip-ansi version that is bundled with Next.js



## 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-05-13 17:14:29 +00:00
Tim Neutkens
7d75bc3ed1 v10.2.1-canary.6 2021-05-13 16:32:33 +02:00
JJ Kasper
40e178e611
Ensure rewrite does not override params from page in minimal mode (#25074)
This makes sure a catch-all rewrite doesn't override the params from a dynamic route in minimal mode, it also makes sure we don't attempt applying headers and rewrites un-necessarily in minimal mode. 

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
2021-05-13 11:40:25 +00:00
Janicklas Ralph
eaf74c1cb8
Improving script loading strategy (#24939) 2021-05-13 12:39:36 +02:00
Tobias Koppers
288984b1ea
enable contenthashing in webpack 5 (#25055)
This improves long term caching by avoiding hash changes

workaround fix #25013 
The real problem is fixed by #24573

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
2021-05-12 16:33:51 +00:00
Tobias Koppers
5f3351dbb8
use official mini-css-extract-plugin and experimentalUseImportModule (#24573)
## 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-05-12 16:04:01 +00:00
JJ Kasper
9a0fc42d56
Fix ie11 support with webpack 5 (#25014)
This fixes ie11 compatibility that broke in https://github.com/vercel/next.js/pull/24656 from the polyfills not being loaded first, our existing ie11 test caught this but was failing, this ensures the test is passing again. This also updates the `hrefValue` optional chaining in the eslint plugin as these files aren't transpiled and related tests were failing in azure 

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
2021-05-12 12:24:42 +00:00
Janicklas Ralph
6ad9172295
Font optimization bug fix (#24968) 2021-05-12 13:39:26 +02:00
Janicklas Ralph
b859c5bdf5
Refactor scriptloader option names (#25012) 2021-05-12 13:37:57 +02:00
Tobias Koppers
614f105b0f
allow incremental type checking to use caching (#24992)
emit must be called on build program to leverage caching

While the the current way of calling incremental typescript seem to work, it actually doesn't use caching correct. A difference is only notice-able on larger code bases...
2021-05-11 15:18:31 +00:00
Tim Neutkens
30462ebf2c v10.2.1-canary.5 2021-05-11 09:24:55 +02:00
JJ Kasper
e00e3c978d
Ensure webpack cache is invalidated for alias change (#24956) 2021-05-10 17:29:33 -05:00
Tobias Koppers
2330bf9ddd
update webpack to 5.37.0 (#24954)
fixes a small bug which caused the webpack chunk to be too big as it includes references to all pages

## Bug

- [x] 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-05-10 17:18:44 +00:00
Tim Neutkens
da97a18daf v10.2.1-canary.4 2021-05-10 14:43:02 +02:00
Luigi Colombi
59564af9cb
I18n context initial props (#21930)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-10 14:11:19 +02:00
Darsh Patel
9e87596bd6
Fix: Non-writable pages/_app breaks build (#24849)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-10 10:39:18 +02:00
Janicklas Ralph
86827058e4
Refactor experimental-script component (#24940) 2021-05-10 10:39:08 +02:00
Tim Neutkens
8218d5d508 v10.2.1-canary.3 2021-05-07 19:40:20 +02:00
Radosław Grochowski
7f1c8a9bbe
fix: handle compression for custom-server render calls (#16378) (#18891)
Co-authored-by: Radosław Grochowski <radoslaw.grochowski@grupawp.pl>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-05-07 19:37:51 +02:00
JJ Kasper
9d25194e7d
Ensure next/dynamic transpiles for tests (#24751)
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2021-05-07 19:21:54 +02:00
Tobias Koppers
4e8fac93fd
cache typechecking with incremental compilation (#24559)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-07 19:21:20 +02:00
Tim Neutkens
42c4743fbd
Remove experimental babel flag (#24776) 2021-05-07 19:17:45 +02:00
Tobias Koppers
33e09dffb2
webpack 5 externals fixes (#24603)
* fix check in externals that validate if the require is resolve-able for the server
* performance improvements

Fixes #23130

## Bug

- [x] 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.
- [x] 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.

## Documentation / Examples

- [ ] Make sure the linting passes
2021-05-07 16:32:33 +00:00
Sebastian Silbermann
7c7e86454e
feat(build): Log whether type checking is actually performed (#24440)
Closes https://github.com/vercel/next.js/issues/24889

## Feature

Currently `next build` is logging "Checking validity of types" even if `typescript.ignoreBuildErrors` is `true`. It seems like these options still work so `next build` either shouldn't log anything related to type-checking or log that type-checking is skipped.

I decided to branch the log message for clarity.

Happy to add a test but I'm not sure if you have existing infra considering https://github.com/vercel/next.js/pull/23226/files (which added the message) didn't add or change tests either.

CI failures look unrelated to me.
2021-05-07 14:34:15 +00:00
JJ Kasper
802af5ff5b
Land - Font optimizations - Adobe Fonts / Typekit support (#24834)
This updates this initial PR here https://github.com/vercel/next.js/pull/18146 to resolve merge conflicts and updates tests since we aren't able to update that PR itself.

## 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
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

Closes: https://github.com/vercel/next.js/pull/18146
2021-05-06 04:02:07 +00:00
Vitaly Baev
54ff3223b4
Don't throw 500 error when Content-type is invalid (#24818)
Fixes #24768

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
2021-05-05 14:27:44 +00:00
Tobias Koppers
83395c92ec
fix memory leak in require.cache (#24282)
Previously only the top-level page would be cleared from the require cache, with this change it also clears `module.parent` and `modules.children`.
2021-05-05 09:26:36 +00:00
Tobias Koppers
3a78ccd43f
Add type checking events (#24595)
Will send events like this:

```
[telemetry] {
  "eventName": "NEXT_TYPE_CHECK_COMPLETED",
  "payload": {
    "durationInSeconds": 2,
    "typescriptVersion": "3.8.3",
    "inputFilesCount": 16,
    "totalFilesCount": 289,
    "incremental": false
  }
}
```

## 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-05-04 08:41:01 +00:00
Tobias Koppers
1d643eb6e1
update webpack to 5.36.2, use dependOn (#24656)
* update webpack to 5.36.2
* use dependOn to optimize chunks
* disable vendor splitting for main and _app chunks

=> decreases bundle size in general, gets rid of the 2 extra vendor chunks shared by all pages.

## 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-05-03 10:25:44 +00:00
JJ Kasper
9c47ca2cfd
v10.2.1-canary.2 2021-04-30 13:27:54 -05:00
Joon Park
c76170e829
Add experimental blurry placeholder to image component (#24153)
This is the image component implementation of the blurry placeholder as described in #24004. The matching server side implementation is currently planned.

## 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 issue #18858 
- [x] Integration tests added

(Documentation and telemetry to follow after server side is implemented)
2021-04-30 17:05:03 +00:00
Ishank Sharma
9bbb968c43
Fix/link router 24075 take asPath instead of pathName in router (#24199)
Fixes: #24075

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


## Documentation / Examples

- [x] Make sure the linting passes
2021-04-30 16:34:23 +00:00
Pepijn Senders
d5de1c53c1
Don't swallow MODULE_NOT_FOUND error (#24577)
## Bug

- [x] Related issues linked using [`fixes #24328`](https://github.com/vercel/next.js/pull/24328#issuecomment-828847472)
- [ ] Integration tests added

The change in #24328 will swallow any `MODULE_NOT_FOUND` errors triggered in the page. If you for example have a page with a broken import, it will tell you `Error: Failed to load /whatever`. This of course doesn't really tell people what is going on internally (a broken import). I added a check to see if the error actually happened in the page.
2021-04-30 15:45:25 +00:00
Houssein Djirdeh
e783b0a2e8
Adds ESLint with default rule-set (#23702)
This PR re-includes ESLint with some notable changes, namely a guided setup similar to how TypeScript is instantiated in a Next.js application.

To add ESLint to a project, developers will have to create an `.eslintrc` file in the root of their project or add an empty `eslintConfig` object to their `package.json` file.

```js
touch .eslintrc
```

Then running `next build` will show instructions to install the required packages needed:

<img width="862" alt="Screen Shot 2021-04-19 at 7 38 27 PM" src="https://user-images.githubusercontent.com/12476932/115316182-dfd51b00-a146-11eb-830c-90bad20ed151.png">

Once installed and `next build` is run again, `.eslintrc` will be automatically configured to include the default config:

```json
{
  "extends": "next"
}
```

In addition to this change:

- The feature is now under the experimental flag and requires opt-in. After testing and feedback, it will be switched to the top-level namespace and turned on by default.
- A new ESLint shareable configuration package is included that can be extended in any application with `{ extends: 'next' }`
  - This default config extends recommended rule sets from [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), and [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next)
- All rules in [`eslint-plugin-next`](https://www.npmjs.com/package/@next/eslint-plugin-next) have been modified to include actionable links that show more information to help resolve each issue
2021-04-30 11:09:07 +00:00
JJ Kasper
49cd08da17
v10.2.1-canary.1 2021-04-29 19:52:43 -05:00
JJ Kasper
01c15c5150
Remove un-used lib files (#24625) 2021-04-29 19:48:39 -05:00
JJ Kasper
f9faf3f96a
v10.2.1-canary.0 2021-04-29 12:55:54 -05:00
JJ Kasper
1e441fe440
Replace regex lexer with minimal regex for named groups (#24604) 2021-04-29 12:50:06 -05:00
Shu Ding
89d2c4e198
Fix Image compatibility issue when using sizes (#24569)
When using `sizes`, [`matchAll`](https://caniuse.com/mdn-javascript_builtins_string_matchall) isn't supported by older browsers like IE and Safari 12. This PR changes it to `exec`.

There're already tests of `sizes` with multiple `vw` values covered.

Fixes #23677.

## Bug

- [x] 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.
- [x] 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-04-29 10:07:27 +00:00
Sumanth Ratna
a35dedb7d3
Remove unnecessary optimizeFonts key from type (#24563)
https://github.com/vercel/next.js/pull/21676 moved `fontOptimization` out of the experimental key of `NextConfig` to the top level, so it should be removed from the type

## 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-04-28 22:47:31 +00:00
JJ Kasper
6b97bcea5b
v10.2.0 2021-04-28 09:32:18 -05:00
JJ Kasper
0abbb75b29
v10.1.4-canary.18 2021-04-28 08:58:39 -05:00
Tim Neutkens
b26077bd25
Upgrade postcss (#24546)
Fixes #24421



## Bug

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

Can't add an integration test currently, we'll add Node 16 tests later.

## 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-04-28 13:16:41 +00:00
Tim Neutkens
53c19ff185
Test fixes for Babel mode (#24312)
* Try enabling Babel turbo mode

* Pass config file explicitly to babel turbo loader.

* Update NextBabelLoaderOptions to use `configFile` instead of `babelrc`.

* Re-add support for options passed to next/babel preset with new babel loader.

* Load babel config files depending on their file extension.

* Include `next/babel` if no Babel config is provided.

* Minor cleanup.

* Avoid duplicate `next/babel` entries.

* No need to pass configFile anymore.

* Fix multiple small issues in merging loader opts with cached config.

* Remove redundant logging (that also breaks a test).

* Include file extension CharacteristicsGermaneToCaching.

* bump

* Disable turboMode now that tests pass

Co-authored-by: Dale Bustad <dale@divmain.com>
2021-04-28 11:51:57 +02:00
JJ Kasper
f3d518385c
Remove experimental note for has routes (#24529)
This removes the warnings/notes for the `has` custom-routes feature being experimental

## Documentation / Examples

- [x] Make sure the linting passes
2021-04-28 09:08:38 +00:00
JJ Kasper
0f2bd4f252
v10.1.4-canary.17 2021-04-27 12:02:08 -05:00
JJ Kasper
efa58efd0c
Ensure stalled CSS triggers fallback navigation (#24488)
This ensures when CSS requests stall that they are included in the route load timeout so that stalled CSS requests don't block us from falling back to a hard navigation. This handles a rare case noticed by @pacocoursey where a transition did not complete while attempting to load CSS assets. 

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
2021-04-27 07:49:28 +00:00
Janicklas Ralph
fff183c4cd
Font optimization bug fix (#24162)
## Bug

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

Fixes #23896
2021-04-26 18:30:21 +00:00
JJ Kasper
cac9ccf9ce
Ensure proxy rewrite does not hang on error (#24394)
* Ensure proxy rewrite does not hang on error

* remove logs

* Listen to req close
2021-04-26 08:40:32 -05:00
Tim Neutkens
cf4ba8d705
Upgrade eslint to the latest version (#24377)
## 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-04-25 18:34:36 +00:00
Allen Hai
08ee60d56e
[next] update initial config message (#23165)
This PR updates the initial typescript config message to mention that strict-mode is off by default to maintain expectations about type errors. 

[Tweet](https://twitter.com/timneutkens/status/1372218890260987904?s=20)
2021-04-25 15:56:37 +00:00
Gerald Monaco
29402f3c68
Replace experimental reactMode with reactRoot (#24280)
* Remove reactMode config

* Add config + warning

* Tweak wording on warning

* Tweak wording on warning

* Don't default reactRoot for 10.x

* yak shaving

* Add warning when using old reactMode
2021-04-24 15:19:07 -05:00
Joe Haddad
2743a74b62
v10.1.4-canary.16 2021-04-23 15:23:56 -04:00
Joe Haddad
079c629165
experimental: remove legacy plugin system (#20759)
* chore: remove old plugins implementation

* chore: remove `onErrorMiddleware`

* Reduce allowed middleware

* remove collect plugins file

* remove old tests

* remove old demo packages
2021-04-22 14:03:13 -05:00
JJ Kasper
1e9f45931c
v10.1.4-canary.15 2021-04-22 09:51:04 -05:00
Shu Ding
6cd1c87451
Fix not exposing server errors in hot reloader (#24331)
Fixes #24056.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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-04-22 11:47:15 +00:00
JJ Kasper
85d87a3795
Ensure dev overlay is triggered for more _app/_document errors (#24328)
This expands on https://github.com/vercel/next.js/issues/24070 and ensures we show the dev overlay for additional cases like where `_app` or `_document` have syntax errors causing compilation to not be able to complete. This achieves showing the dev overlay even when compilation fails from a syntax error by doing a third minimal compilation in development with the needed client-side assets to render the dev overlay. 

## Bug

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

x-ref: https://github.com/vercel/next.js/issues/24070
2021-04-22 11:08:47 +00:00
JJ Kasper
1caa7f4971
Bump next-babel-loader cache key (#24335)
This bumps the babel cache key since we modified the `react-loadable` babel plugin and we don't want any cached versions used since the module names generated in previous cached version won't match the newly expected values. 

x-ref: https://github.com/vercel/next.js/pull/24281 

## 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-04-22 08:26:07 +00:00
Janicklas Ralph
9edb1ef16d
Adding script loader files to package.json (#24326)
Adding script loader files to package.json
2021-04-22 03:35:38 +00:00
Kyle Marshall
a29d8c9eaf
Ensure locale key not duplicated when navigating back to root path with a query or hash value (#24323)
This ensures that a duplicate locale key is not prepended to the path when navigating back (using browsers back button) to the root path containing query parameters or a hash value.

Current behaviour:
* `/fr?value=1` -> `/fr/another` -> click browser back button -> `/fr/fr?value=1`
* `/fr?value=1` -> `/fr?value=2` -> click browser back button -> `/fr/fr?value=1`
* `/fr#section` -> `/fr/another` -> click browser back button -> `/fr/fr#section`
* `/fr#section` -> `/fr#another` -> click browser back button -> `/fr/fr#section`

Fix:
Remove query string or hash value from path before determining whether to add the locale to the path in `addLocale` function.

## Bug

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

Fixes: #24287
2021-04-22 03:06:26 +00:00
Tim Neutkens
03cc0f89ed v10.1.4-canary.14 2021-04-21 13:59:43 +02:00
Tim Neutkens
755fc6f0da v10.1.4-canary.13 2021-04-21 13:59:04 +02:00
Tobias Koppers
08baf526ff
improve react-loadable-plugin (#24281)
Co-authored-by: JJ Kasper <jj@jjsweb.site>



## Bug

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


Closes: https://github.com/vercel/next.js/issues/22741
2021-04-21 11:18:05 +00:00
Tobias Koppers
710ad29714
webpack 5.35 (#24293)
* memory usage improvements for `next dev`
2021-04-21 10:06:16 +00:00
JJ Kasper
bfac04dcbc
v10.1.4-canary.12 2021-04-20 16:06:53 -05:00
tarunama
7fd5a24d94
feat: add type to previewData (#21574)
`previewData` was already [typed declare variable](https://github.com/vercel/next.js/compare/canary...tarunama:feature/remove-any1?expand=1#diff-bd7baf53ff559d84461af8b2fd62cade7e2d8eb203f489e24a27c5b83a79a9d3L1380).
So I have defined `PreviewData` type, and adapt for avoiding error by type safe.
2021-04-20 18:13:48 +00:00
Gerald Monaco
1f5f0d313a
Fix metrics measurements under new root API (#24110)
Previously, we weren't recording most (all?) of the Next.js measurements like `Next.js-hydration` in Concurrent Mode. This was mainly because the new API doesn't accept a callback.

Instead of special casing this, I've refactored it so that the measurements are just recorded when Root first flushes (via `useLayoutEffect`), which should be more or less the same timing for the old API.

Concurrent Mode is a little trickier for two reasons:

1. Flushes might be (slightly) delayed due to time-slicing and prioritization
2. Selective hydration might skew measurements in cases where full hydration is aborted

I don't have a good answer for those yet, so they'll need to be addressed when the time comes.
2021-04-20 15:37:32 +00:00
Tim Neutkens
8d84b08752
Add event for webpack 5 usage (#24222) 2021-04-20 16:46:40 +02:00
JJ Kasper
e532c58c23
Ensure locale cookie does not error with similarly named cookie (#24182)
This ensures we don't error when a cookie with a similar name to the `NEXT_LOCALE` cookie is present. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23787
Closes: https://github.com/vercel/next.js/pull/23788
2021-04-20 13:41:14 +00:00
Dale Bustad
b2d8e15d1e
Babel Turbo Loader, Part 2 (#24078)
This PR addresses the potential for memory leakage with the previous caching scheme; it should also be more efficient, resulting in fewer instances where a fresh Babel config must be generated.  Documentation has been added, and `overrides` have been removed in favor of conditional plugins for consistency.

This approach is easier to break, in that `CharacteristicsGermaneToCaching` must be correct for all cases.  However, it means that <= 8 configs will need to be generated within the context of a single thread, and the config-caching is about as fast as we can get it.
2021-04-20 08:45:57 +00:00
JJ Kasper
bfde2833c0
v10.1.4-canary.11 2021-04-19 21:41:09 -05:00
JJ Kasper
aab6b37e50
Omit un-necessary stack trace from invalid routes (#24240)
This removes the extra stack trace from throwing an error instead of logging and then exiting since the stack trace doesn't provide any additional information that is helpful for debugging in this case. 

<details>

<summary>Before screenshot</summary>

![image](https://user-images.githubusercontent.com/22380829/115301794-4f3b1280-a127-11eb-8a0d-0797efb8fc9f.png)


</details>

<details>

<summary>After screenshot</summary>

<img width="962" alt="Screen Shot 2021-04-19 at 3 53 45 PM" src="https://user-images.githubusercontent.com/22380829/115301901-6ed23b00-a127-11eb-83f9-e3f4cf0ed8fe.png">


</details>
2021-04-20 02:03:46 +00:00
Tobias Koppers
155e34c3a6
upgrade webpack to 5.34 (#24230) 2021-04-19 18:18:07 +00:00
Tim Neutkens
aee453e219
Disable strictExportPresence when webpack 5 is enabled (#24214)
Solves an issue some users ran into where enabling webpack 5 highlighted a wrong JSON import where named exports were used for JSON data.

> Should not import the named export 'myValue' (imported as 'myValue') from default-exporting module (only default export is available soon)
2021-04-19 18:50:09 +02:00
Kristoffer K
d24a0c18c1
ci: fix PnP e2e tests using Webpack 5 (#24216)
Fixes the e2e PnP tests by updating `enhanced-resolve` to get the fix in https://github.com/webpack/enhanced-resolve/pull/289, the tests started failing in https://github.com/vercel/next.js/pull/23810

## 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-04-19 14:43:55 +00:00
JJ Kasper
0bcc6943ae
v10.1.4-canary.10 2021-04-18 08:59:27 -05:00
Tobias Koppers
5bdef6aabe
startup performance improvements (#24129)
* import next-server logic during the time the configuration is loaded
* load minimizer plugins only when used
* load ReactDevOverlay only when used
* load only meta information of tsconfig for validation
* make worker for configuration loading lighter
* only load runTypeCheck when used
* load postcss config only when used
2021-04-18 10:28:09 +00:00
JJ Kasper
65588083db
Ensure query for static pages with rewrites is updated correctly (#24189)
This updates the query refreshing on the client to also refresh when rewrites are used and the page is static since additional query values can be provided from rewrites that are relied on client-side. An additional test has been added in the custom-routes suite to ensure this is working correctly. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23490
Fixes: https://github.com/vercel/next.js/issues/22931
Fixes: https://github.com/vercel/next.js/issues/21062
2021-04-18 10:00:04 +00:00
JJ Kasper
6e7245cddb
Add error for getStaticPaths on non-dynamic page (#24188)
Noticed in this issue the reproduction was using `getStaticPaths` on a non-dynamic page incorrectly although we don't currently show an error for this. 

## Bug

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

x-ref: https://github.com/vercel/next.js/issues/22931
2021-04-18 09:31:40 +00:00
JJ Kasper
a153b63240
Ensure locale is not duplicated from differing casing (#24187)
This ensures we don't attempt adding a locale to a path when the locale is already present but in a different casing, this also ensures we successfully remove the locale if the casing differs in the path. Additional tests have been added in the `i18n-support` suites to ensure this is working correctly. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23553
2021-04-18 09:01:01 +00:00
umarsenpai
9fcfce3463
Fix serving Images through external rewrite with Image component (#21001)
This PR fixes the issue described here: https://github.com/vercel/next.js/issues/20909

The _req passed to getRequestHandler doesn't have `on` function which is required by http-proxy. It throws the error e.on is not a function. We should also wait for buffer to finish writing before sending the response. 

Fixes: https://github.com/vercel/next.js/issues/20909
Closes: https://github.com/vercel/next.js/issues/24177
2021-04-17 21:03:08 +00:00
JJ Kasper
432c9ee5fc
Use same num workers between export and build (#24180)
This ensures we use the same `numWorkers` config between `next build` and `next export` since we already calculate the correct value to use [in the config](6e22a440e2/packages/next/next-server/server/config-shared.ts (L99-L103)). 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23318
2021-04-17 20:09:26 +00:00
JJ Kasper
fe0583edea
v10.1.4-canary.9 2021-04-16 10:09:07 -05:00
JJ Kasper
7d77a19af2
Fix fallback: false triggering 404 before rewrites (#24121)
This fixes dynamic pages with `fallback: false` that don't have a matching path causing a 404 before rewrites are checked unexpectedly. This ensures we treat `fallback: false` pages as a match only if they also have a matching static path so that fallback rewrites can be triggered correctly. An additional test suite as been added to ensure this is working as expected. 

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
2021-04-16 15:07:24 +00:00
Martin Alix
b2ee0a93fe
Fix IE11 incompatibility due to string litterals (#23784)
Fixes #22270

## Bug

- [X] Related issues linked using `fixes #number`
- [  ] Integration tests added
2021-04-15 16:34:52 +00:00
JJ Kasper
3fb4e091bc
v10.1.4-canary.8 2021-04-15 09:50:36 -05:00
Tobias Koppers
1c2ee7c6b8
improve pr stats action (#24086)
* add cache build duration tracking
* default = webpack 5
* better hash handling
* allow to opt-out of webpack5 via `future.webpack5: false`
2021-04-15 11:46:56 +00:00
JJ Kasper
1797fc50ab
Fall back to default components when a top-level error occurs (#24079)
This fixes an internal server error showing when a top-level error occurs in `_app` in development instead of the dev overlay. This includes the failing test case from https://github.com/vercel/next.js/pull/24069 and also ensures the overlay is cleared when the error is corrected. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/24070
Closes: https://github.com/vercel/next.js/pull/24069
2021-04-15 10:19:19 +00:00
Tobias Koppers
1e207301c2
update webpack to 5.33 (#24077)
relevant changes:

* performance improvements for `export *` and reexports
* fixes incorrect cache invalidation when new properties are added to the DefinePlugin (fixes #23901)
2021-04-14 21:23:13 +00:00
Joe Haddad
880935842f
fix: upgrade cssnano/postcss version (#24034)
This PR upgrades CSSNano and PostCSS to v8, fixing various longstanding PostCSS bugs in PostCSS@7. This should yield an overall install size win.
2021-04-14 08:44:07 +00:00
Gerald Monaco
cb7ef3feb5
Add react@experimental testing (#23359) 2021-04-13 19:16:45 +02:00
JJ Kasper
c3390b8cca
v10.1.4-canary.7 2021-04-13 11:35:21 -05:00
Tim Neutkens
9baee888af
Clean up eventsource initialization (#24015)
Just cleans up some code, doesn't change the underlying mechanism



## 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-04-13 16:32:36 +00:00
JJ Kasper
4d291bd810
Use regex lexer for gathering named groups from has (#23626)
This is a follow-up to https://github.com/vercel/next.js/pull/23588 to update to use a regex lexer to gather the named regex groups instead of attempting to gather them through executing the regex since it can fail to gather the regex groups when they are using specific matching. This also ensures we don't pass the value as a segment when value is defined and it doesn't use a capture group. Additional tests are added to cover these cases and documentation updated to reflect this. 

Closes: https://github.com/vercel/next.js/issues/23415

## Bug

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

## Documentation / Examples

- [x] Make sure the linting passes
2021-04-13 12:34:51 +00:00
Shu Ding
b610db830e
Add request deduplication to image optimizer (#24000)
This PR adds the deduplication logic to image optimizer so the cache will be reused as much as possible if there're multiple concurrent requests.

Fixes #23436.

## Bug

- [x] 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-04-12 22:38:51 +00:00
Tim Neutkens
25ca1b5bab v10.1.4-canary.6 2021-04-12 19:58:36 +02:00
Tim Neutkens
2dba861ea3
Enable webpack5 by default (#23810)
- Enable webpack 5 by default for apps without custom webpack configuration

Fixes #23143



## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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-04-12 17:52:43 +00:00
JJ Kasper
1be97547d9
v10.1.4-canary.5 2021-04-12 11:33:08 -05:00
JJ Kasper
ec62ea6134
Ensure minimal mode SSR 404 handling is correct (#23996) 2021-04-12 11:31:51 -05:00
JJ Kasper
f02363e0c4
Ensure no-op rewrite matches dynamic route with i18n correctly (#23860)
This ensures we match dynamic routes correctly when applying `check: true` behavior with i18n so that no-op rewrites match dynamic routes correctly. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23854
2021-04-12 09:42:01 +00:00
Tim Neutkens
c5c16494e3 v10.1.4-canary.4 2021-04-12 10:34:17 +02:00
Tim Neutkens
2b48670bd6
Remove bugfix needed for webpack 4 when webpack 5 is used (#23886)
Tobias has fixed the `compiler.hooks.invalid.call()` bug in webpack 5 so this is no longer needed



## 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-04-11 15:06:35 +00:00
Tobias Koppers
2c2ac2e868
reduce the number of write syscalls by buffering (#23863)
buffer the output of bfj to avoid 1000s of small write calls
2021-04-09 21:43:30 +00:00
Tobias Koppers
1258d13d73
upgrade webpack to 5.31.2 (#23861)
https://github.com/webpack/webpack/releases/tag/v5.31.1

## 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-04-09 18:31:26 +00:00
Tim Neutkens
a561dd9cdb
Resolve new babel loader through require.resolve (#23819) 2021-04-08 16:15:42 +02:00
Tim Neutkens
911bdacf89 v10.1.4-canary.3 2021-04-08 14:48:18 +02:00
Dale Bustad
c2dfe40296
Babel fast mode (#23760)
@timneutkens it'd be great to get your input.

These changes introduce a new Babel loader that eliminates much of the existing overhead, resulting in better HMR speeds. 
 Multithreading is still in flight, and may be omitted if speed improvements end up being negligible.  For now, the new loader is hidden behind an `experimental` flag.

Items to be completed before this PR is ready to merge:

- [x] reconfigure `ncc` to precompile the parts of `@babel/core` and `@babel/traverse` that we're accessing directly
- [x] change `@babel/core/...` imports to `ncc`ed version
- [x] ~~measure multithreading (not currently pushed) functionality, and include the functionality depending on the results~~ I'll open a separate PR for this
- [x] ensure TypeScript is happy with all imports as final step (`--no-verify` was used to bypass)

There will be two follow-up PRs:
- loader support for projects with custom `.babelrc`
- multithreaded loader (should the change we warranted after measurement)
2021-04-08 12:03:02 +00:00
Tobias Koppers
c5cf9e4c69
upgrade to webpack 5.31.0 (#23776)
* fixes a bundle size regression from webpack 4 to 5
* fixes these warnings during resolving build dependencies for packages using `exports`

## 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-04-07 18:55:06 +00:00
JJ Kasper
23ad3a7189
v10.1.4-canary.2 2021-04-06 12:26:23 -05:00
JJ Kasper
348115036c
Ensure no-op export returns without error (#23752)
This ensures we don't reach the invariant from trying to create the export progress with no items during `next build` or `next export` by returning immediately when we notice there are no paths being exported. Additional tests have been added to ensure these cases don't error. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23724
2021-04-06 17:12:23 +00:00
JJ Kasper
45b8c88521
Ensure fallback rewrites dont match over pages with i18n (#23674)
This ensures we are checking the filesystem correctly when i18n is used to prevent fallback rewrites from being applied even when a page is matched. Additional tests have been added to ensure these cases are being handled. 

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23577
2021-04-06 10:25:04 +00:00
JJ Kasper
55c6b7aba2
Ensure basePath is not applied for external GSSP redirect (#23673)
This ensures we don't attempt prepending the `basePath` for external (http://) `getStaticProps`/`getServerSideProps` redirects. Additional tests to cover this case have been added in the `gssp-redirect` test suites to prevent regression.

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23623
2021-04-06 10:02:13 +00:00
Felipe Lima
c2c1b96544
Fix webpack5 cache distDir (#23718)
## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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

Fixes: #23716
2021-04-06 08:32:29 +00:00
JJ Kasper
9986d7c92e
v10.1.4-canary.1 2021-04-05 14:10:54 -05:00
Gerald Monaco
63b96b1884
Stop mutating resolvedAsPath (#23705)
Follow up to #23614. `resolvedAsPath` isn't actually even being used as an output, we're just mutating it for convenience. If we do want to output it in the future, we can do it a different way (i.e. via return).
2021-04-05 18:51:21 +00:00
Janicklas Ralph
8fdcc52854
Font optimization (#21676)
Enable font optimization by default
2021-04-05 17:47:03 +00:00
JJ Kasper
bf629f9427
v10.1.4-canary.0 2021-04-05 11:17:37 -05:00
JJ Kasper
88fd76f4d2
Ensure default fallback values are correct with i18n (#23675)
This ensures we don't parse the default params when auto-exporting dynamic routes with i18n since the page and path aren't equal when localized. This adds an additional test case to ensure we don't regress on this behavior in the `i18n-support` test suites.

## Bug

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

Fixes: https://github.com/vercel/next.js/issues/23167
2021-04-04 14:09:20 +00:00
Tim Neutkens
29aa48dfc4 v10.1.3 2021-04-02 12:24:12 +02:00
Tim Neutkens
6e51f2a816 v10.1.3-canary.2 2021-04-02 12:22:15 +02:00
Gerald Monaco
af3315b14d
Clean up RenderOptsPartial (#23614)
* Remove autoExport from RenderOpts

* Remove ampMode from RenderOpts

* Stop passing inAmpMode and hybridAmp

* Unset nextExport when falsy
2021-04-01 20:21:15 -05:00
JJ Kasper
95b9839622
v10.1.3-canary.1 2021-04-01 15:15:29 -05:00
Tobias Koppers
0ad805fee6
update webpack to 5.30 (#23612)
* has some memory usage improvements
* after a while cache entries that are unused and already persistent to disk are removed from the memory cache
  * When are read again, they are restored from disk again
  * Should play well together with adding and removing pages due to on-demand-entries

## 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-04-01 19:25:57 +00:00
Shu Ding
2ed54cddfa
Update decoder to correctly handle grayscale PNGs (#23393)
This PR updates the Squoosh PNG decoder, which fixes #22929 in GoogleChromeLabs/squoosh#971.

## Bug

- [x] Fixes #22929
- [x] 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-04-01 15:16:26 +00:00
JJ Kasper
65c22167c8
Ensure has segments are allowed in destination (#23588)
This ensures we gather segments from the experimental has field when validating segments used in the destination to prevent the invalid segments in the destination error from showing incorrectly. This usage has been added to the custom-routes test suite to ensure the segments are passed correctly from the has field. 

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

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
2021-04-01 09:15:28 +00:00
Tim Neutkens
0d5baf2c70
Mark this.router protected (#23573)
* Mark this.router protected

Seems that some people (#23558) are using Next.js internals based on the typings that TS generates automatically even though these values are not documented / should not be used in applications. This ensures the router value on Server is not used by accident.

* Mark all variables as protected

https://github.com/vercel/next.js/issues/23349

* fix type error

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-03-31 11:37:44 -05:00
Tim Neutkens
ce7f2b8329 v10.1.3-canary.0 2021-03-31 10:27:33 +02:00
Shu Ding
7adfce23ab
Fix memory leak in image optimization (#23565)
This RP fixes the problem that the image optimization API uses a large amount of memory, and is not correctly freed afterwards. There're multiple causes of this problem:

### 1. Too many WebAssembly instances are created

We used to do all the image processing operations (decode, resize, rotate, encodeJpeg, encodePng, encodeWebp) inside each worker thread, where each operation creates at least one WASM instance, and we create `os.cpus().length - 1` workers by default. That means in the worst case, there will be `N*6` WASM instances created (N is the number of CPU cores minus one).

This PR changes it to a pipeline-like architecture: there will be at most 6 workers, and the same type of operations will always be assigned to the same worker. With this change, 6 WASM instances will be created in the worst case.

### 2. WebAssembly memory can't be deallocated

It's known that [WebAssembly can't simply deallocate its memory as of today](https://stackoverflow.com/a/51544868/2424786). And due to the implementation/design of the WASM modules that we are using, they're not very suitable for long-running cases and it's more like a one-off use. For each operation like resize, it will allocate **new memory** to store that data. So the memory will increase quickly as more images are processed.

The fix is to get rid of `execOnce` for WASM module initializations, so each time a new WASM module will be created and the old module will be GC'd entirely as there's no reference to it. That's the only and easiest way to free the memory use of a WASM module AFAIK.

### 3. WebAssembly memory isn't correctly freed after finishing the operation

`wasm-bindgen` generates code with global variables like `cachegetUint8Memory0` and `wasm` that always hold the WASM memory as a reference. We need to manually clean them up after finishing each operation. 

This PR ensures that these variables will be deleted so the memory overhead can go back to 0 when an operation is finished.

### 4. Memory leak inside event listeners

`emscripten` generates code with global error listener registration (without cleaning them up): https://github.com/vercel/next.js/blob/99a4ea6/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.js#L39-L43

And the listener has references to the WASM instance directly or indirectly: https://github.com/vercel/next.js/blob/99a4ea6/packages/next/next-server/server/lib/squoosh/webp/webp_node_dec.js#L183-L192 (`e`, `y`, `r`).

That means whenever a WASM module is created (emscripten), its memory will be kept by the global scope. And when we replace the WASM module with a new one, the newer will be added again and the old will still be referenced, which causes a leak.

Since we're running them inside worker threads (which will retry on fail), this PR simply removes these listeners.

### Test

Here're some statistics showing that these changes have improved the memory usage a lot (the app I'm using to test has one page of 20 high-res PNGs):

Before this PR (`next@10.1.0`):

<img src="https://user-images.githubusercontent.com/3676859/113058480-c3496100-91e0-11eb-9e5a-b325e484adac.png" width="500">

Memory went from ~250MB to 3.2GB (peak: 3.5GB) and never decreased again.

With fix 1 applied:

<img src="https://user-images.githubusercontent.com/3676859/113059060-921d6080-91e1-11eb-8ac6-83c70c1f2f75.png" width="500">

Memory went from ~280MB to 1.5GB (peak: 2GB).

With fix 1+2 applied:

<img src="https://user-images.githubusercontent.com/3676859/113059207-bf6a0e80-91e1-11eb-845a-870944f9e116.png" width="500">

Memory went from ~280MB to 1.1GB (peak: 1.6GB).

With fix 1+2+3+4 applied:

<img src="https://user-images.githubusercontent.com/3676859/113059362-ec1e2600-91e1-11eb-8d9a-8fbce8808802.png" width="500">

It's back to normal; memory changed from ~300MB to ~480MB, peaked at 1.2GB. You can clearly see that GC is working correctly here.

---

## Bug

- [x] Related issues #23189, #23436
- [ ] 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-03-31 08:24:42 +00:00
Tim Neutkens
1ff6057b3a v10.1.2 2021-03-30 10:32:36 +02:00
Tim Neutkens
1344e2dee2 v10.1.2-canary.0 2021-03-30 10:31:45 +02:00
Joe Haddad
eecc3342cb
Temporarily remove experimental ESLint integration (#23521)
This pull request **temporarily** removes ESLint, as it was not landed in accordance with our standard experimental policies. We are fully committed to landing this change again.

This is being reverted because:

- Next.js has very strict goals for its install size. This feature resulted in adding over 17MB, or a 43.6% increase.
- The feature was not first landed under the `experimental` key in `next.config.js`, rather, it was added under the stable namespace (top-level)
- Using the feature doesn't do a "guided setup" like TypeScript, it should ask you to "bring your own" dependencies for ESLint
- It uses a undesirable ESLint plugin name: `plugin:@next/next/recommended`. This should read out as strictly `next`, or as short as we can get it.
- Does not provide actionable warnings (missing link to resolve issue)
- Does not follow appropriate console output styling. We need to revisit how these are presented.

To re-land this, we need to ensure the following minimums are met:
- Very minor change in install size
- Fully experimental (i.e. flagged) with warnings
- Finalized package name and configuration shape, preferably so we can do ` { extends: 'next' } `.
2021-03-30 08:26:35 +00:00
Tim Neutkens
cd46241349 v10.1.1 2021-03-29 18:02:58 +02:00
Tim Neutkens
b73816b2b4 v10.1.1-canary.0 2021-03-29 18:00:50 +02:00
Tim Neutkens
2ec2ea8786
Make eslint opt-in until it lands on stable (#23509) 2021-03-29 17:58:55 +02:00
Tim Neutkens
fc286d6e19 v10.1.0 2021-03-29 16:56:57 +02:00
Tim Neutkens
378ba1d2eb v10.0.10-canary.14 2021-03-29 16:54:12 +02:00
Tim Neutkens
d40a804dd3 v10.0.10-canary.13 2021-03-29 14:01:21 +02:00
Tim Neutkens
46fa9b6421
Temporarily remove the automatic opt-in for webpack5 (#23497) 2021-03-29 13:42:04 +02:00
Tim Neutkens
cd9bb986eb
Add os-browserify dep (#23354)
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-03-29 10:25:27 +02:00
Tim Neutkens
b34a0c98fa
Update err.sh links to use nextjs.org/docs/messages instead (#23353) 2021-03-29 10:25:00 +02:00
JJ Kasper
f28ea89aa7
v10.0.10-canary.12 2021-03-26 11:02:54 -05:00
JJ Kasper
d130f63c41
Add handling fo beforeFiles, afterFiles, and fallback rewrites (#23407)
This adds support for returning an object from `rewrites` in `next.config.js` with `beforeFiles`, `afterFiles`, and `fallback` to allow specifying rewrites at different stages of routing. The existing support for returning an array for rewrites is still supported and behaves the same way. The documentation has been updated to include information on these new stages that can be rewritten and removes the outdated note of rewrites not being able to override pages. 



## 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`
- [x] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
2021-03-26 15:19:48 +00:00
JJ Kasper
9f5b61d091
v10.0.10-canary.11 2021-03-24 15:51:14 -05:00
JJ Kasper
a6c0d76ebb
Run server client/server builds serially (#23371)
Previously we special cased serverless builds and ran the client/server builds serially to allow the server build to load manifests produced in the client. To help with memory usage and for consistency this updates server mode to build in the same way.  

## 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-03-24 20:50:49 +00:00
Shu Ding
98211405a6
Make sure the image optimization endpoint only response with images (#23366)
If the upstream MIME type isn't prefixed with `image/`, the endpoint should directly response with a 400 error.

## Bug

- [x] Fixes #23312
- [x] 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-03-24 17:59:00 +00:00
JJ Kasper
1dae228877
v10.0.10-canary.10 2021-03-24 12:05:28 -05:00
JJ Kasper
75c721c583
Add has route field (#22341)
This adds support for a `has` field to `rewrites`, `redirects`, and `headers` to allow matching against `header`, `cookie`, and `query` values. Documentation and additional tests for the feature is also added in this PR. 

Closes: https://github.com/vercel/next.js/issues/22345
2021-03-24 16:50:16 +00:00
Tobias Koppers
1383bbffa1
upgrade webpack to 5.28.0 (#23350)
fixes some bugs and improves performance

## 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-03-24 13:47:52 +00:00
Tim Neutkens
34f98451bd v10.0.10-canary.9 2021-03-24 14:12:21 +01:00
Joe Haddad
437c35f121
feat: automatically enable webpack 5 (#22323)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-03-24 14:10:10 +01:00
Shu Ding
4c63456543
Remove visibility: inherit from the image component (#23329)
This is a follow-up PR of #19052, where `visibility: inherit` was mistakenly added back. It was removed in #23278.

## 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-03-23 22:11:37 +00:00
JJ Kasper
a16f7a3829
v10.0.10-canary.8 2021-03-23 16:35:15 -05:00
Houssein Djirdeh
e5ef60fecb
Add ESLint to Next.js (#22437)
For #22228

This PR:

- Adds ESLint to toolchain
  - Included by default for builds (`next build`)
  - Can be enabled for development (`next dev`)
  - Custom formatter built for output
- Adds appropriate tests
- Adds two documentation pages
2021-03-23 21:32:42 +00:00
Tim Neutkens
c219c1d9ce
Add polyfills for node_modules that are covered in webpack 4 to webpack 5 (#23316)
Brings back the remaining Node.js module polyfills to not break existing apps upgrading from webpack 4 to webpack 5.

Fixes #23169



## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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-03-23 20:59:42 +00:00
Bruno Crosier
48dd9954d8
Add fallback for <Image /> component when JavaScript is disabled in browser (#19052)
The current `<Image />` component does not fallback gracefully when JavaScript is disabled in the client / browser.

You can test this with the [official Next/Image example](https://csb-4k0kr-p8ya8f304.vercel.app/), by disabling JavaScript in the browser's DevTools. Video demo: https://streamable.com/frkvw9

This PR aims to fix this behaviour by using `<noscript></noscript>` tags to conditionally display a standard `<img>` element using the `props` passed to `<Image />` when JavaScript is disabled.

For browser sessions where JavaScript is enabled, this will not cause an increase in network requests, so there should be no downside.

One area where this PR is a bit "hacky" is that it uses a negative `margin-top` to counteract `sizerStyle.paddingTop`. From what I can tell, `sizerStyle.paddingTop` is generated on the server side, where we can not know ahead of time whether JavaScript is enabled in the browser - hence why I've opted for this solution. 

Fixes #19223
Fixes #21214
2021-03-23 19:25:00 +00:00
Shu Ding
c8680a344f
Remove visibility: hidden from the image component (#23278)
This PR removes the `visibility` style property change from next/image. It was previously added in #18195 to fix a bug that when no `src` is set, and that bug is not valid anymore as all images will always have `src` (and a fallback too).

It also fixes the problem that screen readers ignore elements with `visibility: hidden`.

Fixes #23201.

## Bug

- [x] Related issues #23201
- [ ] 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-03-22 19:20:52 +00:00
Tim Neutkens
fe80128915 v10.0.10-canary.7 2021-03-22 11:35:23 +01:00
Tobias Koppers
c9a2e5b8f0
upgrade webpack to 5.27.1 (#23224)
fixes #23125

fixes https://github.com/tailwindlabs/tailwindcss-jit/issues/54

## 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-03-22 09:21:51 +00:00
Tobias Koppers
8c72806ace
add separate progress output for typechecking (#23226)
## Bug

- [x] 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

Fixes #23240
2021-03-20 19:11:45 +00:00
Shu Ding
32c435d819
Experimental feature for allowing importing Typescript files outside of the root directory (#22867)
This PR attempts to provide an option to allow importing TS/TSX from outside of the current Next.js project root directory. Although this goes against the design decision that no source code should be imported from outside of root and [might bring tons of issues](https://github.com/vercel/next.js/issues/19928#issuecomment-741596557), it will still be helpful in some monorepo use cases.

This PR assumes that the external files are following the same language syntax rules and under the same tooling versions as the source code inside your project root. And it's also not allowed to enable the `baseUrl` feature in the external directory (as the project should only have 1 import base URL).

X-ref: #9474, #15569, #19928, #20374.
2021-03-19 16:43:46 +00:00
JJ Kasper
79066aee8e
v10.0.10-canary.6 2021-03-19 11:20:13 -05:00
Tim Neutkens
2874bbc61c v10.0.10-canary.5 2021-03-19 09:50:42 +01:00
Sam Ko
e71014609e
Fix invalid console.error link (#23213) 2021-03-19 09:22:19 +01:00
JJ Kasper
b6bb110aca
Ensure process exits after build completes (#23207)
This ensures we exit the build process after the build completes even if timers/connections are left open since this can cause the process to hang indefinitely. This was the previous behavior although got changed un-intentionally in e27b7e996d

This updates our production test with an open timer to ensure it doesn't block the process from completing.
2021-03-19 08:06:28 +00:00
Shu Ding
241a916e03
Improve image optimizer to only create 1 worker thread (#23188)
As stated in #23157, this PR merges all the operations into 1 worker thread (`processBuffer` in `impl.ts`) and only pass a list of operation names and args into the worker. This should improve the speed and memory usage of next/image.

Fixes #23157. X-ref: #22925.
2021-03-18 15:51:36 +00:00
Tim Neutkens
ea374d8156 v10.0.10-canary.4 2021-03-18 13:54:25 +01:00
Tobias Koppers
b267635d63
rename to NEXT_WEBPACK_LOGGING (#23186)
as vercel doesn't allow env vars starting with _
2021-03-18 12:53:41 +00:00
Tobias Koppers
60af3a125a v10.0.10-canary.3 2021-03-18 12:23:30 +01:00
Tobias Koppers
a408416299
get files from entrypoints instead of from chunks (#23174) 2021-03-18 11:14:58 +00:00
Tobias Koppers
75c62cb74c
add env var to enable advanced webpack logging and profiling (#23178)
This allows to use `__NEXT_WEBPACK_LOGGING` to enable verbose webpack logging output to investigate into performance and cache problems.

`__NEXT_WEBPACK_LOGGING=1` enables some basic logging

`__NEXT_WEBPACK_LOGGING=infrastructure` enables only infrastructure logging

`__NEXT_WEBPACK_LOGGING=profile-client` enables deep profile output of the client build

`__NEXT_WEBPACK_LOGGING=profile-server` same for the server

`__NEXT_WEBPACK_LOGGING=profile-client,infrastructure` combines multiple things
2021-03-18 09:46:07 +00:00
Tim Neutkens
7757364fc6 v10.0.10-canary.2 2021-03-17 10:13:36 +01:00
Tobias Koppers
e019ef6acc
update webpack, fix runtime location, fix undeclared variable, omit env vars from cache version (#23113)
* this will fix problems with serverless target which doesn't use a runtime chunk
* It also omit env vars from contributing to cache version as webpack will handle that now
* It moves the webpack-runtime chunk from ./chunks back to ./
2021-03-17 08:32:45 +00:00
JJ Kasper
a9da48d3da
v10.0.10-canary.1 2021-03-16 16:33:31 -05:00
Shu Ding
1bf4cf3e76
Upgrade jest-worker (#23077)
This PR upgrades `jest-worker` and `jest-cli` to the latest pre-release version, also removed `jest-circus` which is included in Jest by default. `jest-worker@next` includes a fix for memory leak that we need (https://github.com/facebook/jest/pull/11187). 

Fixes #22925. This will also improve the OOM issue for `next dev` #15855.
2021-03-16 21:08:35 +00:00
JJ Kasper
d680ba65a6
v10.0.10-canary.0 2021-03-15 19:59:56 -05:00
Shu Ding
85499b5375
Revert "Revert "[a11y] Route Announcements"" (#23086)
Reverts vercel/next.js#23082
2021-03-15 20:18:11 +00:00
JJ Kasper
ca9f808cd5
v10.0.9 2021-03-15 14:12:40 -05:00
Shu Ding
732c49cdc8
Revert "[a11y] Route Announcements" (#23082)
Reverts vercel/next.js#20428 temporarily to move this feature into the next canary release.
2021-03-15 19:09:24 +00:00
Kyle Boss
688611a582
[a11y] Route Announcements (#20428)
# Route Announcements

## Summary
This PR improves the accessibility of NextJS's client-side navigation by announcing route changes to screen readers.

## Context
When a user who is sighted clicks on a link, they can see the content change. It's an affirmation that what the user intended to do by clicking a link actually worked! Users navigating the page via a screen-reader will not get this feedback on NextJS sites (This is an issue on many SPA-like architectures).

https://user-images.githubusercontent.com/4213649/103017382-63b02b00-44f8-11eb-9940-fb530d2d3018.mov

## Solution
Whenever there is a route change, the new `<RouteAnnouncer />` will look for a name to give the new page and then announce it! The name is found by first looking for an `h1`, falling back to `document.title`, and lastly to `pathname`. `<RouteAnnouncer />` is a visually hidden component placed within the `<AppContainer />`.

## Demo
https://user-images.githubusercontent.com/4213649/103017401-6ad73900-44f8-11eb-8050-b3e9a7e0c3f2.mov

## Inspiration
First and foremost, this PR was inspired by @marcysutton's studies and writing, [What we learned from user testing of accessible client-side routing techniques with Fable Tech Labs
](https://www.gatsbyjs.com/blog/2019-07-11-user-testing-accessible-client-routing/) as well as @madalynrose's [Accessible Routing](https://github.com/gatsbyjs/gatsby/pull/19290) PR for Gatsby.

There were also learnings gleaned from the conversations within #7681.

### Related Issues & PRs
- Resolves #7681
- Relates to #19963
2021-03-15 18:36:55 +00:00
JJ Kasper
4f894a3a33
v10.0.9-canary.8 2021-03-15 13:02:13 -05:00
Lee Robinson
a63c64a02d
Update error message for next export and next/image. (#23061) 2021-03-15 13:01:12 -05:00
Lee Robinson
c4508d1d13
Update README to fix broken links. (#23058)
Also put current maintainers at the top of the list.
2021-03-15 16:36:24 +00:00
JJ Kasper
9afcdfcbc4
Ensure i18n index prefetch is correct with trailingSlash (#22746)
This fixes index data route loading for i18n with `trailingSlash: true` enabled and also fixes prerendering `asPath` values not containing a trailingSlash when enabled. 


Fixes: https://github.com/vercel/next.js/issues/17813
Fixes: https://github.com/vercel/next.js/issues/22747
2021-03-14 12:58:34 +00:00
JJ Kasper
0ec58c6328
v10.0.9-canary.7 2021-03-12 09:40:31 -06:00
JJ Kasper
7e63bd7d54
Ensure export only triggers when static pages are present (#22996)
This makes sure we don't trigger the export step if we aren't exporting any static pages during a build. This also adds an invariant to ensure we don't attempt creating a progress with 0 items.

Fixes: https://github.com/vercel/next.js/issues/22994
2021-03-12 08:36:28 +00:00
JJ Kasper
97ebc742e8
v10.0.9-canary.6 2021-03-11 13:54:57 -06:00
Dale Bustad
ffbb10fa9a
Silence trace debug messages (#22988)
These messages aren't necessary in the normal course of using Next.js.  Hiding behind a flag to reduce the noise.
2021-03-11 19:51:43 +00:00
JJ Kasper
014a2f8495
v10.0.9-canary.5 2021-03-10 15:50:50 -06:00
Dale Bustad
e27b7e996d
Telemetry-compatible tracing (#22713)
A number of changes here.  I recommend viewing the diff with the <a href="?w=1">whitespace flag enabled</a>.

- OpenTelemetry is replaced with a custom and lightweight tracing solution.
- Three trace targets are currently supported: console, Zipkin, and NextJS.
- Tracing is now governed by environment variables rather than `--require instrument.js`.
  + `TRACE_TARGET`: one of `CONSOLE`, `ZIPKIN`, or `TELEMETRY`; defaults to `TELEMETRY` if unset or invalid.
  + `TRACE_ID`: an 8-byte hex-encoded value used as the Zipkin trace ID; if not provided, this value will be randomly generated and passed down to subprocesses.

Other sundry:

- I'm missing something, probably a setup step, with the Zipkin target.  Traces are captured successfully, but you have to manually enter the Trace ID in order to view the trace - it doesn't show up in queries.
- I'm generally unhappy with [this commit](235cedcb3e).  It is... untidy to provide a telemetry object via `setGlobal`, but I don't have a ready alternative.  Is `distDir` strictly required when creating a new Telemetry object?  I didn't dig too deep here.

As noted, there are a lot of changes, so it'd be great if a reviewer could:

- [ ] pull down the branch and try to break it
- [ ] check the Zipkin traces and identify possible regressions in the functionality

Closes #22570
Fixes #22574
2021-03-10 21:00:20 +00:00
JJ Kasper
7f1800e175
v10.0.9-canary.4 2021-03-09 13:12:16 -06:00
Shu Ding
7dd99faee7
Fix next/image being downloaded multiple times on Safari (#22902)
Currently if you have `sizes` set in `next/image`, the image will likely be downloaded multiple times (usually twice) on Safari (macOS and iOS): the correct size for the viewport, and the original size specified in `src`. 

Also make sure you have "Ignore Resource Cache" disabled in the Safari Devtools when trying to reproduce:

![CleanShot 2021-03-09 at 21 05 54@2x](https://user-images.githubusercontent.com/3676859/110476820-6399f180-811d-11eb-93ec-5b2482c87884.png)

The root cause is the way Safari handles `<img>`'s attribute updates. Although React updates all the attributes one by one synchronously and programmatically, Safari will still try to fetch the resource immediately and won't wait for other DOM changes to be finished. 

That means if we set the following 3 attributes in this order: `src`, `srcSet`, `sizes`. Safari will fetch the image when `src` is set. And then once `srcSet` is there it will fetch the resource again based on it. And finally, when `sizes` is updated it might correct the resource URL again.

So the fix here is simple: by just reordering those to `sizes`, `srcSet`, `src`, it will only load the image with the correct size only once:

<img width="1498" alt="CleanShot 2021-03-09 at 21 05 30@2x" src="https://user-images.githubusercontent.com/3676859/110477852-a27c7700-811e-11eb-88dc-d6e7895f67bd.png">

Fixes #19478.
2021-03-09 19:07:01 +00:00
JJ Kasper
e84571d8e3
Add appDir field to server files manifest (#22915)
This adds an `appDir` field to the `required-server-files` manifest signifying where the app source is located. 

x-ref: https://github.com/vercel/next.js/issues/22847
2021-03-09 18:41:57 +00:00
Tim Neutkens
969ef1676d v10.0.9-canary.3 2021-03-09 13:00:58 +01:00
JJ Kasper
d951b2385f
Update /500 page exporting when _error has custom GIP (#22887)
This updates to not automatically export `/500` from `_error` if a custom `getInitialProps` is used since logic may be used inside of this method that causes the export to fail. Users can still opt-in to the static `/500` by adding a `pages/500.js` file. 

This also refactors checking `_app` for custom `getInitialProps` to outside of the static check loop to prevent a potential race condition where we could run this check multiple times un-necessarily.  

Fixes: https://github.com/vercel/next.js/issues/22815
2021-03-09 09:55:28 +00:00
JJ Kasper
38964ab09c
v10.0.9-canary.2 2021-03-08 10:58:24 -06:00
JJ Kasper
e9506773a3
Ensure env is loaded before next config (#22879)
This ensures we load all env values before loading `next.config.js` since these values can be used in there. This also updates to ensure we're testing these values are available while loading `next.config.js` so we don't regress on this. 

Fixes: https://github.com/vercel/next.js/issues/22811
2021-03-08 16:53:52 +00:00
Tim Neutkens
9e06f82af4
Upgrade webpack 5 (#22864)
Upgrades webpack 5 to the latest version.
2021-03-08 15:20:42 +00:00
Sadra Bahrami
42b3b162df
Remove extra work on cli functions (#22855)
Hi I saw you wrote extra async await code for command line function that doesn't need. I fixed that and code become very smaller and prettier.
![ts](https://user-images.githubusercontent.com/48912836/110254867-442c8880-7fa6-11eb-9f0f-3b853d5db94c.png)
2021-03-08 13:47:05 +00:00
Tim Neutkens
e7a1cb86e3 v10.0.9-canary.1 2021-03-08 11:46:03 +01:00
JJ Kasper
cdf8f9a1d0
Ensure /404 is not exported during build un-necessarily (#22825)
This ensures we don't export `/404` during the automatic static optimization during build when the `/404` isn't static and won't be used/copied to the final output. 

x-ref: https://github.com/vercel/next.js/issues/22815
2021-03-08 08:30:44 +00:00
JJ Kasper
e17398f40e
v10.0.9-canary.0 2021-03-05 13:26:54 -06:00
Shu Ding
2d207fb11d
Dedupe in-flight server data requests (#22781)
This PR adds request deduplication for `_getServerData`. If a request with the same URL is already in-flight, we don't send another new request. When a request succeeds or fails, we delete the cache.

A potential improvement this brings is, when `getServerSideProps` of a new route is slow to load, the user might keep clicking on the link which causes new requests, and the route will never update because results of old requests were ditched. Also adds a test case for this scenario.

Closes #19238.
2021-03-05 17:16:02 +00:00
Shu Ding
afc8ce4d0d
Fix idleTimeout error being thrown in route loader (#22775)
In the current implementation, `idleTimeout` will always be thrown even if it didn't time out and `Promise.race` was resolved. This causes the error `Error: Route did not complete loading` on every route transition and Chrome Devtools will pause code execution if you have "Pause on exceptions" enabled.

This PR adds `resolvePromiseWithTimeout` which does the same thing as `Promise.race` and `idleTimeout`, but it cancels the rejection when it resolves successfully, in which case the error won't be thrown.

Fixes #21543.
2021-03-05 16:32:00 +00:00
Joe Haddad
33255b7f4e
v10.0.8 2021-03-05 10:26:50 -05:00
JJ Kasper
c493791165
v10.0.8-canary.17 2021-03-04 16:23:09 -06:00
JJ Kasper
27555c8ef9
v10.0.8-canary.16 2021-03-04 16:10:20 -06:00
JJ Kasper
3417164c1d
Fix index revalidate with dynamic route in minimal mode (#22783)
This fixes the case where index page revalidation would match a dynamic page instead of the index page from the pathname not being denormalized. 

Fixes: https://github.com/vercel/next.js/issues/22750
2021-03-04 22:09:45 +00:00
Joe Haddad
2046648fa7
v10.0.8-canary.15 2021-03-03 14:53:19 -05:00
Joe Haddad
61dae380a8
chore: upgrade webpack 5 version (#22737) 2021-03-03 19:52:20 +00:00
JJ Kasper
1435de15bc
Ensure component load order (#22731)
This ensures we load `_document` then `_app` and then the page's component in all cases which matches behavior between the serverless target and the default server target.  Additional tests to ensure this order is followed has been added to prevent regression. 

Fixes: https://github.com/vercel/next.js/issues/22732
2021-03-03 19:20:48 +00:00
Tim Neutkens
5b479b609a v10.0.8-canary.14 2021-03-03 10:39:10 +01:00
JJ Kasper
b80fdfb828
Update webpack server chunks output (#22697)
This updates to output server chunks to a nested folder to prevent bundling the entire folder when tracing. This also fixes the webpack 5 tests not actually using webpack 5 since https://github.com/vercel/next.js/pull/22583 since the webpack 5 enabling check didn't account for the test environment variable used to enable webpack 5. This also clears up some deprecation warnings from webpack 5 in the mini-css-extract-plugin.

Fixes: https://github.com/vercel/next.js/issues/21297
2021-03-03 09:37:24 +00:00
JJ Kasper
ac47795d37
v10.0.8-canary.13 2021-03-02 13:55:31 -06:00
JJ Kasper
e037c22997
Ensure optional params are normalized in minimal mode (#22676) 2021-03-02 13:51:53 -06:00
Janicklas Ralph
a107dcb732
Experimental script loader changes (#22038)
Making experimental script work in _document.js - Fixes for server to client transition
Adding additional test for _document.js
2021-03-02 19:17:33 +00:00
Joe Haddad
103422ce70
v10.0.8-canary.12 2021-03-02 13:20:40 -05:00
Joe Haddad
72ce0173e1
v10.0.8-canary.11 2021-03-01 14:00:25 -05:00
Joe Haddad
7aaebee14e
v10.0.8-canary.10 2021-03-01 09:17:17 -05:00
Joe Haddad
04f37d0978
fix: load webpack hook before config is required (#22583)
This pull request ensures the webpack hook is installed before an attempt is made to load the configuration.

This pull request is tested by the PnP tests, which should now be passing as a result of this change.

---

Fixes #21679
2021-02-27 06:19:35 +00:00
Jan Potoms
1ebc9bbb5e
Load next.config.js async (#22578)
Just the conversion of config loading from sync to async from https://github.com/vercel/next.js/pull/22153

cc @Timer
2021-02-27 00:29:32 +00:00
lindsaylevine
b1a1c80e7c
bug (#21943): remove incorrect rewrite of parsedUrl.pathname in serverless handler (#22445)
Fixes https://github.com/vercel/next.js/issues/21943

i confirmed in a personal test repo that this solves the issue of infinite 307s on root level non-default locales :)  let me know what else this needs if anything! thanks for the time/help @ijjk ❤️
2021-02-25 18:43:51 +00:00
JJ Kasper
0088caa1ea
v10.0.8-canary.9 2021-02-25 09:36:47 -06:00
JJ Kasper
6d068aed4f
Fix experimental optimizeCss for SSR (#22513)
This ensures `distDir` is set under `renderOpts` in `next-server` so that it is present when experimental `optimizeCss` is enabled. 

x-ref: https://github.com/vercel/next.js/pull/16539
2021-02-25 09:56:11 +00:00
Alex Castle
a0d44ca311
Allow smaller sizes in srcset for image with fill layout and sizes prop (#21670)
Currently, the image component doesn't handle use of the `sizes` property with `layout="fill"` and `layout="responsive"` very well for small viewports. It will never include sizes smaller than the smallest viewport (640px) in the srcset, so even if you specify `sizes="30vw"` in your image, you have to download the full-viewport-width image on small devices. 

This PR adds logic such that if you use `layout="fill"` and include a `sizes` property, the image component will include the full range of image sizes in the `srcset`.

It also includes an optimization where it finds the smallest `vw` value in the sizes value and combines that with the smallest viewport width, and uses that as the floor of the srcset. It does this so it doesn't unnecessarily increase transfer size by including ALL sizes. This is still a conservative optimization--for 95% of cases, taking the _largest_ `vw` size would work, but I don't see a way to do that without breaking a few corner cases.

The case of a sizes prop with `px` values is fixed but not optimized--though generally that case is less of a good fit for the fill or responsive layout anyway.
2021-02-24 22:57:19 +00:00
JJ Kasper
b90b4b503c
v10.0.8-canary.8 2021-02-24 10:26:52 -06:00
Joe Haddad
775bdc341e
fix: correctly handle fallbacks for webpack 5 (#22497)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-02-24 10:25:57 -06:00
JJ Kasper
9d2b0fc04a
Ensure rewrites are resolved while prefetching (#22442)
This ensures we handle resolve rewrites during prefetching the same way we do during a client-transition. Previously if a rewritten source was used in an `href` neither the page bundle or SSG data if needed would be prefetched although would work correctly on a client transition. 


Fixes: https://github.com/vercel/next.js/issues/22441
2021-02-24 15:37:13 +00:00
JJ Kasper
59d467542a v10.0.8-canary.7 2021-02-23 17:12:34 -06:00
JJ Kasper
5cf16ece71
Ensure static 500 hydrates correctly with query (#22468)
Follow-up to https://github.com/vercel/next.js/pull/22139 this ensures the default 500 error page hydrates with the correct `statusCode` prop when updating query values on the client since currently it will switch the 404 `statusCode` when one isn't present. An additional test case has been added to ensure this is handled correctly.
2021-02-23 22:15:46 +00:00
Joe Haddad
f8cd075870
chore: upgrade webpack5 (#22460)
Upgrades webpack 5 and watchpack to their latest versions.
2021-02-23 16:57:23 +00:00
JJ Kasper
435eef75e2 v10.0.8-canary.6 2021-02-22 10:57:07 -06:00
JJ Kasper
51e0752f87
Add generating static 500 status page (#22139)
This adds generating a static 500 status page when a `pages/500.js` file is added similar to how we handle generating static 404 pages when `pages/404.js` is present. This allows showing a customized error page when a 500 error occurs in an optimal way.
2021-02-22 16:29:50 +00:00
Tim Neutkens
9ab98bc956
Reduce webpack watcher aggregate timing (#22418)
Reduces the time the watcher waits for events coming in before compiling.
2021-02-22 14:06:49 +00:00
Tim Neutkens
76e2bb57ad v10.0.8-canary.5 2021-02-19 11:11:15 +01:00
Tim Neutkens
3cef2e10ed
Delay server compilation until client compilation is done in development (#22187)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-02-19 11:10:19 +01:00
Joe Haddad
ef666f2e9a
v10.0.8-canary.4 2021-02-18 23:54:40 -05:00