Commit graph

8279 commits

Author SHA1 Message Date
Rishabh Poddar
f7d0bd115c
Update to with-supertokens example (#23728)
- Updated dependency version
- Optimises for serverless execution by taking advantage of `/tmp` folder (enabled via a config setting)
2021-04-06 12:45:09 +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
Rayhan Arayilakath
0d98cd9037
Fix: Codeblock Syntax Highlighting (#23545)
I don't believe NodeJS code should receive Bash syntax highlighting :).



## 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-04 01:39:54 +00:00
david
9d2962cfab
fix with-mqtt-js example. (#23636)
## Documentation / Examples

- [x] Make sure the linting passes

***

Related to #23607

We should use `NEXT_PUBLIC_`  as [stated here](https://nextjs.org/docs/basic-features/environment-variables) to expose environment variables to the browser.

The code was already using the correct variables name.
2021-04-02 16:33:30 +00:00
david
6b2a2d9bc5
fix with-styled-jsx-plugins example. (#23635)
## Documentation / Examples

- [x] Make sure the linting passes

***

Related to #23607

Bump packages fixed the example and worked fine on macOS.
2021-04-02 16:28:34 +00:00
david
c46e99d346
fix with-web-worker example. (#23634)
## Documentation / Examples

- [x] Make sure the linting passes

***

Related to #23607

Instead of using a third-party loader `worker-plugin`, we leverage the use of `webpack 5` built-in worker support.

https://nextjs.org/docs/messages/webpack5
https://webpack.js.org/guides/web-workers/
2021-04-02 16:20:45 +00:00
rpxs
be0957650d
fixes a part of #23607 remove with-glamor example (#23639)
## 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

The `with-glamor` package has been unmaintained for 4 years now.
2021-04-02 13:38:58 +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
Sam Robbins
4de984ca23
Update router.md to improve a11y (#23611)
Code examples used `span`, change to use `button` for better accessibility 

## Documentation / Examples

- [x] Make sure the linting passes
2021-04-01 18:26:19 +00:00
JJ Kasper
bfd36bd227
Update custom-routes-proxying to use fallback rewrites (#23610)
This updates to use the new `fallback` rewrites support instead of the previous no-op rewrite workaround. 


## Documentation / Examples

- [x] Make sure the linting passes
2021-04-01 16:48:49 +00:00
Sam Robbins
ba81b6ab2a
Delete examples/with-style-sheet directory (#23609)
The underlying package [style-sheet](https://github.com/giuseppeg/style-sheet) has been archived, and the example doesn't currently work, so I think it's better deleted. Closes part of issue #23607 


## Documentation / Examples

- [x] Make sure the linting passes
2021-04-01 16:33:30 +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
Justin Bennett
68fc4deaef
Remove redundant prefresh dependency in with-preact example (#23567)
The package `next-plugin-preact` [already contains](38cfb182dd/packages/next-plugin-preact/package.json (L25)) the dependency `@prefresh/next` so it shouldn't be explicitly installed.

## Documentation / Examples

- [x] Make sure the linting passes
2021-03-31 14:03:39 +00: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
Lee Robinson
d4d611119e
Fix YAML parsing issue in ESLint docs. (#23511) 2021-03-29 17:59:51 +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
92e14f8d60
Update webpack5.md 2021-03-29 15:22:05 +02:00
Tim Neutkens
7da0f9c4cf
Update manifest.json 2021-03-29 15:16:10 +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
Lee Robinson
d49f978a17
Update with-docker example and deployment docs. (#23486)
## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [x] Make sure the linting passes
2021-03-28 20:32:09 +00:00
Scott MacDonnell
5fde82a556
Add links to dependencies in with-three-js example README (#23470)
## 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

- [x] Make sure the linting passes
2021-03-28 15:23:30 +00:00
Jiachi Liu
737c25edd8
doc: fix ActiveLink detection condition (#23472)
## Documentation / Examples

- [x] Make sure the linting passes


`router.pathname` can be dynamic routes like `/posts/[slug]`, use `router.asPath` instead to detect anchor is active
2021-03-28 14:17:50 +00:00
Steven
9973b8cb9f
[examples] Fix image-component typo (#23437)
## Documentation / Examples

- [x] Make sure the linting passes
2021-03-26 21:57:21 +00:00
Turadg Aleahmad
4e5a359ae5
update with-linaria example (#23332)
## Documentation / Examples

* removes deprecated `@zeit/next-css`.
* adds https://github.com/Mistereo/next-linaria to work with the new built-in CSS functionality.
* updates Linaria to latest release (v3 will require https://github.com/Mistereo/next-linaria/pull/3 ) 
* adds an example of using Linaria without React
* gitignores `.linaria-cache`
2021-03-26 18:02:55 +00:00
JJ Kasper
f28ea89aa7
v10.0.10-canary.12 2021-03-26 11:02:54 -05:00
Lee Robinson
5ac8951ed9
Update babel docs to mention you can use babel.config.js. (#23434)
## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [x] Make sure the linting passes
2021-03-26 16:01:22 +00:00