Commit graph

2702 commits

Author SHA1 Message Date
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
Joe Haddad
16e4f9e79e
Strongly type Head Manager (#16144) 2020-08-12 23:54:48 -04:00
Joe Haddad
9e65c6a958
Strongly type PageLoader (#16132)
Fixes #16131
2020-08-12 20:42:05 +00:00
Tim Neutkens
e72ac76422
Remove tslint disables (#16116)
We no longer use tslint so these comments don't do anything.
2020-08-12 14:39:07 +00:00
Joe Haddad
07df897dad
v9.5.2 2020-08-10 19:17:42 -04:00
Joe Haddad
1bc63a379d
v9.5.2-canary.18 2020-08-10 18:45:23 -04:00
Joe Haddad
782d27e576
v9.5.2-canary.17 2020-08-10 16:49:03 -04:00
Yuhei Yasuda
052a9d2353
Don’t prevent the browser’s default behavior for Alt key (#16003)
In most browsers, clicking links with the Alt key has a special behavior, for example, Chrome downloads the target resource. As with other modifier keys, the router should stop the original navigation to avoid preventing the browser’s default behavior.

When users click a link while holding the Alt key together, the browsers behave as follows.

Windows 10:

| Browser    | Behavior                                    |
|:-----------|:--------------------------------------------|
| Chrome 84  | Download the target resource                |
| Firefox 79 | Prevent navigation and therefore do nothing |
| Edge 84    | Download the target resource                |
| IE 11      | No impact                                   |

macOS Catalina:

| Browser    | Behavior                                    |
|:-----------|:--------------------------------------------|
| Chrome 84  | Download the target resource                |
| Firefox 79 | Prevent navigation and therefore do nothing |
| Safari 13  | Download the target resource                |
2020-08-10 20:32:47 +00:00
Joe Haddad
378f092aaf
v9.5.2-canary.16 2020-08-10 15:46:43 -04:00
Prateek Bhatnagar
2ddfd84411
Improvements - Font optimizations (#16031)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-08-10 14:06:38 -04:00
Joe Haddad
bd70354394
v9.5.2-canary.15 2020-08-10 13:55:06 -04:00
Joe Haddad
6d71eef518
Do not assign to readonly property in Safari (#16051) 2020-08-10 13:15:37 -04:00
Joe Haddad
4a04212d6b
v9.5.2-canary.14 2020-08-10 12:28:49 -04:00
Sebastian Benz
d6ad0d0843
upgrade @ampproject/toolbox-optimizer to 2.6.0 (#16043)
See [release notes](https://github.com/ampproject/amp-toolbox/releases/tag/v2.6.0).

**Highlight:** [hero images can now be server-side rendered](https://github.com/ampproject/amp-toolbox/tree/main/packages/optimizer#preloadheroimage) by annotating then with `data-hero`. This will greatly improves LCP when using large images in the first viewport.

```
<amp-img data-hero src="/hero.jpg" layout="responsive" width="640" height="480"></amp-img>
```

Also fixes #15979
2020-08-10 16:06:00 +00:00
Joe Haddad
e08b633c3a
Do not bundle caniuse-lite (#16048) 2020-08-10 11:27:21 -04:00
Tim Neutkens
1398aebf7b v9.5.2-canary.13 2020-08-10 16:29:13 +02:00
Tim Neutkens
e8e59a175e v9.5.2-canary.12 2020-08-10 14:35:25 +02:00
Tim Neutkens
281318d50e v9.5.2-canary.11 2020-08-10 11:49:45 +02:00
Tim Neutkens
37d2d15b6e
Resolve aliases modules (#16033)
Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>
2020-08-10 11:45:10 +02:00
Tim Neutkens
62031ff24f
Move next-codemod to Next.js monorepo (#15536) 2020-08-10 11:14:53 +02:00
Tim Neutkens
f4433ceaa2 v9.5.2-canary.10 2020-08-10 09:50:15 +02:00
Tim Neutkens
843d58425b
Add browser polyfils for Node.js modules (webpack 5 backwards compat) (#16022)
This adds the following Node.js core polyfills only when the import is used:

- `path`
- `stream`
- `vm`
- `crypto`
- `buffer`

Fixes #15948

We'll have a separate issue about adding warnings for the usage of these modules in the browser, some polyfills like crypto are quite heavy and generally not needed for most applications (included accidentally through node_modules).
2020-08-10 01:26:21 +00:00
Amirali Esmaeili
4b6e9a45a3
Fix amphtml link rel not respecting basePath (#15949)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-08-08 15:15:00 +02:00
Prateek Bhatnagar
d8edb2eaa5
Bug fix: Font optimization (#15984)
Bug fix
- Do not remove spaces as it might mangle font names
2020-08-08 13:14:03 +00:00
Tim Neutkens
7fc92a6c78 v9.5.2-canary.9 2020-08-07 09:39:18 +02:00
JJ Kasper
b1ef76df31
Fix asPath normalizing for non-dynamic pages (#15960) 2020-08-07 09:01:34 +02:00
Markoz Peña
6375026a41
Added Friendly error for res.redirect 🐝 (#15844)
## Which solves this PR

 Displaying a friendly error, when the user is only passing `statusOrUrl`(type number) and the second argument `url` is ignored.

**Example**

`res.redirect(307);` // Show friendly error

Closes: https://github.com/vercel/next.js/issues/15594
x-ref: https://github.com/vercel/next.js/pull/15603
2020-08-06 22:53:09 +00:00
Tom Dohnal
eb4be226fd
notify component when route hash changes (#13894)
This resolves https://github.com/vercel/next.js/issues/13659
2020-08-06 22:04:47 +00:00
Evil Rabbit
8fed0c3ab5
Improve Vercel's badge (#15946) 2020-08-06 12:35:36 -04:00
Jan Potoms
cbfb8cbcc7
Remove querystring from the client (#15378) 2020-08-06 12:32:58 -04:00
Joe Haddad
882288b532
Warn when Fast Refresh is disabled (React <16.10) (#15931) 2020-08-06 10:41:11 -04:00
Joe Haddad
2d42b8e076
Delay server start message until it's listening (#15929)
Fixes #15928

---

This would cause us to print the message too early and open the browser to a server that wasn't started yet. This waits until we're listening, but before the app is ready fully.
2020-08-06 06:47:01 +00:00
Joe Haddad
0923ee6db4
v9.5.2-canary.8 2020-08-05 16:46:28 -04:00
Joris
0fd1958ae4
Disallow re-export all exports from Next.js pages (#14325)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-08-05 16:21:40 -04:00
JJ Kasper
7d7a8fc300
Normalize serverless asPath value (#15914)
Since we now use query parameters to pass dynamic route params while routing on Vercel, this makes sure we normalize the request URL before populating the `asPath`

Fixes: https://github.com/vercel/next.js/issues/15879
2020-08-05 19:29:38 +00:00
Tim Neutkens
405e42e41e
Enhance module not found error (#15860)
Adds handling for module not found errors exposed by webpack. This ensures you see the actual stack line and code instead of a short message where you don't know where to go.

### Previous

<img width="794" alt="Screen Shot 2020-08-05 at 18 02 06" src="https://user-images.githubusercontent.com/6324199/89435935-d5542c00-d745-11ea-9ca7-c67f553364f9.png">


### New

<img width="769" alt="Screen Shot 2020-08-05 at 14 20 23" src="https://user-images.githubusercontent.com/6324199/89412212-f6595480-d726-11ea-81a3-398ab7036338.png">


Fixes #14711
2020-08-05 19:11:35 +00:00
Joe Haddad
46488fbcc6
v9.5.2-canary.7 2020-08-05 14:25:00 -04:00
Jan Potoms
5dbe0d0215
Allow absolute urls in router and Link (#15792)
Fixes https://github.com/vercel/next.js/issues/15639
Fixes https://github.com/vercel/next.js/issues/15820

To Do:
- [x] Doesn't work with `basePath` yet
2020-08-05 18:12:17 +00:00
Alex Castle
b6060fa4a5
Add experimental image post-processing (#15875)
This PR adds a second experimental post-processing step for the framework introduced by @prateekbh in #14746. The image post-processing step scans the rendered document for the first few images and uses a simple heuristic to determine if the images should be automatically preloaded.

Analysis of quite a few production Next apps has shown that a lot of sites are taking a substantial hit to their [LCP](https://web.dev/lcp/) score because an image that's part of the "hero" element on the page is not preloaded and is getting downloaded with lower priority than the JavaScript bundles. This post-processor should automatically fix that for a lot of sites, without causing any real performance effects in cases where it fails to identify the hero image.

This feature is behind an experimental flag, and will be subject to quite a bit of experimentation and tweaking before it's ready to be made a default setting.
2020-08-05 17:49:44 +00:00
Joe Haddad
fce1830d35
v9.5.2-canary.6 2020-08-04 22:28:36 -04:00
Joe Haddad
754ec6642a
Run Fast Refresh Loader in Babel Loader (#15851)
Next.js plugins like `@next/mdx` inject additional webpack loaders to compile files, but they omit the necessary loader for Fast Refresh to work.

Instead of making these files deopt out of Fast Refresh, we can automatically detect and inject the loader in these cases.

Fixes #13574
2020-08-04 21:24:56 +00:00
Joe Haddad
1968f7f552
v9.5.2-canary.5 2020-08-04 13:52:26 -04:00
Jan Potoms
92304404a4
Disallow basePath: false for internal routes (#15837) 2020-08-04 17:50:09 +00:00
jiangtao
35e4a370d9
fixed issue with runtime-config returning undefined when building or in a development environment (#15777)
fix https://github.com/vercel/next.js/issues/7713#issuecomment-643632270
2020-08-04 16:47:37 +00:00
Joe Haddad
e818389999
Add support for fallback: 'blocking' (#15672)
By popular request, this pull request adds support for returning `fallback: 'blocking'` from `getStaticPaths`.

This new mode will cause unknown paths to be rendered on-demand ("SSR") without the static (placeholder) fallback.

This feature is **currently experimental and should not be used in production yet**. It's currently flagged behind `unstable_`:

```
fallback: 'unstable_blocking'
```

TODO:

- [x] Next.js tests
- [ ] Add Vercel support
- [ ] Vercel tests

---

Fixes #15637
2020-08-04 15:10:31 +00:00
Tim Neutkens
668cc6a6f1 v9.5.2-canary.4 2020-08-04 12:35:24 +02:00
Darsh Patel
96a66c4bd3
incremental static generation and regeneration support in build manifest (#14365)
The icon is just something I thought might look good, can certainly be changed.
I've currently added incremental static generation support

Edit: Updated screenshot after 8037981
![Screenshot 2020-08-04 at 1 51 14 PM](https://user-images.githubusercontent.com/11258286/89270960-afe9f400-d659-11ea-8f18-197dc53b8beb.png)





Fixes: #14204
2020-08-04 08:42:18 +00:00
Jonathan G
6c59cbb46a
[Feature] Progress bar for static build (#15297)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-08-04 09:58:23 +02:00
Prateek Bhatnagar
1ea8bdcdc7
Bug fix: Font optimization (#15644)
- Fixes the serverless build for font optimizations
2020-08-04 07:54:08 +00:00
Kristóf Poduszló
aef6726eb8
Add missing nomodule polyfills and suggest using features only up to ES2019 for browser compatibility (#15772)
These changes aim to resolve most of the concerns raised in #15756. It adds missing polyfills for legacy browsers up until ES2019:

- Number.{parseFloat,parseInt}
- ~Math.{acosh,asinh,atanh,cbrt,clz32,cosh,expm1,fround,hypot,imul,log10p,log1p,log2,sign,sinh,tanh,trunc}~ _[Removed as these are [not widely used](https://github.com/vercel/next.js/pull/15772#discussion_r463957931)]_
  - While these may seem to weigh a lot, they barely add 1 kB to the resulting bundle:
    <img width="492" alt="gzip: 32 kB vs. 30.9 kB, Brotli: 28.8 kB vs. 27.8 kB" src="https://user-images.githubusercontent.com/14854048/89100961-1376e600-d3fc-11ea-90fd-3e6632b70220.png">
- ~Object.fromEntries~ _[Removed as [it's rarely used in user code](https://github.com/vercel/next.js/pull/15772#discussion_r463984612)]_

Also, the following features are now supported with build-time transforms:

- ~`globalThis` (gets transformed into `window` in browser environments)~ _[Removed as it [could break existing applications](https://github.com/vercel/next.js/pull/15772#discussion_r463956269)]_
- `export * as ns from 'module'`

The suggested TypeScript library version has been set to ES2018, so the features below become unavailable in type-checked files (they're not evenly supported by module-compatible browsers, either):

- Object.fromEntries
- String.prototype.matchAll
- String.prototype.replaceAll
- Promise.any + AggregateError
- WeakRef

As for the `import.meta` support, [webpack v5 seems to fix that](https://github.com/webpack/webpack/pull/11075), so it should eventually become an issue of the past.

---

Fixes #15756
2020-08-04 06:03:52 +00:00
Joe Haddad
8285df5ed2
v9.5.2-canary.3 2020-08-04 00:08:28 -04:00
Joe Haddad
48ca2f2cc5
Fix CSS grid-column shorthand syntax (#15848) 2020-08-04 00:08:09 -04:00
Tim Neutkens
e8c3190255
Support persisting the dev cache buster (#15827)
Same as #15483 but couldn't push to it

---

Closes #15483
Fixes #15828
2020-08-03 14:22:55 +00:00
Jan Potoms
b87e4989e2
Rename exportTrailingSlash to existing trailingSlash property (#15768)
In terms of url rewriting, `trailingSlash` supports everything `exportTrailingSlash` does. We can just share all other code paths and deprecate `exportTrailingSlash`.

This PR shows a deprecation warning when `exportTrailingSlash` is used.

Also fixes https://github.com/vercel/next.js/issues/15774

We can update the tests now or later. (I kept them the same to prove it's non-breaking)

To do:
- [x] Do we want to keep this? => nope 841d4efc51/packages/next/next-server/lib/router/router.ts (L329)
- [x] I kept `exportTrailingSlash` here. Do we want to rename that as well? => nope 2d9d649d49/packages/next/build/index.ts (L959)
2020-08-03 14:03:11 +00:00
Tim Neutkens
60f1d58c83
Fix some webpack 5 deprecation warnings (#15797)
- Use latest terser version (still 1 warning in the stable version which is an open PR)
- Add emitOnErrors instead of noEmitOnErrors
- Added trace-deprecations for Next.js core development
2020-08-03 12:57:17 +00:00
Tim Neutkens
210a6980d2
Solve large portion of webpack 5 deprecation warnings (#15806)
- Using `namedChunks` where possible, this will also allow for faster access to the chunks as we no longer have to look them up like we did before using `find`
- Using the new asset hooks introduced in the latest webpack beta
- Using the new externals function signature
2020-08-03 12:26:23 +00:00
Joe Haddad
ed0a47b110
v9.5.2-canary.2 2020-08-03 01:47:42 -04:00
JJ Kasper
9dd974dfca
Fix dotenv loading with cascading values (#15799)
Adds additional test cases for cascading env values and corrects behavior

Fixes: https://github.com/vercel/next.js/issues/15744
2020-08-02 20:15:11 +00:00
Jan Potoms
841d4efc51
Improve router types (#15775) 2020-08-01 18:13:03 +00:00
Jan Potoms
1b033423dc
Fix asPath of rewrite without basePath (#15760)
Fixes https://github.com/vercel/next.js/issues/15755
2020-08-01 11:51:47 +00:00
Joe Haddad
6366727550
v9.5.2-canary.1 2020-07-31 13:31:49 -04:00
Jan Potoms
ad5c736798
Remove unused error (#15748)
Irrelevant since https://github.com/vercel/next.js/pull/15379
2020-07-31 17:29:09 +00:00
Rafau
bcd1ba622e
[webpack5] Complile for ES5 (#15708)
I think this is necessary for IE11.

via [Webpack docs](https://webpack.js.org/migrate/5/#turn-off-es2015-syntax-in-runtime-code-if-necessary)


> By default, webpack's runtime code uses ES2015 syntax to build smaller bundles. If your build targets environments that don't support this syntax (like IE11), you'll need to set output.ecmaVersion: 5 to revert to ES5 syntax.


Thank you
2020-07-31 08:50:54 +00:00
Jan Potoms
c9e379c3bf
Fix wrong asPath on 404 (#15728)
Caught this while reviewing router code for https://github.com/vercel/next.js/pull/15710
2020-07-31 06:38:39 +00:00
JJ Kasper
ce56b60166
Add additional pageProps check (#15667)
`pageProps` should always be defined to ensure everything is working as expected although to prevent a breaking change this adds an additional check before attempting to access `pageProps` before hydration. It also adds tests to prevent regressing on this

Closes: https://github.com/vercel/next.js/issues/15647
2020-07-30 04:47:20 +00:00
Joe Haddad
6a48e3de60
v9.5.2-canary.0 2020-07-29 23:53:24 -04:00
Joe Haddad
cac35c389a
Fix hot reloader edge case with broken webpack plugins (#15659) 2020-07-29 23:44:25 -04:00
Joe Haddad
6b0c4948f0
v9.5.1 2020-07-29 23:11:48 -04:00
Joe Haddad
662d84b95b
v9.5.1-canary.3 2020-07-29 22:36:18 -04:00
Joe Haddad
3d98171dab
Test webpack 5 beta (#15645) 2020-07-29 19:19:32 -04:00
Joe Haddad
b748b5a443
v9.5.1-canary.2 2020-07-29 13:18:18 -04:00
Jan Potoms
80998a05f7
Don't use assetprefix on getServerSideProps and getStaticProps (#15634)
Strictly use `basePath` and not `assetPrefix` on `getStaticProps` and `getServerSideProps`

Fixes https://github.com/vercel/next.js/issues/15563
2020-07-29 16:51:51 +00:00
JJ Kasper
1a0cdbeacb
v9.5.1-canary.1 2020-07-29 09:58:32 -05:00
JJ Kasper
dd6a08980a
Normalize missing optional value on Vercel (#15593)
This updates collecting dynamic route params on Vercel to make sure that missing optional dynamic routes are undefined. Additional tests for this mode have also been added to ensure the params are being collected properly

Closes: https://github.com/vercel/next.js/issues/15579
2020-07-29 14:19:25 +00:00
JJ Kasper
fc2167311e
Update header replacing to be more relaxed (#15592)
Instead of trying to parse header values as URLs and then replace path segments in them this switches to escaping characters that can break `path-to-regexp` compiling

Fixes: https://github.com/vercel/next.js/issues/15580
x-ref: https://github.com/vercel/vercel/pull/4942
2020-07-29 08:47:23 +00:00
Robert van Steen
6eea915456
Add better typing for redirect (#15603) 2020-07-29 09:01:21 +02:00
JJ Kasper
86ba29f654
Make sure link can render without router (#15604)
This ensures rendering `next/link` doesn't fail without being nested under the router context.

Closes: https://github.com/vercel/next.js/issues/15543
2020-07-29 06:56:33 +00:00
Tim Neutkens
4730a1061d v9.5.1-canary.0 2020-07-28 14:08:23 +02:00
Arsalan Khattak
edbb32cac9
Next.js prefetching should use requestIdleCallback (#14580) 2020-07-28 13:13:44 +02:00
Prateek Bhatnagar
fb81ecb2bd
Font optimizations (#14746)
Co-authored-by: atcastle <atcastle@gmail.com>
2020-07-28 12:19:28 +02:00
Darsh Patel
27c207da7b
Fix: UnhandledPromiseRejectionWarning when unknown flag provided for cli commands (#15422) 2020-07-28 12:12:57 +02:00
Jan Potoms
91242ca6d7
Ignore history state not created by next.js (#15379)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-07-28 12:02:00 +02:00
Jean Helou
17420c785c
improves baseUrl resolution in typescript monorepos (#13542) 2020-07-28 12:00:27 +02:00
Tim Neutkens
fdfc508a61
Add polyfill for process and Buffer in webpack 5 (#15499) 2020-07-28 11:33:21 +02:00
Gerald Monaco
71bc0db92a
Combine sendPayload and sendHTML (#15475) 2020-07-27 16:19:30 -04:00
Sebastian Benz
5636748708
upgrade @ampproject/toolbox-optimizer to 2.5.14 (#15463) 2020-07-27 18:12:33 +00:00
Tim Neutkens
d33dbea8dc v9.5.0 2020-07-27 16:55:16 +02:00
Joe Haddad
1ee151640e
v9.4.5-canary.45 2020-07-27 01:59:19 -04:00
Joe Haddad
3accce37a7
v9.4.5-canary.44 2020-07-27 00:23:23 -04:00
Joe Haddad
e837c2253d
Upgrade cssnano-simple dependency (#15488) 2020-07-26 23:56:36 -04:00
Jan Potoms
574fe0b582
Make dynamic routes case-sensitive (#15444)
Fixes https://github.com/vercel/next.js/issues/15377
Closes https://github.com/vercel/next.js/pull/15394
2020-07-25 05:11:42 +00:00
James Mosier
f22f88fd73
Always resolve after router.prefetch() (#15448)
In development or with an invalid href, `await router.prefetch()` would not resolve the promise. This PR ensures that `await router.prefetch()` always resolves, no matter if it succeeds or not.

Fixes: https://github.com/vercel/next.js/issues/15436
Relevant discussion: https://github.com/vercel/next.js/discussions/15431#discussioncomment-41264
2020-07-25 04:36:43 +00:00
Tim Neutkens
c5f29b76ea
Update webpack to land chokidar patch for all Next.js users (#15460)
Forces all Next.js users to have this patch installed: https://twitter.com/timneutkens/status/1282129714627448832

Huge thanks to @paulmillr and @sokra 🙏
2020-07-24 19:23:23 +00:00
Mehedi Hassan
00ebce5553
More helpful README (#14830)
* More helpful README

Updated to include more details about Next.js, link to the interactive tutorial, showcase, etc. Content mostly based on the official Next.js site.

* create-next-app readme

An updated readme with more details on options, benefits, etc.

* Apply edits from code review

Co-authored-by: Luis Alvarez D. <luis@vercel.com>

* Remove redundant intro

* Update packages/create-next-app/README.md

* Remove introduction and list in showcase

* Apply suggestions from code review

* Update packages/next/README.md

Co-authored-by: Luis Alvarez D. <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-07-23 20:56:32 -05:00
Joe Haddad
53a3ffea25
v9.4.5-canary.43 2020-07-22 02:20:02 -04:00
Jan Potoms
fcfbceaa7e
Fix cancellation control flow (#15361) 2020-07-21 13:33:11 -04:00
Joe Haddad
0866ce3f5c
v9.4.5-canary.42 2020-07-20 16:19:48 -04:00
Jan Potoms
7dd61b47a2
Fix basepath router events (#14848)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-20 16:03:49 -04:00
Joe Haddad
d5c1addd64
Simplify trailing slash regex (#15335) 2020-07-20 14:24:43 -04:00
Tim Neutkens
c40f407d82
Stabilize revalidate (#15338) 2020-07-20 14:23:51 -04:00
Joe Haddad
a45def87a2
v9.4.5-canary.41 2020-07-20 13:00:54 -04:00
Joe Haddad
a11d99390a
Stabilize Trailing Slash API (#15331)
Closes #15330
2020-07-20 16:16:59 +00:00
Tim Neutkens
047b73b824 v9.4.5-canary.40 2020-07-20 17:39:41 +02:00
Tim Neutkens
e57b2091aa
Bring over fixes from #15185 (#15326)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-20 11:14:02 -04:00
Bogdan Chadkin
a26c69d11d
Upgrade browserslist (#15324)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-20 10:01:34 -04:00
Joe Haddad
42014a49af
v9.4.5-canary.39 2020-07-19 22:20:41 -04:00
Tim Neutkens
aa62fa7f42
Add test for main.js in webpack.config.js (#15311)
This particular variable was not being read correctly. Added a test for the behavior.

Fixes #15261
2020-07-20 02:16:50 +00:00
Joe Haddad
13a971c8b5
Do not duplicate compilation errors (#15299)
* Do not duplicate compilation errors

* Add tests

* Attempt to fix test

* Fix test
2020-07-19 14:09:41 -04:00
Joe Haddad
b1cfa51b47
v9.4.5-canary.38 2020-07-19 01:53:53 -04:00
Necmettin Karakaya
c2f38f2af0
[Fix] common misspelling errors (#15288)
For reference: https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-07-19 04:38:20 +00:00
Jan Potoms
381e44f324
Fix static data fetching when using absolute assetprefix (#15287)
Fixes https://github.com/vercel/next.js/issues/15188

`parseRelativeUrl` was used on urls that weren't always relative. It was used to generate a cache key, but we actually don't need these cache keys to be relative if the urls aren't relative.

Also took a look at the overall static data fetching logic and found a few things:

- [x] cache key is unnecessarily transformed through `prepareRoute`, we can just cache by resolved `dataHref` and remove that function. Pretty sure that `prepareRoute` was also introducing edge cases with `assetPath` and `delBasePath`
- [x] there is [a bug in the caching logic](ebdfa2e7a3/packages/next/next-server/lib/router/router.ts (L898)) that made it fail on the second visit: it should be `Promise.resolve(this.sdc[pathname])` instead of `Promise.resolve(this.sdc[dataHref])`. Also added a test for this
- [x] ~converted to async await to improve stacktraces and readability.~ I assumed this was fine since I saw some async/awaits in that file already but it seems to just blow up the size of the non-modern bundle.
- [x] extracted nested `getResponse` function and define it top level. this should improve runtime performance
- [x] convert `_getStaticData` and `_getServerData` to class methods instead of properties. Not sure why they were defined as properties but I think they belong on the prototype instead.
- [x] remove `cb` property from `fetchNextData`, it's unnecessary and makes the async flow hard to understand.  The exact same logic can go in the `.then` instead.
- [ ] data fetching logic [retries on 5xx errors](ebdfa2e7a3/packages/next/next-server/lib/router/router.ts (L157)), but not on network level errors. It should also retry on those. It should also not retry on every 5xx, probably only makes sense on 502, 503 and 504. (e.g. 500 is a server error that I wouldn't expect to succeed on a retry)

The overall result also is a few bytes smaller in size
2020-07-19 04:02:01 +00:00
Joe Haddad
f5b186cb69
Drop module: esnext requirement in tsconfig.json (#15276)
Next.js forcibly setting `module: 'esnext'` in `tsconfig.json` is necessary to prevent TypeScript from erroring on the following code:

```tsx
import dynamic from 'next/dynamic';

const A = dynamic(() => import('../A'));
```

```
ERROR in /Users/joe/Desktop/scratch/test-cjs/pages/index.tsx(5,25):
5:25 Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.
  > 5 | const A = dynamic(() => import("../test"));
```

However, users may want to use one of the many other targets for better interoperability with projects that co-exist with their Next.js project (like `commonjs`).

When cross referenced with:
```
Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'.ts
```

That means we can permit any of these values:

```json5
      parsedValues: [
        ts.ModuleKind.ES2020,
        ts.ModuleKind.ESNext,
        ts.ModuleKind.CommonJS,
        ts.ModuleKind.AMD,
      ],
```

This PR updates Next.js to allow those!

---

Fixes #15275
2020-07-18 19:37:13 +00:00
Tim Neutkens
4d944a2bfb
Fix no-anon-default-export for webpack 5 (#15293)
Fixes one of the cases of https://github.com/vercel/next.js/pull/15185#issuecomment-660128647
2020-07-18 18:34:05 +00:00
Tim Neutkens
569a289c84 v9.4.5-canary.37 2020-07-17 11:08:33 +02:00
Wayne Warner
7834766907
Fix DevServer#close doesn't close all resources (#15247) 2020-07-17 09:07:48 +00:00
Tim Neutkens
a33bb5bec5
Fix app-document-import-order test for webpack 5 (#15224) 2020-07-17 10:38:06 +02:00
Jan Potoms
dad3299852
Improve query conversion logic (#15236)
`URLSearchParams` has a `forEach` method. this should simplify and shorten the logic. Perhaps it will even phix https://github.com/vercel/next.js/issues/15232
2020-07-16 20:44:45 +00:00
Joe Haddad
2ffe46605d
v9.4.5-canary.36 2020-07-16 10:50:28 -04:00
Joe Haddad
b9f4bdfde3
v9.4.5-canary.35 2020-07-15 21:41:55 -04:00
Jan Potoms
54d991e642
fix basepath trailing slash (#15200)
Fixes the link rewriting part of https://github.com/vercel/next.js/issues/15194
2020-07-15 23:53:31 +00:00
Tim Neutkens
1fe612e882
Make sure the correct chunk names are used in webpack 5 (#15204) 2020-07-15 19:33:41 -04:00
Tim Neutkens
14babe5b3f
Make type checking compatible with webpack 5 (#15158)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-15 13:56:27 -04:00
Joe Haddad
ac7bee1589
v9.4.5-canary.34 2020-07-15 01:29:42 -04:00
Luis Alvarez D
6639b8f2af
Find pages/_document.js chunk in development (#15172)
Chunks already have a normalized path.

Not sure if there are other chunks that require this change, I did a global search and didn't find similar cases.
2020-07-15 05:28:47 +00:00
Joe Haddad
29dfaf9c7b
v9.4.5-canary.33 2020-07-14 14:59:19 -04:00
Joe Haddad
8222d571e7
Correctly fetch data for root route (#15149)
This PR corrects the data fetching behavior for optional root routes.

---

Fixes #14923
2020-07-14 18:58:02 +00:00
Darsh Patel
fcd03091b4
Fix: Invalid flag provided to next build results in UnhandledPromiseRejectionWarning (#15049) 2020-07-13 23:07:35 +02:00
Joe Haddad
a8b2a8e617
v9.4.5-canary.32 2020-07-13 15:40:57 -04:00
Jan Potoms
cd79c829b1
Make sure bad links in router methods resolve in production (#15135)
edge-case I introduced in https://github.com/vercel/next.js/pull/14827
2020-07-13 19:28:32 +00:00
Joe Haddad
dfee55221c
Update Fast Refresh full reload warning (#15062)
We've added a Babel warning for unnamed default exports, and this PR addresses the remaining points in #13024.

Fixes #13024
2020-07-13 18:01:11 +00:00
Jan Potoms
3369d67bd1
Replace node.js url module with WHATWG URL (#14827)
Replace `url.parse` and `url.resolve` logic with whatwg `URL`, Bring in a customized `format` function to handle the node url objects that can be passed to router methods. This eliminates the need for `url` (and thus `native-url`) in core. Looks like it shaves off about 2.5Kb, according to the `size-limits` integration tests.
2020-07-13 16:08:12 +00:00
Jan Potoms
d2699be6e8
Trailing slash basepath (#14781)
Fixes https://github.com/vercel/next.js/issues/14757

Since https://github.com/vercel/next.js/pull/15041 has been sorted out, this can now be fully fixed
There was also a bug in the dev server that causes redirect loops
2020-07-13 14:59:40 +00:00
Jan Potoms
c9492a8cc9
Relax encoding on dynamic prerendered routes (#14717)
It should be enough to encode the characters that `path-to-regexp` uses as path delimiters (`/#?`).

Fixes https://github.com/vercel/next.js/issues/14691
2020-07-13 14:42:27 +00:00
Jason Miller
272080c9c0
Avoid aggressive state loop (#15068)
/cc @cristianbote
2020-07-13 13:12:18 +00:00
JJ Kasper
2d9d649d49
Add handling for custom-routes with basePath (#15041)
This adds handling for custom-routes with `basePath` to automatically add the `basePath` for custom-routes `source` and `destination` unless `basePath: false` is set for the route. 

Closes: https://github.com/vercel/next.js/issues/14782
2020-07-12 19:03:49 +00:00
Tim Neutkens
8a8ef641d8
Update ignored patterns for webpack 4 (#15096)
Found while working on figuring out this bug: https://twitter.com/timneutkens/status/1282129714627448832

 I noticed that the node_modules got passed by the ignore still because when chokidar identifies a ignore pattern is a glob it treats the glob as-is instead of appending `/**` to the glob
2020-07-12 14:03:17 +02:00
JJ Kasper
fed7e093f5
Make sure additional query values aren't added for auto-export (#15037)
This makes sure we don't add an undefined query value for auto-export pages for auto-export pages unnecessarily 

Fixes #15023
2020-07-10 03:16:02 +00:00
Tim Neutkens
525fc360ae
Exclude node_modules in watchOptions (#15020) 2020-07-09 19:58:39 +02:00
Tim Neutkens
096c9a33d2 v9.4.5-canary.31 2020-07-09 16:32:24 +02:00
Tim Neutkens
ab4a90b0d9
Add filename to error in webpack 5 (#14977)
Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com>
2020-07-09 14:31:06 +02:00
Tim Neutkens
10408241f7
Make serverless-plugin compatible with webpack 5 (#15010)
Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>
2020-07-09 14:30:40 +02:00
Darsh Patel
6d7cf2a934
Convert profiling mode from configuration option to CLI switch (#14920)
Removed Option to enable `ReactProductionProfiling` from configuration and added a CLI switch for the same.
Users can now do `next build --profile`  to enable react production profiling. 
Also added a warning to notify users about the performance impact

Fixes: #14688
2020-07-09 11:39:12 +00:00
Jan Potoms
33ebda1b7d
Fix root route optional catch-all prerendering (#14986)
Fixes https://github.com/vercel/next.js/issues/14964
2020-07-09 04:21:49 +00:00
JJ Kasper
62902545df
v9.4.5-canary.30 2020-07-08 14:51:37 -05:00
JJ Kasper
16590f7606
Make sure routeKeys are PCRE compliant (#14987)
This adds additional checks against the routeKeys used to build the named regexes for dynamic routes to ensure they follow PCRE rules for named capture groups

x-ref: https://github.com/vercel/vercel/pull/4813
2020-07-08 18:45:53 +00:00
Joe Haddad
85057e5417
v9.4.5-canary.29 2020-07-07 02:11:43 -04:00
Ty Mick
1f5bbb3a8c
Add warning when viewport meta tag is added to _document.js (#13452)
Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-07-07 01:43:16 -04:00
Jan Potoms
3623d444c1
Fix basepath browser back/forward issue (#14861)
Discovered while working on https://github.com/vercel/next.js/pull/14848

when asPath is the same but href is different it should use `replaceState` instead of `pushState`, so that browser back/forward behavior is preserved. Currently it's comparing a path that includes basepath with one that excludes  it, so `pushState` is always used. This makes sure the behavior is the same as when running next.js without a basepath
2020-07-07 05:24:38 +00:00
Ben Botvinick
d19c34353d
Add res.redirect response helper (#14705)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2020-07-07 01:06:16 -04:00
Jan Potoms
2f78d8858f
basePath: Resolve links against router pathname instead of window.location (#14804)
Currently following links are broken when using `basePath`:
```jsx
// pages/hello.js
    <Link href="#hashlink">
      <a id="hashlink">Hash Link</a>
    </Link>
```
with `basePath: '/docs'`, this will navigate to `/docs/docs/hello#hashlink` instead of `/docs/hello#hashlink`

I have a further optimization that builds on this branch that removes `url.parse` and `url.resolve` in favor for `new URL()` in router and link. Will PR when this gets merged.
2020-07-07 04:52:26 +00:00
Asher Foster
33234ca1f1
Attach previewData to API Route request (#13373)
Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-07-06 23:41:16 -04:00
JJ Kasper
38bd1a024c
Re-enable scroll restoration behind flag (#14046)
This updates the scroll position saving to occur as the scroll position changes instead of trying to do it when the navigation is changing since the `popState` event doesn't allow us to update the leaving history state once the `popState` has occurred. 

The order of events that was previously attempted to save scroll position on a `popState` event (back/forward navigation)

1. history.state is already updated with state from `popState`
2. we replace state with the currently rendered page adding scroll info
3. we replace state again with the `popState` event state overriding scroll info

Using this approach the above event order is no longer in conflict since we don't attempt to populate the state with scroll position while it's leaving the state and instead do it while it is still the active state in history

This approach resembles existing solutions:
https://www.npmjs.com/package/scroll-behavior
https://twitter.com/ryanflorence/status/1029121580855488512

Fixes: https://github.com/vercel/next.js/issues/13990
Fixes: #12530
x-ref: https://github.com/vercel/next.js/pull/14075
2020-07-06 14:27:45 +00:00
matamatanot
62ef872989
Change authors member and links (#14367) 2020-07-05 11:36:50 +02:00
Tim Neutkens
eecc73702b v9.4.5-canary.28 2020-07-03 13:31:38 +02:00
Darsh Patel
e84537f88e
add NextWebVitalsMetric type for reportWebVitals (#14675)
Fixes: #13512
Defined and exported type for `metric`  used in [reportWebVitals](https://nextjs.org/docs/advanced-features/measuring-performance)

```
export function reportWebVitals(metric) {
  if (metric.label === 'custom') {
    console.log(metric) // The metric object ({ id, name, startTime, value, label }) is logged to the console
  }
}
```

One can now do 
```
import { NextWebVitalsMetric } from 'next/app'
export function reportWebVitals(metric: NextWebVitalsMetric ) {
  if (metric.label === 'custom') {
    console.log(metric) // The metric object ({ id, name, startTime, value, label }) is logged to the console
  }
}
```
2020-07-03 03:36:13 +00:00
JJ Kasper
a0c683208a
Fix URL being updated with basePath for 404 page (#14740)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-07-02 11:11:57 +02:00
Jan Potoms
dd97c984b2
Convert link to function component (#14633)
Convert `Link` to a function component. Prefetch logic and memoized url formatting now meshes nicely with React hooks. Class methods were hoisted to module scope to preserve performance characteristics.
2020-07-02 04:53:17 +00:00
JJ Kasper
dc49cd33eb
Update warning for rewriting to auto-export dynamic pages (#14751)
Since the no-op rewrite is a valid rewrite used to check pages/assets before adding a 404-rewrite this makes sure we don't show the rewriting to auto-export dynamic pages warning from it

Closes: https://github.com/vercel/next.js/issues/14736
2020-07-02 04:12:41 +00:00
Jan Potoms
066a18ffc8
Fix basepath root handling (#14756)
Fixes https://github.com/vercel/next.js/issues/14734
2020-07-02 03:48:10 +00:00
Tim Neutkens
9e83ba8cf6 v9.4.5-canary.27 2020-07-01 20:49:52 +02:00
Tim Neutkens
c5cc6072d0
Use single webpack runtimeChunk for Node.js compilation (#14722)
Webpack 5 supports a single runtimechunk for the Node.js compilation, this solves sharing modules between entrypoints.
2020-07-01 15:34:00 +00:00
Tim Neutkens
260707de68
Add etag support for getServerSideProps/getStaticProps pages (#14760)
Fixes #11711

Also cleaned up some extra code.

This was already supported on the Vercel edge network.
2020-07-01 14:59:18 +00:00
JJ Kasper
4a107b6994
v9.4.5-canary.26 2020-06-30 17:21:24 -05:00
JJ Kasper
dd644945ea
Fix encoding for env files in serverless mode (#14750)
This makes sure to base64 encode the `.env*` file contents before passing them in the URL for the serverless-loader since `!` is a special character in this case which can cause webpack to fail to build

Closes: https://github.com/vercel/next.js/issues/14749
2020-06-30 21:33:37 +00:00
Joe Haddad
cbb1c5c755
v9.4.5-canary.25 2020-06-30 11:54:20 -04:00
Joe Haddad
ea1f45a388
Add no-anon-default-export Babel lint rule (#14519)
Fixes #12291 

![image](https://user-images.githubusercontent.com/616428/85499698-176b4900-b5b0-11ea-8a5d-a7f0b4c20307.png)
2020-06-30 13:05:29 +00:00
Yang Sun
a8d2c1ee95
modify global css import error message (#14639)
Fixes #14464
2020-06-30 05:25:02 +00:00
Jan Potoms
ab7010711f
Avoid pulling extra code in the bundles for trailingSlash logic (#14696)
* avoid pulling code in the bundle for `trailingSlash` logic when it's not enabled
* avoid cloning the url an extra time if normalizing the path doesn't change it
2020-06-30 04:06:39 +00:00
Jan Potoms
6ff3a63a2e
Fix link to file url behavior with trailingSlash (#14681)
Avoid trailing slashes on urls that look like files. The redirect for `trailingSlash: true` will now look like:

```
Redirects

┌ source: /:path*/:file.:ext/
├ destination: /:path*/:file.:ext
└ permanent: true

┌ source: /:path*/:notfile([^/.]+)
├ destination: /:path*/:notfile/
└ permanent: true
```

The default still looks like:

```
Redirects

┌ source: /:path+/
├ destination: /:path+
└ permanent: true
```
After this gets merged, I have a few optimizations planned on the normalization code that should reduce the client bundle a little and that consolidates the `trailingSlash` and `exportTrailingSlash` options
2020-06-30 02:25:12 +00:00
Joe Haddad
af901f4366
v9.4.5-canary.24 2020-06-29 17:31:30 -04:00
Joe Haddad
923afd68d4
Upgrade CSSNano Version (#14638)
Fixes #14632
Fixes #14690
2020-06-29 21:29:53 +00:00
Joe Haddad
ac5b2acd12
Fix dynamic route encoding for NextLinks (#14281) 2020-06-29 16:44:43 -04:00
Joe Haddad
1d0e7a8a9a
Enable Optional Catch-All by Default (#14687)
Closes #14682
2020-06-29 18:50:32 +00:00
JJ Kasper
f12a9f92f8
v9.4.5-canary.23 2020-06-29 10:45:40 -05:00
JJ Kasper
89ca0d10d4
Update to use getDataHref in fetchNextData (#14667)
This updates `fetchNextData` to re-use the `getDataHref` function from `page-loader` which has more verbose handling to ensure the correct `/_next/data` URL is built. Re-using this logic ensures the `/_next/data` URL can still be built even when a mismatching `href` and `as` value is provided to `next/link`.

This also fixes a case in `getDataHref` where optional values that weren't provided would fail to build the data href since the check requiring the param be present while interpolating the route values hasn't been updated to allow missing params for optional values.

An additional test case has been added to the prerender suite to ensure the `/_next/data` URL is built correctly when mismatching `href` and `as` values are provided

x-ref: https://github.com/vercel/next.js/discussions/14536
x-ref: https://github.com/vercel/next.js/discussions/9081#discussioncomment-31160
Closes: https://github.com/vercel/next.js/issues/14668
2020-06-29 15:14:45 +00:00
Jan Potoms
b8a30bab55
Handle trailing slashes, even when query parameters (#14650)
Add tests and fix for when the url contains query parameters.
`router` now uses the same method for formatting url+as pair as `Link`, will be able to share code after https://github.com/vercel/next.js/pull/14633 is merged
2020-06-29 14:50:45 +00:00
Tim Neutkens
327f6eed41
Clean up plugins (#14676)
Preparation for a larger rewrite
2020-06-29 14:26:49 +00:00
Tim Neutkens
83de34239c
Convert incremental generation cache to a class (#14660)
We've been meaning to change this code for a while 👍

- Changed the name from spr to incremental
- Changed the code to be a class instead of using module scope variables
2020-06-28 20:58:43 +00:00
Todor Totev
1aed9eaac1
Introduce react profiling production flag (#13873)
Closes [13709](https://github.com/vercel/next.js/issues/13709).

The solution works, **(tested and confirmed with true and false flags with the latest next version)** though I am quite sure this is not the most elegant and proper way to implement it. I have spent the good part of yesterday and today's morning in order to make it more generic but since it's my first time working with anything related to webpack I have struggled miserably. Last, but not least I'm unsure if this is the most proper naming for the flag.

Please, let me know what you want me to change and I'll get it done asap.
2020-06-28 11:23:29 +00:00
Tim Neutkens
479c38d3b7 v9.4.5-canary.22 2020-06-27 20:39:52 +02:00
Tim Neutkens
b4b68c0b85
Use assetEmitted hook instead of afterEmit (#14626)
Makes sure this works correctly with webpack 5.
2020-06-27 17:16:55 +00:00
Jan Potoms
bd24b70d60
Fix trailing slash handling in exporting pages with getStaticPaths (#14620)
Fixes https://github.com/vercel/next.js/issues/14573
2020-06-27 11:59:27 +00:00
Tim Neutkens
3909c76cef v9.4.5-canary.21 2020-06-27 13:11:08 +02:00
JJ Kasper
61b68730f8
De-experimentalize custom-routes (#14602)
This moves the custom-routes configs outside of the experimental section to prepare them for being made stable

Fixes: https://github.com/vercel/next.js/issues/14184
2020-06-27 09:18:18 +00:00
Tim Neutkens
8393869912 v9.4.5-canary.20 2020-06-26 12:05:38 +02:00
Tim Neutkens
ae542b8525
Use entry option instead of custom make hook (#14527)
Simplifies on-demand-entries a bit.
2020-06-26 04:26:09 +00:00
JJ Kasper
3b12dbf488
v9.4.5-canary.19 2020-06-25 15:13:12 -05:00
Jan Potoms
fdcc24be6d
Fix native-url path parsing bug (#14442)
Test case for https://github.com/GoogleChromeLabs/native-url/pull/28

Fix https://github.com/vercel/next.js/issues/14419
2020-06-25 17:19:12 +00:00
Anthony Short
61c4cdb501
Avoid adding basePath when it's not needed (#14535)
* Avoid adding basePath when it's not needed

When using the `basePath` setting, on pages with params it will fire a router change. This will pass the url pathname in the `as` param using the `getUrl()` function. This means the `as` path will be sent through already including the `basePath`, leading to `/basePath/basePath/path` which will cause the router to throw an error.

* lint

* Add test case and ensure removal

* Make sure to re-add before changeState

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-06-24 21:36:22 -05:00
James Mosier
435bf65784
Warn/revert custom devtool in development mode (#14285)
Warn users and revert their `devtool` when they manually change the `devtool` in development mode. For this addition, I check to ensure the `devtool` is custom (i.e. different than what is set by Next) and has a value (`false` is fine as a custom `devtool`!).

As described in [this issue (13963)](https://github.com/vercel/next.js/issues/13963), changing the `devtool` in development mode can cause issues with performance.

Fixes #13963
2020-06-24 04:15:57 +00:00
JJ Kasper
15367829de
v9.4.5-canary.18 2020-06-23 16:04:34 -05:00
JJ Kasper
5bb081f13f
Handle rendering next/head outside of Next.js (#14511)
This ensures `next/head` doesn't fail to render when being rendered during tests or outside of Next.js' tree

Closes: https://github.com/vercel/next.js/issues/14425
2020-06-23 20:46:40 +00:00
Jan Potoms
574e9d285a
Remove deprecated plugin in favor of the option (#14503)
Not sure if it's still there for a reason, but from  the types for `NoEmitOnErrorsPlugin`
```js
/* @deprecated use config.optimization.noEmitOnErrors */
```
2020-06-23 17:44:51 +00:00
Tim Neutkens
be2a63238a
Webpack 5 build compat (#14498)
Initial PR to make `next build` work with webpack 5, still needs more work to make sure runtimeChunk and such are shared between pages.

- No longer needs the custom ChunkNamesPlugin as the default behavior was changed
- Dropping AMP First client page bundles is now compatible
2020-06-23 15:47:50 +00:00
Tim Neutkens
23db226ea5 v9.4.5-canary.17 2020-06-23 13:39:18 +02:00
Jan Potoms
2142b76e6b
Normalize trailing slashes (#13333)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-06-23 13:38:49 +02:00
Jan Potoms
bc2cb2210f
Fix prerendered nested index handling (#14383)
Noticed this while reviewing https://github.com/vercel/next.js/pull/14376. After having done https://github.com/vercel/next.js/pull/13699, this code didn't feel right to me:
```js
function prepareRoute(path: string) {
  path = delBasePath(path || '')
  // this /index rewrite is problematic, it makes pages/index.js 
  // and pages/index/index.js point to the same thing:
  return toRoute(!path || path === '/' ? '/index' : path)
}
```
Added a nested index page to the prerender tests and found it was rendering the `/` route on navigation. This uncovered 2 more places around the dataroute where the index path was not translated correctly.

**edit:**

Just to note that there was nothing wrong with https://github.com/vercel/next.js/pull/14376, the issue was already there, I just noticed it while reading that PR
2020-06-23 05:49:48 +00:00
JJ Kasper
fca768d3d2
Update to rely on dynamic param values from proxy (#12608)
This updates to rely on query values from the proxy when capable to ensure the correct values are provided. This does not remove the `x-now-route-matches` as this is still needed until the values are provided in the query instead for iSSG

x-ref: https://github.com/zeit/now/pull/4196
x-ref: https://github.com/zeit/next.js/pull/12250
x-ref:

Tested against the following updated fixtures from https://github.com/vercel/vercel/pull/4682 with https://github.com/ijjk/next-update-loader

- 08-custom-routes-catchall
- 10-export-cache-headers
- 16-base-path
- 22-ssg-v2
- 23-custom-routes-verbose
2020-06-23 05:31:32 +00:00
Tim Neutkens
1f125f8a7e v9.4.5-canary.16 2020-06-22 23:20:11 +02:00