Commit graph

3401 commits

Author SHA1 Message Date
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
JJ Kasper
9793e9004f
Add isPreview field to router (#21638)
This adds an `isPreview` field to the `next/router` to allow detecting when in preview mode. 

Closes: https://github.com/vercel/next.js/issues/14903
2021-02-18 18:34:33 +00:00
JJ Kasper
12cd2f9f11 v10.0.8-canary.3 2021-02-18 10:38:42 -06:00
Joe Haddad
4335237aad
v10.0.8-canary.2 2021-02-18 10:03:36 -05:00
Joe Haddad
99a4ea6e9a
feat(next/image): remove sharp for wasm variant (#22253)
This pull request removes the native `sharp` dependency (which doesn't work on some Linux variants, nor **M1 Mac**) and replaces it with a wasm equivalent.

It also reduces Next.js' installed size by 27.3 MB.

The code is adapted from the [Squoosh CLI](https://github.com/GoogleChromeLabs/squoosh).

This PR still supports:

- Rotation normalization
- Resizing
- PNG
- JPEG
- Webp

However, it (temporarily) removes support for:
- Resizing Gifs
- Resizing Tiff

(these formats still get served and rendered correctly by the image component)

---

Fixes #20456
Closes #20738
Closes #21762
2021-02-18 10:23:24 +00:00
JJ Kasper
62803a9d40 v10.0.8-canary.1 2021-02-17 17:08:28 -06:00
Janicklas Ralph
cf6bc446ea
Experimental feature - fix optimizeCss flag for serverless deployments (#21790) 2021-02-17 22:52:43 +00:00
Tim Neutkens
c64005ffd5 v10.0.8-canary.0 2021-02-16 09:57:24 +01:00
Kristoffer K
89edd34ff8
fix: register webpack hook earlier and use absolute paths (#21877) 2021-02-16 09:51:52 +01:00
Joe Haddad
80c9522750
v10.0.7 2021-02-15 15:39:02 -05:00
Tim Neutkens
57ed93bc5e v10.0.7-canary.8 2021-02-12 14:25:43 +01:00
matamatanot
b3aa1d14ff
Upgrade to lerna 4 (#22039)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-02-12 13:34:25 +01:00
Tim Neutkens
83657b6bce
Check if parentspan is provided in profiler (#22061)
Co-authored-by: Dale Bustad <dale@divmain.com>
2021-02-12 11:17:38 +01:00
Joe Haddad
5f41abda9a
fix(link): cancel idle callback on unmount (#22072)
Co-authored-by: mAAdhaTTah <jamesorodig@gmail.com>
2021-02-11 13:51:41 -05:00
JJ Kasper
27b6dd6b02 v10.0.7-canary.7 2021-02-11 09:41:58 -06:00
JJ Kasper
55e4a3d1ad
Only create locale domain links if on locale domain (#22032)
This updates to only create locale domain links if the current hostname is a locale domain to prevent making links unvisitable in development and preview environments where the configured locale domains don't point to the current build. 

Closes: https://github.com/vercel/next.js/issues/21211
Closes: https://github.com/vercel/next.js/issues/22011
2021-02-11 10:18:24 +00:00
JJ Kasper
5febe218a6
Add nccing AMP optimizer (#21980)
This adds ncc'ing the AMP optimizer package to speed up install times and cache the runtime. 

Closes: https://github.com/vercel/next.js/issues/20404
2021-02-11 09:55:56 +00:00
JJ Kasper
3f94f33ba2
Ensure error is passed up in minimal mode (#22030)
This ensures we pass the error up to the top-level when in minimal mode
2021-02-11 09:31:49 +00:00
Tim Neutkens
6b99bda3e3
Fix profiling plugin for next build (#21989)
Makes sure `yarn trace build` works.
2021-02-09 23:21:38 +00:00
Tim Neutkens
6369981754 v10.0.7-canary.6 2021-02-07 20:07:22 +01:00
Tim Neutkens
44fa86e384
Make sure all modules are included in the stats file (#21942) 2021-02-07 20:06:41 +01:00
Tim Neutkens
8b44bccd88 v10.0.7-canary.5 2021-02-05 17:41:49 +01:00
Tim Neutkens
6387f368dc
Update reasons array to use module id instead of identifier (#21895)
Missed this then changing the modules array to rely on `module.id`
2021-02-05 16:39:46 +00:00
Joe Haddad
b678d68705
v10.0.7-canary.4 2021-02-04 14:23:23 -05:00
Tim Neutkens
15d02f6559
Make experimental stats file approximately 90% smaller (#21858)
Tested against some smaller apps. Will have a high impact for larger apps.
2021-02-04 19:21:54 +00:00
Guy Bedford
234e1c9601
feat: Implement webpack require hook (#21802)
This implements the compatibility require hook as per https://github.com/vercel/next.js/issues/21789.

The hook is applied at the point of webpack initialization. In addition the separate packages are exposed for the various webpack subrequires.

The test then ensures instance equality for the basic require hook from the next.js config file.

I suspect this might have bad interactions with Yarn Pnp support, but maybe we will be lucky.
2021-02-04 08:49:42 +00:00
Joe Haddad
5fff814ca1
v10.0.7-canary.3 2021-02-03 15:46:57 -05:00
JJ Kasper
6d80e6e5f3
Add version for stats (#21823)
Adds versioning for the stats output
2021-02-03 20:46:35 +00:00
Tim Neutkens
379ad1b302
Rename package build scripts to dev (#21743)
The top-level script has always been `dev` so this makes the package scripts consistent
2021-02-03 17:02:44 +00:00
Guy Bedford
a6c1f9cfe7
Add webpack type to ncc bundle (#21785)
This adds a simple typing definition to the Webpack ncc output.

Fixes https://github.com/vercel/next.js/issues/21390.
2021-02-03 16:39:59 +00:00
JJ Kasper
41b7c524fa v10.0.7-canary.2 2021-02-02 15:52:34 -06:00
JJ Kasper
a65f8c3e0e
Update stats flag default (#21791) 2021-02-02 21:38:50 +00:00
Tim Neutkens
2079b74431 v10.0.7-canary.1 2021-02-02 17:15:24 +01:00
JJ Kasper
523537178c
Add stats config option (#21761)
This adds a config to output webpack's stats
2021-02-02 15:39:39 +00:00
Tim Neutkens
36aeca8f04 v10.0.7-canary.0 2021-02-01 12:56:04 +01:00
Guy Bedford
d5a4dec042
fix: add declarations for compiled webpack and loader (#21741)
This should resolve the typing issues described in https://github.com/vercel/next.js/issues/21390 from the webpack inlining, by declaring `next/dist/compiled/webpack` in the main typing file as a source.
2021-02-01 11:27:41 +00:00
Rafael Bonalume Lebre
60e699555d
Fix #top anchor link scroll (#16638)
According to [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-href) the page must scroll to the top with both "#" and "#top" anchors.

<img width="675" alt="Screen Shot 2020-08-27 at 7 20 19 PM" src="https://user-images.githubusercontent.com/13899924/91500693-582a5b80-e89a-11ea-803f-4592d458baba.png">
2021-01-30 04:32:00 +00:00
Joe Haddad
5201cdbaea
v10.0.6 2021-01-29 15:21:46 -05:00
Joe Haddad
f8f2a173e3
v10.0.6-canary.12 2021-01-29 14:45:49 -05:00
Joe Haddad
558289247e
v10.0.6-canary.11 2021-01-29 11:36:36 -05:00
Janicklas Ralph
8f21c283b2
Experimental feature changes (#21646)
Adding test for experimental-serverless-trace + fix for the same
2021-01-29 13:53:07 +00:00
Tim Neutkens
08846cf8b5 v10.0.6-canary.10 2021-01-29 12:10:06 +01:00
Dale Bustad
652a1e8915
Improvements to webpack tracing, including hot-reload (#21652)
@timneutkens I think this is ready for a review.

I've made some changes to the original design that _seem_ to have paid off.  The parenting relationships for traces of normal builds are applied more uniformly, resulting in more intelligible traces:

<img width="900" alt="Screen Shot 2021-01-29 at 12 53 47 AM" src="https://user-images.githubusercontent.com/5016978/106253732-ba321880-61cc-11eb-98fd-d45af5078273.png">

Hot-reloading is surfaced now, too.  I will note, however, that we will want to dig in deeper and find out where the large portion of time at the beginning of hot-reload is spent.  Example:

<img width="894" alt="Screen Shot 2021-01-29 at 12 53 28 AM" src="https://user-images.githubusercontent.com/5016978/106253828-e057b880-61cc-11eb-967d-46eaff31ecef.png">

Where did those 180 ms go?  At the least, we can now track how long a hot-reload takes, and have a place to start with further investigation.
2021-01-29 10:32:26 +00:00
Lee Robinson
5a73859fe8
Update docs and Create Next App to use API Middlewares by default. (#21639) 2021-01-28 23:34:03 +00:00
JJ Kasper
e75f6119d8 v10.0.6-canary.9 2021-01-27 10:49:12 -06:00
JJ Kasper
87ed37d51c
Ensure prerender-manifest contains all i18n revalidate values (#21404)
This insures we add entries for each locale version of a non-dynamic SSG page since they can have unique revalidate values. This requires a version bump in the `prerender-manifest` since the static routes now contain additional values which need to be handled separately. 

Fixes: https://github.com/vercel/next.js/issues/21568
2021-01-27 11:24:00 +00:00
Joe Haddad
b785fbc5d1
chore: upgrade webpack5 (#21563) 2021-01-26 21:05:58 +00:00
Jaon
e1fe28c849
Fix and add test filterModuleRules for next-plugin-storybook (#17306)
I tried the preset provided at `packages/next-plugin-storybook` but it was raising error due to an [unsafe negation](https://eslint.org/docs/rules/no-unsafe-negation) in the `preset.js` file.

I added a test to show the error:
```
● next-plugin-storybook filterModuleRules › should filter module rules correctly

    TypeError: rule.test.test is not a function

      48 |       if (!rule.test instanceof RegExp) return true
      49 |       // use Next.js' built-in CSS
    > 50 |       if (rule.test.test('hello.css')) {
         |                     ^
      51 |         return false
      52 |       }
      53 |       // use next-babel-loader instead of storybook's babel-loader

      at filter (../packages/next-plugin-storybook/preset.js:50:21)
          at Array.filter (<anonymous>)
      at Object.filterModuleRules (../packages/next-plugin-storybook/preset.js:46:28)
      at Object.<anonymous> (unit/webpack-config-overrides.test.js:12:36)
```
2021-01-26 19:28:41 +00:00
Janicklas Ralph
dc2de37014
Font optimization - Pass nonce to inlined font definition (#21346) 2021-01-26 18:32:39 +00:00
Roko Bekavac
004ad62d6b
Allow undefined body sent to sendData() (#20981)
Co-authored-by: rokobekavac0 <roko.beakavac2003@gmail.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2021-01-26 10:24:48 -05:00
Andre Hsu
a47d47e07a
Change type of GetServerSidePropsContext.req.cookies the be the same as NextApiRequest.cookies (#21336)
The original type for `GetServerSidePropsContext.req.cookies` was introduced in #19724. In the PR, the test at `test/integration/typescript/test/index.test.js` expects req.cookies to always exist, so `req.cookies` will never be undefined.

I'm guessing that req.cookies is parsed using the same cookie middleware as `NextApiRequest`, in which case `req.cookies` should be `{ [key: string]: string }`, not `{ [key: string]: any }`.
2021-01-26 14:26:59 +00:00
Chulki Lee
f6cc0dedaa
Remove mkdirp (#21365)
Closes #17042

I removed mkdirp from package.json taskfil.js, and ran `yarn && ./check-pre-compiled.sh `. Please let me know if anything else is needed!

(Extracted from #20411)

Note that now compiled webpack has mkdirP function
2021-01-26 14:02:16 +00:00
youngvform
3368fdde48
Fix to parse REACT_EDITOR in env (#21331)
I made an issue #[21330](https://github.com/vercel/next.js/issues/21330).

I think this line 0bd175264b/packages/react-dev-overlay/src/internal/helpers/launchEditor.ts (L216) return string array and toLowerCase is undefined in string array so throw error.

I fixed it by referring to [launchEditor](7e4949a20f/packages/react-dev-utils/launchEditor.js) of create react app.
2021-01-26 12:08:06 +00:00
tarunama
b40fd6ce25
refactor: add types to name-default-components.ts (#21291)
- Add.type to variables and function, arguments
2021-01-26 11:43:52 +00:00
tarunama
c110e45b62
refactor: server/api-utils.ts (#21148)
- Add return type to function
- Add [isNotValidData](https://github.com/vercel/next.js/pull/21148/files#diff-64466461287cc1a70ce5597e3e1d18ac22755f9aeb7ff1865160a8c057540983R374) function for readability
2021-01-26 09:52:00 +00:00
kaykdm
47cb4cf850
Fix aspath for getInitialProps (#20572)
Fixes: https://github.com/vercel/next.js/issues/20370

> AsPath is incorrect on Server if you use rewrites and getInitialProps. On the server, asPath is the rewritten asPath while on the client asPath ist as given in the request URL.

The same issue was used to happen on `getServersideProps`, but it was fixed in this PR (https://github.com/vercel/next.js/pull/17121).
`getInitialProps` needs same fix except when the target is serverless, which has correct `asPath` value.

Additional tests have been added in the `getInitialProps` suite to ensure correct asPath with rewrites.
2021-01-25 18:26:32 +00:00
Joe Haddad
88b6ea416d
v10.0.6-canary.8 2021-01-25 12:59:39 -05:00
Janicklas Ralph
cf95146a51
Critical css fix (#21462)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2021-01-25 12:43:05 -05:00
Ryan
8798c40c96
Require only build directory to be writeable for build (#20977)
Allows building without permission to write to the application directory, useful for containers and sandboxes.
2021-01-25 12:09:22 -05:00
Joe Haddad
75c504708b
fix: upgrade pinned deps for tests (#21515) 2021-01-25 12:08:08 -05:00
Chulki Lee
fc34f89a80
Fix hostname message in dev/start (#20409) 2021-01-25 16:13:12 +01:00
Calmon Ribeiro
783b9d86ff
fix(next): respect extends in tsconfig with exclude and include (#16619) 2021-01-24 14:24:36 +01:00
kaykdm
a5b0094677
Fix shallow routing scroll (#21437)
This ensures that Next.js will not scroll to the top of the page in shallow routing.

Fixes: https://github.com/vercel/next.js/issues/21386
Fixes: https://github.com/vercel/next.js/issues/21366
2021-01-22 18:03:29 +00:00
Joe Haddad
74b6389bd6
ci: fix webpack 5 enabling for tests (#21436)
* ci: fix webpack 5 enabling for tests

* refactor: move default location

* Disable incompatible suite
2021-01-22 11:20:53 -06:00
Tim Neutkens
4dc32ec0a7 v10.0.6-canary.7 2021-01-22 09:56:40 +01:00
JJ Kasper
5b70802f61
Preserve asPath while resolving rewrites (#21410)
* Preserve asPath while resolving rewrites

* remove un-needed alias

* Add new alias

* Add return type for resolve rewrites
2021-01-21 17:40:23 -06:00
Joe Haddad
a1b8fb49e6
v10.0.6-canary.6 2021-01-20 00:48:30 -05:00
Joe Haddad
47ec677127
chore: compile css-loader (#21357)
This PR compiles `css-loader` to resolve a peer dep warning.
2021-01-20 05:47:25 +00:00
Joe Haddad
55b8502dd0
chore: compile style-loader dep (#21355)
This PR compiles `style-loader` to resolve a peer dep warning.

---

Closes #21359
2021-01-20 05:25:46 +00:00
Joe Haddad
0d0db45c72
v10.0.6-canary.5 2021-01-19 15:11:46 -05:00
Joe Haddad
ab158c0aee
chore: compile resolve-url-loader (#21351)
Closes #21166
2021-01-19 20:08:24 +00:00
Tim Neutkens
56b149f7be
Add experimental per-page option to disable JS preloads (#21329)
As discussed with @csswizardry. This is a temporary option in case you know the preloads are not needed. It will likely be a default once the ScriptLoader work from @janicklas-ralph has been proven in partner apps and landed.

```js
// pages/index.js
export const config = {
  unstable_JsPreload: false
}
```
2021-01-19 19:38:15 +00:00
Tobias Koppers
11900431fa
upgrade webpack 5 for empty entrypoint fix (#21353)
fixes a problem where entrypoints are nearly empty.
2021-01-19 19:15:45 +00:00
Bernd Artmüller
72ce099106
Fix splitting page path by buildId (#19901)
Running next.js in `development` causes issues when having pages named "development" or "developments",... as `this.buildId` = `development`

Fixes: https://github.com/vercel/next.js/issues/19520
2021-01-19 18:27:28 +00:00
Joe Haddad
d33aad7815
chore: upgrade chokidar to fix install warning (#21343)
To resolve:
```
warning next > chokidar > fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
```
2021-01-19 17:02:32 +00:00
Tim Neutkens
85624d6164 Remove console.log 2021-01-19 09:44:03 +01:00
Tim Neutkens
f8fecf57c3
Fix webpack 5 warning + disabling of profiling (#21276)
Noticed that there was a specific warning when using webpack 5.
2021-01-18 16:38:00 +00:00
Tim Neutkens
c5b5c43e3d
Add codemod for files that do not support the new React JSX transform (#21281)
Previously our automatic React injection approach injected `import React from 'react'` automatically whenever JSX was detected. The new official JSX transform solves this by enforcing importing `React` when it is used.

This codemod automatically converted files that are using a "global React variable" to use `import React from 'react'`
2021-01-18 15:17:10 +00:00
Tim Neutkens
f534a5cad2 v10.0.6-canary.4 2021-01-17 20:13:41 +01:00
Tobias Koppers
b02df3f487
improve splitChunks config for webpack 5 (#21208) 2021-01-17 20:05:47 +01:00
Tobias Koppers
9c4d368459
use webpack resolve api to resolve in externals config (#21205) 2021-01-17 20:02:20 +01:00
JJ Kasper
cfa9326c63
Minimal mode normalizing (#21083)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-01-16 16:46:21 +01:00
kaykdm
cdab7bf831
fix hydration mismatch on href for url with anchor refs (#21065)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-01-15 17:53:10 +01:00
Joe Haddad
ceef1566c3
v10.0.6-canary.3 2021-01-15 11:49:31 -05:00
Joe Haddad
54bee4fb4d
fix: resolve two peer dep install warnings (#21176)
This removes the peer dep on `webpack` from `react-dev-overlay`, as it is for types only.

This makes the peer dep on `webpack` optional for `react-refresh-utils`, as you can provide webpack via the constructor (how Next.js does).
2021-01-15 16:39:49 +00:00
Joe Haddad
dd2218adc9
v10.0.6-canary.2 2021-01-15 01:32:14 -05:00
Gerald Monaco
cd5ea7db1f
Bump minimum suggested React version (#21046)
* Upgrade React version warning

* Fix font/stylesheet plugin

* Fix size-limit tests

* Fix build-output test

* Add tests for React 16

* Fix react-dom version
2021-01-14 22:29:57 -05:00
Guy Bedford
005a8abe39
feat: Webpack loader inlining (#21127)
This picks up on the inlining work in https://github.com/vercel/next.js/pull/20598 to also include webpack loader inlining optimizations.

This includes:
* The dependencies of sass-loader
* resolve-url-loader

And for added benefit:
* babel-plugin-transform-define
* babel-plugin-transform-react-remove-prop-types

style-loader and css-loader didn't inline easily. Perhaps we can come back to these ones.
2021-01-15 01:51:45 +00:00
Joe Haddad
60a896f833
v10.0.6-canary.1 2021-01-14 10:18:03 -05:00
Ramiro Silveyra d'Avila
d72b2d6e36
fix: webpack 5 and worker-loader support (#21050)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2021-01-14 01:48:49 -05:00