Commit graph

2700 commits

Author SHA1 Message Date
Joe Haddad
47b7e0b318
v9.5.4-canary.21 2020-09-24 02:17:53 -04:00
Joe Haddad
c351f6154b
Improve server performance by skipping decode/re-encode (#17323)
Prior to this pull request, Next.js would immediately decode all URLs sent to its server (via `path-match`).

This was rarely needed, and Next.js would typically re-encode the incoming request right away (see all the `encodeURIComponent`s removed in PR diff). This adds unnecessary performance overhead.

Long term, this will also help prevent weird encoding edge-cases like #10004, #10022, #11371, et al.

---

No new tests are necessary for this change because we've extensively tested these edge cases with existing tests.
One test was updated to reflect that we skip decoding in a 404 scenario.

Let's see if all the existing tests pass!
2020-09-24 06:05:40 +00:00
Yuji Sugiura
4adf48b6cc
Fix export-cli progress label default value (#17106)
This PR fixes `info  - undefined (N/N)` log for `export` cli.

![image](https://user-images.githubusercontent.com/6259812/93186247-5d801500-f779-11ea-89ec-e20939d7b7c1.png)

Default parameter `label` for `createProgress()` was always ignored by `${Log.prefixes.info} undefined` 😅 .
2020-09-21 16:09:14 +00:00
Joe Haddad
63fee0f30c
v9.5.4-canary.20 2020-09-15 15:32:27 -04:00
JJ Kasper
2cf1d1c191
Separate resolved asPath from resolved URL for GSSP (#17121)
This makes sure we have the correct `asPath` value to prevent breaking hydration for `getServerSideProps` pages and doesn't re-use the `resolvedUrl` value for the `asPath` and instead creates a separate `resolvedAsPath` value that only removes the `_next/data` prefix from the path. Additional tests have been added in the `getServerSideProps` suite to ensure correct `asPath` with rewrites. 

Fixes: https://github.com/vercel/next.js/issues/17113
2020-09-15 19:19:07 +00:00
Joe Haddad
6a4c256491
v9.5.4-canary.19 2020-09-14 23:37:08 -04:00
JJ Kasper
a4c97c5c4a
Update webpack 5 resolving (#17095)
On the latest beta of webpack 5 resolving fails with the below error and according to https://github.com/webpack/webpack/issues/11467 is due to the imports in this module not being fully specified. This adds the config mentioned in the thread to correct the resolving for this module. 

```sh
Failed to compile.
--
16:33:50.046 | ModuleNotFoundError: Module not found: Error: Can't resolve './assertThisInitialized' in '/vercel/f03cc85/node_modules/@babel/runtime/helpers/esm'
16:33:50.046 | > Build error occurred
16:33:50.047 | Error: > Build failed because of webpack errors
16:33:50.047 | at build (/vercel/f03cc85/node_modules/next/dist/build/index.js:15:918)
16:33:50.099 | error Command failed with exit code 1.
```
2020-09-15 03:27:43 +00:00
Joe Haddad
0c1ebb4d3a
v9.5.4-canary.18 2020-09-14 21:04:10 -04:00
JJ Kasper
62cbbf525c
Fix API page check during SSG page collecting (#17092)
Fixes SSG pages that start with `/api` not being detected as SSG pages. This also adds tests to ensure this is working correctly in the `prerender` suite.

x-ref: https://github.com/vercel/next.js/issues/17091
2020-09-15 01:03:43 +00:00
JJ Kasper
d3f4a4cb2a
Provide resolvedUrl to getServerSideProps (#17082)
This continues off of https://github.com/vercel/next.js/pull/17081 and provides this normalized `asPath` value in the context provided to `getServerSideProps` to provide the consistent value since the request URL can vary between direct visit and client transition and the alternative requires building the URL each time manually. 

Kept this change separate from https://github.com/vercel/next.js/pull/17081 since this is addressing a separate issue and allows discussion separately. 

Closes: https://github.com/vercel/next.js/issues/16407
2020-09-14 21:01:04 +00:00
JJ Kasper
71a0181572
v9.5.4-canary.17 2020-09-14 14:47:53 -05:00
Joe Haddad
49a59b1ad2
Polyfill missing std lib fns for module browsers (#17083) 2020-09-14 15:25:30 -04:00
JJ Kasper
7203f50091
v9.5.4-canary.16 2020-09-14 12:15:33 -05:00
JJ Kasper
94a5bd6109
Normalize asPath for GS(S)P pages (#17081)
This normalizes the `asPath` for `getServerSideProps` and `getStaticProps` pages to ensure it matches the value that would show on the client instead of a) the output pathname when revalidating or generating a fallback or b) the `_next/data` URL on client transition. 

Fixes: https://github.com/vercel/next.js/issues/16542
2020-09-14 16:48:04 +00:00
Jens Meindertsma
80000f4238
[Fix] webpack@5.0.0-beta.30: Invalid configuration (#17045)
Earlier today #17038 was merged which I opened to fix a problem when using `webpack@5.0.0-beta.30` with Next.js using the new Webpack 5 support. In that PR, the only change was the renaming of a configuration key. I later discovered that the change on the Webpack side was different than I initially thought, and this meant that the fix I submittted to Next.js didn't work.

This PR intends to fix the remaining problems. Webpack 5 now accepts a `environment` key that can be used to configure the target output. Previously, this was known as `ecmaVersion` and accepted a number. Now, `environment` accepts a configuration object with individual options. I've configured this in such a way where it resembles an ES5 environment:
```js
environment: {
   arrowFunction: false,
   bigIntLiteral: false,
   const: false,
   destructuring: false,
   dynamicImport: false,
   forOf: false,
   module: false,
}
```
2020-09-14 13:21:17 +00:00
Joe Haddad
1d30f2179f
v9.5.4-canary.15 2020-09-13 23:39:22 -04:00
Bogdan Chadkin
9959d7ef32
Use babel 7 jsx syntax (#17043)
For some reason babel-plugin-syntax-jsx of babel 6 was used instead of
babel 7 version.
2020-09-13 13:29:23 +00:00
Joe Haddad
9b22dc4660
Improve custom document error message (#17048) 2020-09-12 18:57:07 +00:00
Tim Neutkens
d113c640b3 v9.5.4-canary.14 2020-09-12 16:16:28 +02:00
Jens Meindertsma
4af5032e77
Fix Webpack 5 configuration for v5.0.0-beta.30 (#17038)
This PR fixes #17035. As described in the issue, there was a breaking change in `webpack@5.0.0-beta.30`: `output.ecmaVersion` was replaced by `output.environment`. This meant Next.js apps using this `webpack` version would break. This PR updates the relevant Webpack config.

I think this will break any apps that are still using `webpack@5.0.0-beta.29`, but I don't know whether that is a problem as this is a beta feature. If it is, I'd love it if someone could let me know how to detect beta versions in the code so I can make it backwards-compatible.
2020-09-12 13:23:55 +00:00
Joe Haddad
4c3631402f
v9.5.4-canary.13 2020-09-12 02:37:04 -04:00
Markus Lautenbach
76e86e0fba
Remove false positive in circular structure detection (#16380)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-09-12 02:36:29 -04:00
Ole-Martin Bratteng
5f36f4699c
Upgrade web-vitals (#17028)
ref https://github.com/GoogleChrome/web-vitals/pull/68

won't fail the new [`no-unload-listeners`](https://github.com/GoogleChrome/lighthouse/pull/11085) Lighthouse audit.
2020-09-12 04:04:33 +00:00
Joe Haddad
310863e86f
v9.5.4-canary.12 2020-09-11 14:27:49 -04:00
Bogdan Chadkin
f786ccdbb9
Upgrade cacache of terser-webpack-plugin (#17022)
Ref https://github.com/webpack-contrib/terser-webpack-plugin/blob/v4.1.0/package.json#L44

cacache is a dependency of terser-webpack-plugin. The latest version
depends on cacache 15 while next adds cacache 13. This may give
unexpected results. Better keep it in sync with terser plugin.
2020-09-11 16:19:54 +00:00
Bogdan Chadkin
ddf9ed3b62
Prefer builtin optional chaining and nullish coalescing (#16780)
Babel-preset-env includes includes optional chaining and
nullish-coalescing since [7.8.0](https://github.com/babel/babel/releases/tag/v7.8.0).

In this diff I removed these plugins from next preset to prevent
dependency duplication when their newer versions are out.
2020-09-11 15:20:10 +00:00
Bogdan Chadkin
e5f9fbbcdf
Upgrade sass loader (#16970)
The new version replaced big clone-deep package with dependency-free klona
- https://github.com/webpack-contrib/sass-loader/releases/tag/v10.0.0
- https://github.com/webpack-contrib/sass-loader/releases/tag/v9.0.0

Also deduped some related transitives.
2020-09-11 12:36:48 +00:00
Sakito Mukai
7efa3babb7
Security upgrade node-fetch (#17009)
There was a security update for node-fetch.

> This is an important security release. It is strongly recommended to update as soon as possible.
https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md#v261
2020-09-11 09:01:48 +00:00
Joe Haddad
a7a6187193
v9.5.4-canary.11 2020-09-10 16:06:51 -04:00
JJ Kasper
47d983f71f
Add error when href interpolation fails (#16946)
This adds an error when interpolation fails to make sure invalid `href`s aren't accidentally used and an invalid URL is built. 

Closes: https://github.com/vercel/next.js/issues/16944
2020-09-10 20:05:02 +00:00
Joe Haddad
c12afa066e
v9.5.4-canary.10 2020-09-10 13:50:52 -04:00
Joe Haddad
1ea6745106
Importing CSS from Third Party React Components (#16993) 2020-09-10 13:45:30 -04:00
Jan Potoms
5aed1d2e35
Correct query behavior for falsey values to pre 9.5.1 behavior (#16608)
Fixes https://github.com/vercel/next.js/issues/16147
2020-09-10 15:12:37 +00:00
Joe Haddad
ca986abd95
v9.5.4-canary.9 2020-09-10 00:05:18 -04:00
JJ Kasper
dcdcf49a87
Fix resolving href with a rewrite (#16975)
This makes sure we properly resolve a rewrite when only the `href` value is used. This was causing a full-reload and was missed in the existing test since we weren't making sure a full navigation didn't occur which has been added in this PR. 

Fixes: https://github.com/vercel/next.js/issues/16974
2020-09-10 00:55:22 +00:00
Joe Haddad
72b78f3be3
v9.5.4-canary.8 2020-09-09 19:44:04 -04:00
Joe Haddad
25cdaab297
Add Support for CSS Module Value Imports (#16973)
Fixes #10142
Fixes #11629
2020-09-09 23:29:37 +00:00
Joe Haddad
fceb566baf
v9.5.4-canary.7 2020-09-08 22:02:48 -04:00
Gerald Monaco
039eb817e1
Remove next-head-count (#16758)
Removes `next-head-count`, improving support for 3rd party libraries that insert or append new elements to `<head>`.

---

This is more or less what a solution with a `data-` attribute would look like, except that instead of directly searching for elements with that attribute, we serialize the elements expected in `<head>` and then find them/assume ownership of them during initialization (in a manner similar to React's reconciliation) based on their properties.

There are two main assumptions here:
1. Content is served with compression, so duplicate serialization of e.g. inline script or style tags doesn't have a meaningful impact. Storing a hash would be a potential optimization.
2. 3rd party libraries primarily only insert new, unique elements to head. Libraries trying to actively manage elements that overlap with those that Next.js claims ownership of will still be unsupported.

The reason for this roundabout approach is that I'd really like to avoid `data-` if possible, for maximum compatibility. Implicitly adding an attribute could be a breaking change for some class of tools or crawlers and makes it otherwise impossible to insert raw HTML into `<head>`. Adding an unexpected attribute is why the original `class="next-head"` approach was problematic in the first place!

That said, while I don't expect this to be more problematic than `next-head-count` (anything that would break in this new model also should have broken in the old model), if that does end up being the case, it might make sense to just bite the bullet.

Fixes #11012
Closes #16707

---

cc @Timer @timneutkens
2020-09-09 01:41:04 +00:00
JJ Kasper
f46ddc6933
Correct page path for GS(S)P data refreshing (#16939)
This makes sure to the page path is the expected version to trigger refreshing on the client and adds additional tests to make sure it is working properly with these page variants. 

Closes: https://github.com/vercel/next.js/issues/16938
2020-09-08 16:00:05 +00:00
Tim Neutkens
ac0c892acc v9.5.4-canary.6 2020-09-08 11:07:29 +02:00
JJ Kasper
bc80fb4fb2
Add handling for redirects from getStaticProps/getServerSideProps (#16642)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-09-08 09:23:21 +02:00
Tim Neutkens
4c5c7cd2da v9.5.4-canary.5 2020-09-07 14:11:50 +02:00
JJ Kasper
f942d9e892
Include additional query values when interpolating href (#16878)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-09-07 13:09:02 +02:00
Tim Neutkens
f077a39e21
Divide export build output in 4 segments instead of showing it one by one (#16815) 2020-09-07 11:52:12 +02:00
JJ Kasper
a9c442f2df
v9.5.4-canary.4 2020-09-06 21:17:34 -05:00
JJ Kasper
489cad36bc
Fix href resolving with trailing slash enabled (#16873)
This makes sure to strip the trailing slash before attempting to resolve the `href` against pages/dynamic routes and adds tests ensuring the correct pages are resolved with `trailingSlash: true` enabled.

Fixes: https://github.com/vercel/next.js/issues/16872
2020-09-06 02:36:57 +00:00
Joe Haddad
ae7ae0ba68
v9.5.4-canary.3 2020-09-05 00:43:53 -04:00
JJ Kasper
6233ef7ed8
Correct client rewrite resolving with query (#16860)
This makes sure we only pass the as value's `pathname` instead of the full value so that we don't accidentally include `query` values while resolving the rewrites. This also adds tests to ensure the rewrites are resolved with the correct query values when only providing `href` and when manually mapping them with `href` and `as`

Fixes: https://github.com/vercel/next.js/issues/16825
2020-09-04 19:19:17 +00:00
JJ Kasper
f7435b4142
v9.5.4-canary.2 2020-09-04 10:37:58 -05:00
JJ Kasper
d97237a292
Fix invalid config export errors (#16834)
This corrects detecting of invalid page config exports and adds additional test cases for non-invalid config import/exports

Closes: https://github.com/vercel/next.js/issues/16775
2020-09-04 13:19:12 +00:00
Jan Potoms
764b194505
make parseRelativeUrl return a UrlObject (#16809)
Alternative to https://github.com/vercel/next.js/pull/16798
2020-09-03 18:26:52 +00:00
JJ Kasper
8426f13713
Update to show build indicator while re-fetching GS(S)P data in dev (#16789)
This is a follow-up to https://github.com/vercel/next.js/pull/16744 which shows the build/activity indicator while the data is being re-fetched to let the user know the re-fetching is occurring 

Closes: https://github.com/vercel/next.js/issues/16790
2020-09-03 12:27:08 +00:00
Joe Haddad
a555029a7b
v9.5.4-canary.1 2020-09-02 13:13:51 -04:00
JJ Kasper
4685332353
Add automatic reloading when editing GS(S)P methods (#16744)
This adds initial support for reloading the page when `getStaticProps`, `getStaticPaths`, or `getServerSideProps` were changed for a page by triggering a reload when the server output for a page has changed but the client output has not since these methods aren't included in the client output. 

Closes: https://github.com/vercel/next.js/issues/13949
2020-09-02 16:57:21 +00:00
JJ Kasper
f8d92a67f0
Ensure interpolating dynamic href values works correctly (#16774)
This corrects/makes sure interpolating dynamic route values for `href` works correctly. This provides an alternative approach to building the `href` value with `next/link` so that you don't need to worry about encoding the params manually. 

Closes: https://github.com/vercel/next.js/issues/13473
Closes: https://github.com/vercel/next.js/issues/14959
Closes: https://github.com/vercel/next.js/issues/16771
2020-09-02 16:23:26 +00:00
Joe Haddad
200c5ed806
v9.5.4-canary.0 2020-09-02 02:43:58 -04:00
Alex Castle
6874adbbb9
Make the image post-processor ignore SVG images (#16732)
This is a small change to the image post-processor logic. When it's looking for images to preload, it will now ignore SVGs, as these are rarely the relevant images for LCP.
2020-09-02 02:42:20 +00:00
Joe Haddad
b6df810406
v9.5.3 2020-09-01 16:21:49 -04:00
Joe Haddad
48ce4de0fd
v9.5.3-canary.27 2020-09-01 14:10:34 -04:00
Joe Haddad
e34e5e09d9
Revert #14580 (#16757) 2020-09-01 14:09:25 -04:00
Joe Haddad
1c45f70952
[test] Update hydration marker for React 17 (#16756) 2020-09-01 17:43:44 +00:00
Arthur
d20dbd6c2e
Export return type for GetStaticPaths (#16580)
* feat Export return type for GetStaticPaths

* add Duplicate generic

Co-authored-by: Luis Alvarez D <luis@vercel.com>
2020-09-01 12:20:17 -05:00
Joe Haddad
d59f12c416
v9.5.3-canary.26 2020-09-01 12:22:12 -04:00
JJ Kasper
91a50d3674
Revert "fix: Promise.prototype.finally is object (#16620)" (#16753)
This reverts commit 6926ab7b2a.
2020-09-01 12:06:51 -04:00
Joe Haddad
f921b4f476
Auto enable React's new JSX transform on 17.x (#16603) 2020-09-01 11:29:25 -04:00
TMQ
6926ab7b2a
fix: Promise.prototype.finally is object (#16620)
The [finally-polyfill](https://gist.github.com/developit/d970bac18430943e4b3392b029a2a96c)  did not expose any values.
![image](https://user-images.githubusercontent.com/15967520/91409583-2f916a00-e878-11ea-86d0-189966ceb83c.png)
2020-08-30 03:01:29 +00:00
Jan Potoms
20a4928b16
remove unneeded error (#16636)
This is not needed anymore since absolute urls are supported.
Also added an extra test for `mailto:` urls
2020-08-28 02:49:40 +00:00
Joe Haddad
f658b7641d
v9.5.3-canary.25 2020-08-26 22:18:49 -04:00
Joe Haddad
328abb72ca
Do not rely on cssText (#16611) 2020-08-26 22:13:28 -04:00
Joe Haddad
42e8dcf281
v9.5.3-canary.24 2020-08-26 12:35:37 -04:00
Joe Haddad
6895f9b0f4
Replace <link rel=stylesheet> client-side transitions with <style> tags (#16581)
This pull request replaces our client-side style transitions with `<style>` tags over async `<link rel=stylesheet>` tags. This should fix some edge cases users see with Chrome accidentally causing a FOUC.

This also removes the need to perform an async operation before starting the render, which should remove any perceivable navigation delay.

---

Fixes #16289
2020-08-26 16:34:53 +00:00
Joe Haddad
5fbe50c49a
v9.5.3-canary.23 2020-08-25 11:23:04 -04:00
Joe Haddad
52efe3364f
Reuse existing <link rel=stylesheet> on nav (#16537)
This pull request reuses existing `<link rel=stylesheet>` tags if their `href` matches instead of recreating it. This is in effort to fix an edge case where the browser will FOUC on the tag swap.

This behavior should be sufficiently covered by all the existing CSS cases, as misbehavior would result in the resulting CSS styles being incorrect.
2020-08-25 15:03:14 +00:00
Tim Neutkens
2e12e86d7c v9.5.3-canary.22 2020-08-25 12:03:06 +02:00
Tim Neutkens
ed0820f763
Enable webpack 5 caching by default (#16531)
When the webpack 5 beta is used disk caching will be automatically enabled to improve incremental build performance.
2020-08-24 22:37:52 +00:00
Joe Haddad
885d145ff7
v9.5.3-canary.21 2020-08-24 01:23:01 -04:00
khades
1a7f3e5199
Store css file dependencies info for dynamic imports and apply it at SSR (#12843)
To prevent FOUC, discussed in #10557 i need to store information about css file dependencies for chunk. Right now current implementation just throws away everything but js.

Can there be more than one css file in chunk? If no - code will be simplified.

closes #10557
2020-08-24 05:20:11 +00:00
Luis Alvarez D
735aab6f03
Update Fast Refresh warning (#16496)
Fixes https://github.com/vercel/next.js/issues/16495

Terminal:

![image](https://user-images.githubusercontent.com/4278345/90984442-96421b00-e53a-11ea-9939-44b00cba87cf.png)

Browser: 

![image](https://user-images.githubusercontent.com/4278345/90984456-a9ed8180-e53a-11ea-86da-d9f28e9c2fdd.png)

The link https://nextjs.link/codemod-ndc used for the warning links to a currently 404 docs page, that will be available in the next stable release.

Tests not added as the warning has tests already.
2020-08-24 03:04:25 +00:00
JJ Kasper
a7550bf1d7
Add error when document component isn't rendered (#16459)
If a custom `_document` is added but not all of the expected document components are rendered it can cause unintended errors as noticed in https://github.com/vercel/next.js/issues/10219 so this adds detecting when one of the expected document components isn't rendered and shows an error. 

Closes: https://github.com/vercel/next.js/issues/10219
2020-08-24 02:42:51 +00:00
Tim Neutkens
f2ba97d866
Add webpack 5 cache invalidation (#16494)
Handles:

- Next.js version
- next.config.js `env` key
- `NEXT_PUBLIC_` prefixed environment variables
- next.config.js keys that affect performance

Ideally we don't invalidate the whole cache when `NEXT_PUBLIC_` / `env` key variables change, but this is just to initially make the caching reliable, this behavior is similar to the current webpack 4 behavior, so it can only be improved 👍
2020-08-24 01:37:48 +00:00
JJ Kasper
4e0b40145d
Correct initial fallback route param values (#16485)
This fixes invalid initial route params in development mode and serverless production mode. It also adds tests to ensure these values are correct in development, production, and serverless mode.

x-ref: https://github.com/vercel/next.js/pull/16084
Fixes: https://github.com/vercel/next.js/issues/16481
Fixes: https://github.com/vercel/next.js/issues/16482
2020-08-23 12:35:30 +00:00
JJ Kasper
32ee65efa1
Correct shallow routing behavior through history (#16477)
When navigating from a non-shallow page to a page that was navigated to shallowly in history it causes incorrect page data to be shown since an incorrect shallow navigation is done. We can only maintain shallow routing when the current page was navigated to shallowly and the page being navigated to in history was also navigated to shallowly. Additional tests to ensure this behavior is working has also been added. 

Closes: https://github.com/vercel/next.js/issues/7395
Closes: https://github.com/vercel/next.js/issues/14928
Fixes: https://github.com/vercel/next.js/issues/16028
2020-08-22 21:51:14 +00:00
Tim Neutkens
4a981428ae v9.5.3-canary.20 2020-08-22 15:00:30 +02:00
Tim Neutkens
d0754993fc
Add webpack 5 caching for css optimizer (#16467) 2020-08-22 14:16:13 +02:00
Joe Haddad
9acd001e09
Fix render cancel behavior (#16462)
This pull request correctly tracks render cancelation behavior. Prior to this PR, we'd have an unhandled rejection that left the app in a bad state and no routeChangeError event was fired.

---

Closes #16424
Fixes #16445
2020-08-22 11:47:21 +00:00
JJ Kasper
8a1c9937b6
Make sure to break rewrites chain when dynamic route matches (#16455)
This makes sure to also check if a dynamic route matched after resolving a rewrite on the client to match behavior on the server. It also adds tests for this behavior to ensure it is working properly. 

Fixes: https://github.com/vercel/next.js/issues/16454
2020-08-22 05:15:45 +00:00
Joe Haddad
42e1d5b5dc
v9.5.3-canary.19 2020-08-21 15:39:06 -04:00
JJ Kasper
78ef13914a
Fix un-transpiled client file with rewrites (#16453)
This fixes a client-side file not being transpiled correctly when rewrites are used. The cross browser tests have been updated to make sure there are rewrites so the related code is included and not dead-code eliminated'

Closes: https://github.com/vercel/next.js/issues/16440
2020-08-21 19:11:25 +00:00
Joe Haddad
7c7ecaa636
Do not alias Node modules for webpack 4 (#16452)
Fixes #16259
Caused by #16022
Follow up issue: #16450

This PR skips polyfilling Node modules in webpack 4 which are ignored by the `browsers` key.
2020-08-21 18:50:24 +00:00
JJ Kasper
450742274a
Fix optional catch-all /index revalidate params (#16451)
This corrects the case where `/index` is used during revalidation for an optional catch-all route and `index` is passed as a param even though it should be undefined. This also adds test cases to make sure the params are normalized correctly

Fixes: https://github.com/vercel/next.js/issues/16366
2020-08-21 18:13:24 +00:00
Joe Haddad
f5b6c8b7ab
v9.5.3-canary.18 2020-08-21 11:55:25 -04:00
Tim Neutkens
b6a2051d49
Solve last mini-css-plugin webpack 5 warning (#16447)
Adds missing context parameter
2020-08-21 15:33:57 +00:00
Joe Haddad
21566e3ae1
v9.5.3-canary.17 2020-08-20 15:42:07 -04:00
Prateek Bhatnagar
6c9dd6c3d4
AMP compatibility for Font optimization (#16208)
- Upgrades cssnano to 1.2.0
- Only removes whitespaces from downloaded font declarations
- Disables Font optimization for AMP pages
2020-08-20 15:10:59 -04:00
Joe Haddad
3f35b47344
v9.5.3-canary.16 2020-08-20 14:32:06 -04:00
Joe Haddad
ec7009620a
Ensure unknown static paths 404 for data request (#16401)
We were accidentally allowing data requests to be rendered unconditionally. Instead, we should also check them against the staticPaths result and 404 when appropriate.

---

Fixes #15383
2020-08-20 17:59:03 +00:00
Joe Haddad
fc98c13a2e
Warn on duplicate Sass deps (#16398)
Fixes #13953
2020-08-20 16:05:29 +00:00
JJ Kasper
3dec50001e
Add debug flag for extra build output (#16399)
This adds a `-d` or `--debug` flag which enables outputting additional build output information like the rewrites, redirects, and headers

Fixes #15281
2020-08-20 15:43:38 +00:00
Joe Haddad
c210154a28
v9.5.3-canary.15 2020-08-20 10:07:14 -04:00
Tim Neutkens
08ab3ac6c1
Fix mini-css-plugin webpack 5 deprecation warnings (#16390)
Solves the warnings coming from mini-css-plugin in webpack 5.

Fixes #15947
2020-08-20 13:56:52 +00:00
Stephen McMillen
3e81809df4
Correct comment on --help (#16391)
The comment on the two different `--help` sections matched, though their logic if what was handled was slightly different.

This adjusts the comments to clarify that difference.

This is completely unrelated to function, but I noticed it while reviewing code and thought I'd PR the fix.
2020-08-20 13:32:55 +00:00
Tim Neutkens
fa449d9ee5 v9.5.3-canary.14 2020-08-20 12:39:09 +02:00
Tim Neutkens
dab55b473c
Add serialization for mini-css-plugin webpack 5 caching (#16379) 2020-08-20 12:38:39 +02:00
Joe Haddad
8efc8be3e9
v9.5.3-canary.13 2020-08-20 00:27:15 -04:00
JJ Kasper
e1e6cfa189
Fix page checking failing with trailingSlash (#16362)
This fixes page checking failing due to the trailing slash being present which causes pages to proxied by a rewrite when they shouldn't be. This also adds additional tests to ensure rewriting to an external resource is working correctly with `trailingSlash: true`

Fixes: https://github.com/vercel/next.js/issues/15700
2020-08-20 04:05:38 +00:00
JJ Kasper
681fbbd04d
Fix basePath and public folder check ending routes early (#16356)
This corrects the basePath being required check for filesystem routes to not consider the public folder catch-all route since it always matches even if the public file isn't present and instead moves the basePath check inside of the public-folder catch-all. Tests already exist that catch this by adding a public folder to the existing `basepath` test suite

Fixes: https://github.com/vercel/next.js/issues/16332
Closes: https://github.com/vercel/next.js/pull/16350
2020-08-19 17:30:33 +00:00
Joe Haddad
1ad9cd90e5
Reduce filesystem lookups during bootup (#16354)
This PR reduces the total number of filesystem accesses we perform on CLI boot-up to make it happen faster.
2020-08-19 16:15:16 +00:00
JJ Kasper
67482914c6
Normalize request URL/asPath for fallback SSG pages (#16352)
This interpolates the dynamic values and rebuilds the request URL for fallback SSG pages since the proxy uses the output path for non-prerendered pages on Vercel which can cause inconsistent request URL/`asPath` values for SSG pages. This also adds tests to ensure the `asPath` is correctly updated

Fixes: https://github.com/vercel/next.js/issues/16269
2020-08-19 15:23:02 +00:00
Tim Neutkens
1388aa41d5 v9.5.3-canary.12 2020-08-19 13:54:28 +02:00
Joe Haddad
0a72d14deb
Make loadPage track success of script loading (#16334)
Prior to this PR, `loadPage` would call `loadScript` which would then report if the script failed to load.

This was problematic because `loadScript` notified a failure to load via `pageRegisterEvents`, which would not set the `pageCache` value for future requests.
This means a one-off promise rejection would happen, [in lieu of being] typically consumed within the client-side router, causing a server-side reload.

However, when `loadPage` was used independently (i.e. to preload pages), this promise rejection would be ignored as a preload failure.
When the real routing request comes in, the `loadPage` function skips its attempt to load the `<script>` because it was already in the DOM, and the router would stop functioning.

---

To fix this behavior, I've removed erroneous emits on `pageRegisterEvents` to only happen during the page registration lifecycle (its intended use).

The new behavior is that `loadScript` returns a `Promise` that `loadPage` can track, and if any of the page(s) scripts fail to load, we mark the entire page as errored in `pageCache`. This ensures future requests to `loadPage` will always immediately reject with a `PAGE_LOAD_ERROR`, which causes the server-side redirect at the appropriate point.

---

Fixes #16333
2020-08-19 11:41:01 +00:00
Joe Haddad
8ef253fd02
v9.5.3-canary.11 2020-08-19 02:35:22 -04:00
Joe Haddad
9746043354
Fix IE11 CSS Compatibility (#16336) 2020-08-19 02:34:44 -04:00
Tim Neutkens
25fa1653bd v9.5.3-canary.10 2020-08-18 23:16:35 +02:00
Alex Castle
7198cbe093
Add at attribute to image preload link (#16328)
Fixes a small error in the image preload post-processor. Adds a needed 'as' attribute to the link.
2020-08-18 21:14:42 +00:00
Joe Haddad
fe61948d4f
v9.5.3-canary.9 2020-08-18 14:54:27 -04:00
Joe Haddad
ec07bf12aa
Add <link> attributes in proper order (#16319)
1. `as` should be set before `rel` in case of `preload` or `prefetch`
2. `href` should be after `onload` and `onerror`
2020-08-18 18:53:04 +00:00
Joe Haddad
5f9755002d
Force browser to recompute layout on page nav (#16318)
This fixes an edge case where every dozen or so transitions you'll see a flash depending on what's happening on the main thread at the time.

I'm not sure it's possible to test for this case, so we'll just have to do more field testing with this.
2020-08-18 18:15:51 +00:00
Joe Haddad
ff33e07afe
Replace broken prop-types-exact package (#15953)
This PR replaces `prop-types-exact` (only used in this location) with manual property checking.

Right now, malformed properties sent to `<Link>` are silently handled and only emit a warning in the console.
This leads to confusing/unexpected errors because we try to read a value that is undefined.

To fix this, we'll now throw a proper error when `<Link>` is misused. **This still isn't optimal, however, because we don't have a component stack trace we can give the user**.
We're not going to be able to give the user actionable instructions until React 16.14 at a minimum.

---

Fixes #13951
Fixes #16107
Closes #13962
2020-08-18 16:36:40 +00:00
Joe Haddad
f3d622ae47
v9.5.3-canary.8 2020-08-18 10:36:29 -04:00
Joe Haddad
8916e401a2
Fix old TypeScript version compatibility (#16288)
Fixes #16260
2020-08-18 14:06:10 +00:00
Tim Neutkens
0fbc9d23ef
Add experimental webpack 5 cache option (#16307)
Don't use this yet as it's still being developed. This is a first iteration that enables the webpack cache. There's still more to do here, for example if css modules are used there's currently a bug where webpack does not save the cache for browser compilation (impacting build performance). @sokra is going to look into that issue.
2020-08-18 15:46:55 +02:00
James Mosier
29ae372738
Allow React experimental version without warning (#16140)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-08-18 01:54:31 -04:00
Joe Haddad
a81ab3baee
v9.5.3-canary.7 2020-08-18 00:13:36 -04:00
JJ Kasper
9aadd1aa36
Fix forEach error in CSS commit in ie11 (#16282)
This fixes an error that was occurring in ie11 due to `forEach` being called on `querySelectorAll` before it was massaged to an array.

x-ref: https://github.com/vercel/next.js/pull/16126
Fixes #16283
2020-08-18 03:56:14 +00:00
Joe Haddad
d824189bcd
v9.5.3-canary.6 2020-08-17 19:03:17 -04:00
Joe Haddad
06d8acdfd0
Update stylesheets on page navigation (#16126)
This pull request adds a test case for the reproduction provided in #12445. This bug is specifically caused when loading the next page before navigation has actually occurred.

---

Fixes #12445
2020-08-17 21:20:05 +00:00
JJ Kasper
cdff5dfb75
v9.5.3-canary.5 2020-08-17 12:58:13 -05:00
Kevin Mårtensson
aa4b87e357
Handle cases where config is exported after its declaration (#16211)
AMP will still not work correctly when switching between non-AMP and AMP pages in development mode because of https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/plugins/next-page-config.ts#L116-L120.

Fixes #15704.
2020-08-17 17:24:18 +00:00
JJ Kasper
f8534a6e62
Fix data URL with root-catchall and basePath (#16263)
This fixes the incorrect `/_next/data` URL being generated on client transition due to the `as` value passed to `getRouteInfo` having the `basePath` which is used while interpolating the values for dynamic routes, specifically root catch-all routes. A regression test has also been added to ensure this is working

Closes: https://github.com/vercel/next.js/issues/15747
2020-08-17 15:25:36 +00:00
Tim Neutkens
aa7659d807 v9.5.3-canary.4 2020-08-17 13:00:57 +02:00
Tim Neutkens
bbbbb3502d
Make css-minimizer compatible with webpack 5 (#16250) 2020-08-17 12:59:44 +02:00
Sergey Rubanov
feeb941dc6
Update to Terser 5 (#16194)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-08-16 19:32:37 +02:00
Joe Haddad
2e8068fcbe
v9.5.3-canary.3 2020-08-14 16:24:19 -04:00
JJ Kasper
1b4d463cc8
Update rewrite params query appending (#16189)
This updates to not automatically append params to the query for rewrites if one or more of the params are already used in the destination's path. No other behavior is being changed and if the user still wants the params in the query after using them in the destination's path they can manually add them like with redirects.

Closes: https://github.com/vercel/next.js/issues/15626
2020-08-14 18:51:58 +00:00
Joe Haddad
9fcf39acd4
Refactor <Document> files (#16184)
Instead of reading the `BuildManifest` and passing it to `/_document`, it should be able to read it for itself.

---

Fixes #16182
2020-08-14 14:20:03 +00:00
Kristoffer K
db40a39f5e
fix: add missing dependency caniuse-lite (#16091)
**What's the problem this PR addresses?**

https://github.com/vercel/next.js/pull/16048 stopped bundling `caniuse-lite` but didn't declare it as a dependency

https://github.com/yarnpkg/berry/runs/972037981?check_suite_focus=true#step:5:75

**How did you fix it?**

Add `caniuse-lite` as a dependency

---
cc @Timer 

As mentioned in https://github.com/vercel/next.js/issues/14157#issuecomment-667328984 I looked into adding a PnP e2e test but the use of the `gist` protocol stopped me from getting it to work since v2 doesn't support that yet. Would it be possible to change this to one of the supported protocols (https://yarnpkg.com/features/protocols)?
6366727550/packages/next/package.json (L208)
2020-08-14 13:52:52 +00:00
Joe Haddad
32adc3a00d
v9.5.3-canary.2 2020-08-14 01:43:45 -04:00
Joe Haddad
3597978d7f
Modify low priority files in manifest (#16181)
This pull request edits the `BuildManifest` that is sent to `/_document` instead of modifying a single input array to decouple its implementation details.

Optimally, we'd eliminate the `files` key all together.

---

Related to #16182
2020-08-14 04:30:25 +00:00
Joe Haddad
4e813ae0c6
v9.5.3-canary.1 2020-08-13 18:49:35 -04:00
Joe Haddad
cb786ebd81
Share NEXT_DATA type instead of recreating it (#16174) 2020-08-13 22:19:06 +00:00
Joe Haddad
33176806f3
Remove unused dependency (#16168) 2020-08-13 13:40:08 -04:00
Joe Haddad
0e48ea3938
Convert next/client to TypeScript (#16167)
Fixes #16166
2020-08-13 13:39:33 -04:00
Joe Haddad
09afc376cd
Convert performance relayer to TypeScript (#16161)
Really basic one! Needed for `next/client`.
2020-08-13 15:20:29 +00:00
Joe Haddad
5b81531676
Reduce router code (#16159)
This reduces the code as suggested: https://github.com/vercel/next.js/pull/15231#discussion_r469691649.

Removes these bloated Babel helpers:

```diff
@@ -678,80 +678,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
       var _createClass = __webpack_require__("W8MJ");
 
-      function _createForOfIteratorHelper(o, allowArrayLike) {
-        var it;
-        if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
-          if (
-            Array.isArray(o) ||
-            (it = _unsupportedIterableToArray(o)) ||
-            (allowArrayLike && o && typeof o.length === "number")
-          ) {
-            if (it) o = it;
-            var i = 0;
-            var F = function F() {};
-            return {
-              s: F,
-              n: function n() {
-                if (i >= o.length) return { done: true };
-                return { done: false, value: o[i++] };
-              },
-              e: function e(_e) {
-                throw _e;
-              },
-              f: F
-            };
-          }
-          throw new TypeError(
-            "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
-          );
-        }
-        var normalCompletion = true,
-          didErr = false,
-          err;
-        return {
-          s: function s() {
-            it = o[Symbol.iterator]();
-          },
-          n: function n() {
-            var step = it.next();
-            normalCompletion = step.done;
-            return step;
-          },
-          e: function e(_e2) {
-            didErr = true;
-            err = _e2;
-          },
-          f: function f() {
-            try {
-              if (!normalCompletion && it["return"] != null) it["return"]();
-            } finally {
-              if (didErr) throw err;
-            }
-          }
-        };
-      }
-
-      function _unsupportedIterableToArray(o, minLen) {
-        if (!o) return;
-        if (typeof o === "string") return _arrayLikeToArray(o, minLen);
-        var n = Object.prototype.toString.call(o).slice(8, -1);
-        if (n === "Object" && o.constructor) n = o.constructor.name;
-        if (n === "Map" || n === "Set") return Array.from(o);
-        if (
-          n === "Arguments" ||
-          /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)
-        )
-          return _arrayLikeToArray(o, minLen);
-      }
-
-      function _arrayLikeToArray(arr, len) {
-        if (len == null || len > arr.length) len = arr.length;
-        for (var i = 0, arr2 = new Array(len); i < len; i++) {
-          arr2[i] = arr[i];
-        }
-        return arr2;
-      }
-
       exports.__esModule = true;
       exports.hasBasePath = hasBasePath;
       exports.addBasePath = addBasePath;
@@ -1864,28 +1790,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               } // handle resolving href for dynamic routes
 
               if (!pages.includes(cleanPathname)) {
-                var _iterator = _createForOfIteratorHelper(pages),
-                  _step;
-
-                try {
-                  for (_iterator.s(); !(_step = _iterator.n()).done; ) {
-                    var page = _step.value;
-
-                    if (
-                      (0, _isDynamic.isDynamicRoute)(page) &&
-                      (0, _routeRegex.getRouteRegex)(page).re.test(
-                        cleanPathname
-                      )
-                    ) {
-                      parsedHref.pathname = addBasePath(page);
-                      break;
-                    }
+                // eslint-disable-next-line array-callback-return
+                pages.some(function(page) {
+                  if (
+                    (0, _isDynamic.isDynamicRoute)(page) &&
+                    (0, _routeRegex.getRouteRegex)(page).re.test(cleanPathname)
+                  ) {
+                    parsedHref.pathname = addBasePath(page);
+                    return true;
                   }
-                } catch (err) {
-                  _iterator.e(err);
-                } finally {
-                  _iterator.f();
-                }
+                });
               }
 
               return parsedHref;
@@ -2069,10 +1983,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 }
 
                 if (cancelled) {
-                  var _err = new Error("Loading initial props cancelled");
-
-                  _err.cancelled = true;
-                  throw _err;
+                  var err = new Error("Loading initial props cancelled");
+                  err.cancelled = true;
+                  throw err;
                 }
 
                 return data;
```
2020-08-13 14:50:01 +00:00
Tim Neutkens
7b13205e7e v9.5.3-canary.0 2020-08-13 14:41:25 +02:00
JJ Kasper
8a489e24bc
Add initial handling for dynamic route href resolving and rewrites on the client (#15231)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-08-13 14:39:36 +02:00
Joe Haddad
ff0571ae14
Remove unused router method (#16149)
This PR removes a legacy router method that was used for old-style HMR, now replaced by Fast Refresh.

This method was not public:
```tsx
export type NextRouter = BaseRouter &
  Pick<
    Router,
    | 'push'
    | 'replace'
    | 'reload'
    | 'back'
    | 'prefetch'
    | 'beforePopState'
    | 'events'
    | 'isFallback'
  >
```

Even if someone found this method, it's highly unlikely they could use it successfully—it required the full module object.
2020-08-13 05:43:13 +00:00
Joe Haddad
c7acd1187b
Dedupe ComponentRes type (#16148)
This PR dedupes the `ComponentRes` type to now align with the `loadPage` return type.
2020-08-13 05:24:57 +00:00
Joe Haddad
94a85cff12
Improve page loader types (#16145) 2020-08-13 00:01:15 -04:00