Commit graph

2723 commits

Author SHA1 Message Date
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
cargallo
aec37fa8f1
how to bundle-analyzer with next-compose-plugins (#15370)
Added a section in readme with the proper use of the plugin with next-compose-plugins ^2.0.0, otherwise it doesn't work
2020-08-16 15:25:51 +00: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
Tim Neutkens
16345f631e
Add codemod documentation (#16067)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-08-11 15:12:00 +02: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
7acfd7eea7
Add files array to @next/codemod (#16049) 2020-08-10 16:24:01 +02:00
Joe Haddad
06d0ba4199
Fix typos in @next/codemod CLI (#16042) 2020-08-10 15:09:47 +02:00