Commit graph

878 commits

Author SHA1 Message Date
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
Joe Haddad
f921b4f476
Auto enable React's new JSX transform on 17.x (#16603) 2020-09-01 11:29:25 -04: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
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
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
Tim Neutkens
d0754993fc
Add webpack 5 caching for css optimizer (#16467) 2020-08-22 14:16:13 +02: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
Tim Neutkens
b6a2051d49
Solve last mini-css-plugin webpack 5 warning (#16447)
Adds missing context parameter
2020-08-21 15:33:57 +00: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
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
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
Tim Neutkens
dab55b473c
Add serialization for mini-css-plugin webpack 5 caching (#16379) 2020-08-20 12:38:39 +02: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
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
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
Tim Neutkens
bbbbb3502d
Make css-minimizer compatible with webpack 5 (#16250) 2020-08-17 12:59:44 +02: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
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
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
9e65c6a958
Strongly type PageLoader (#16132)
Fixes #16131
2020-08-12 20:42:05 +00: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
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
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
JJ Kasper
b1ef76df31
Fix asPath normalizing for non-dynamic pages (#15960) 2020-08-07 09:01:34 +02:00
Joe Haddad
882288b532
Warn when Fast Refresh is disabled (React <16.10) (#15931) 2020-08-06 10:41:11 -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
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
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
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
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
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
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
Joe Haddad
3d98171dab
Test webpack 5 beta (#15645) 2020-07-29 19:19:32 -04: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
Prateek Bhatnagar
fb81ecb2bd
Font optimizations (#14746)
Co-authored-by: atcastle <atcastle@gmail.com>
2020-07-28 12:19:28 +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
Joe Haddad
a11d99390a
Stabilize Trailing Slash API (#15331)
Closes #15330
2020-07-20 16:16:59 +00:00