Commit graph

1034 commits

Author SHA1 Message Date
lindsaylevine
b1a1c80e7c
bug (#21943): remove incorrect rewrite of parsedUrl.pathname in serverless handler (#22445)
Fixes https://github.com/vercel/next.js/issues/21943

i confirmed in a personal test repo that this solves the issue of infinite 307s on root level non-default locales :)  let me know what else this needs if anything! thanks for the time/help @ijjk ❤️
2021-02-25 18:43:51 +00:00
Joe Haddad
775bdc341e
fix: correctly handle fallbacks for webpack 5 (#22497)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-02-24 10:25:57 -06:00
JJ Kasper
51e0752f87
Add generating static 500 status page (#22139)
This adds generating a static 500 status page when a `pages/500.js` file is added similar to how we handle generating static 404 pages when `pages/404.js` is present. This allows showing a customized error page when a 500 error occurs in an optimal way.
2021-02-22 16:29:50 +00:00
Tim Neutkens
9ab98bc956
Reduce webpack watcher aggregate timing (#22418)
Reduces the time the watcher waits for events coming in before compiling.
2021-02-22 14:06:49 +00:00
Tim Neutkens
3cef2e10ed
Delay server compilation until client compilation is done in development (#22187)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-02-19 11:10:19 +01:00
Joe Haddad
99a4ea6e9a
feat(next/image): remove sharp for wasm variant (#22253)
This pull request removes the native `sharp` dependency (which doesn't work on some Linux variants, nor **M1 Mac**) and replaces it with a wasm equivalent.

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

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

This PR still supports:

- Rotation normalization
- Resizing
- PNG
- JPEG
- Webp

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

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

---

Fixes #20456
Closes #20738
Closes #21762
2021-02-18 10:23:24 +00:00
Janicklas Ralph
cf6bc446ea
Experimental feature - fix optimizeCss flag for serverless deployments (#21790) 2021-02-17 22:52:43 +00:00
Kristoffer K
89edd34ff8
fix: register webpack hook earlier and use absolute paths (#21877) 2021-02-16 09:51:52 +01:00
Tim Neutkens
83657b6bce
Check if parentspan is provided in profiler (#22061)
Co-authored-by: Dale Bustad <dale@divmain.com>
2021-02-12 11:17:38 +01:00
JJ Kasper
55e4a3d1ad
Only create locale domain links if on locale domain (#22032)
This updates to only create locale domain links if the current hostname is a locale domain to prevent making links unvisitable in development and preview environments where the configured locale domains don't point to the current build. 

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

Closes: https://github.com/vercel/next.js/issues/20404
2021-02-11 09:55:56 +00:00
Tim Neutkens
6b99bda3e3
Fix profiling plugin for next build (#21989)
Makes sure `yarn trace build` works.
2021-02-09 23:21:38 +00:00
Tim Neutkens
44fa86e384
Make sure all modules are included in the stats file (#21942) 2021-02-07 20:06:41 +01:00
Tim Neutkens
6387f368dc
Update reasons array to use module id instead of identifier (#21895)
Missed this then changing the modules array to rely on `module.id`
2021-02-05 16:39:46 +00:00
Tim Neutkens
15d02f6559
Make experimental stats file approximately 90% smaller (#21858)
Tested against some smaller apps. Will have a high impact for larger apps.
2021-02-04 19:21:54 +00:00
Guy Bedford
234e1c9601
feat: Implement webpack require hook (#21802)
This implements the compatibility require hook as per https://github.com/vercel/next.js/issues/21789.

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

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

I suspect this might have bad interactions with Yarn Pnp support, but maybe we will be lucky.
2021-02-04 08:49:42 +00:00
JJ Kasper
6d80e6e5f3
Add version for stats (#21823)
Adds versioning for the stats output
2021-02-03 20:46:35 +00:00
JJ Kasper
523537178c
Add stats config option (#21761)
This adds a config to output webpack's stats
2021-02-02 15:39:39 +00:00
Janicklas Ralph
8f21c283b2
Experimental feature changes (#21646)
Adding test for experimental-serverless-trace + fix for the same
2021-01-29 13:53:07 +00:00
Dale Bustad
652a1e8915
Improvements to webpack tracing, including hot-reload (#21652)
@timneutkens I think this is ready for a review.

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

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

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

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

Where did those 180 ms go?  At the least, we can now track how long a hot-reload takes, and have a place to start with further investigation.
2021-01-29 10:32:26 +00:00
JJ Kasper
87ed37d51c
Ensure prerender-manifest contains all i18n revalidate values (#21404)
This insures we add entries for each locale version of a non-dynamic SSG page since they can have unique revalidate values. This requires a version bump in the `prerender-manifest` since the static routes now contain additional values which need to be handled separately. 

Fixes: https://github.com/vercel/next.js/issues/21568
2021-01-27 11:24:00 +00:00
Ryan
8798c40c96
Require only build directory to be writeable for build (#20977)
Allows building without permission to write to the application directory, useful for containers and sandboxes.
2021-01-25 12:09:22 -05:00
Chulki Lee
fc34f89a80
Fix hostname message in dev/start (#20409) 2021-01-25 16:13:12 +01:00
Joe Haddad
74b6389bd6
ci: fix webpack 5 enabling for tests (#21436)
* ci: fix webpack 5 enabling for tests

* refactor: move default location

* Disable incompatible suite
2021-01-22 11:20:53 -06:00
JJ Kasper
5b70802f61
Preserve asPath while resolving rewrites (#21410)
* Preserve asPath while resolving rewrites

* remove un-needed alias

* Add new alias

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

---

Closes #21359
2021-01-20 05:25:46 +00:00
Joe Haddad
ab158c0aee
chore: compile resolve-url-loader (#21351)
Closes #21166
2021-01-19 20:08:24 +00:00
Tim Neutkens
85624d6164 Remove console.log 2021-01-19 09:44:03 +01:00
Tim Neutkens
f8fecf57c3
Fix webpack 5 warning + disabling of profiling (#21276)
Noticed that there was a specific warning when using webpack 5.
2021-01-18 16:38:00 +00:00
Tobias Koppers
b02df3f487
improve splitChunks config for webpack 5 (#21208) 2021-01-17 20:05:47 +01:00
Tobias Koppers
9c4d368459
use webpack resolve api to resolve in externals config (#21205) 2021-01-17 20:02:20 +01:00
Gerald Monaco
cd5ea7db1f
Bump minimum suggested React version (#21046)
* Upgrade React version warning

* Fix font/stylesheet plugin

* Fix size-limit tests

* Fix build-output test

* Add tests for React 16

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

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

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

style-loader and css-loader didn't inline easily. Perhaps we can come back to these ones.
2021-01-15 01:51:45 +00:00
Guy Bedford
bddb02286f
feat: webpack inlining with configuration for v4 / v5 (#20598) 2021-01-13 20:59:08 -05:00
JJ Kasper
9caca2784c
Add proper error when conflicting paths are detected (#20918)
This helps catch conflicting paths returned from `getStaticPaths` with a friendly error

<details>

<summary>
Preview of error
</summary>


<img width="962" alt="Screen Shot 2021-01-08 at 5 03 04 PM" src="https://user-images.githubusercontent.com/22380829/104074719-6e481100-51d6-11eb-9397-938aee3ae30b.png">
<img width="962" alt="Screen Shot 2021-01-08 at 5 03 41 PM" src="https://user-images.githubusercontent.com/22380829/104074722-6f793e00-51d6-11eb-90f6-7cdf9882bf00.png">

</details>




Closes: https://github.com/vercel/next.js/issues/19527
2021-01-11 20:50:17 +00:00
Joe Haddad
d0e28549af
feat(css): add strictPostcssConfiguration flag (#20914)
This pull request adds `future.strictPostcssConfiguration`, allowing users to opt-into the more strict PostCSS configuration loading.

This stricter PostCSS configuration loading ensures that CSS can be cached across builds.
2021-01-11 17:19:56 +00:00
Kristoffer K
1c75bf789b
perf(next): use require.resolve instead of resolve (#19518)
**What's the problem this PR addresses?**

- ~~https://github.com/vercel/next.js/pull/18768 started to ncc babel and thus it's version of resolve which breaks PnP support~~
Babel replaced `resolve` with the builtin `require.resolve` and a polyfill for older node versions in https://github.com/babel/babel/pull/12439 which was upgraded in https://github.com/vercel/next.js/pull/20586
- `next` unnecessarily bundles the `resolve` package when `require.resolve` is builtin and can do the same job

**How did you fix it?**

- ~~Avoid running `resolve` through ncc~~
Added a test for https://github.com/vercel/next.js/issues/19334 (closes https://github.com/vercel/next.js/issues/19334)
- Replace `resolve` with `require.resolve`
2021-01-11 14:43:08 +00:00
Kristoffer K
4e3eb733c8
fix(next): always enable absoluteRuntime when running under webpack (#19538)
**What's the problem this PR addresses?**

In https://github.com/vercel/next.js/pull/18921 I enabled `absoluteRuntime` for everyone (it was only enabled for PnP users) but didn't consider that people used the babel preset outside of the webpack build.

Fixes https://github.com/vercel/next.js/issues/19448 - ~~Since it doesn't contain a repro I can't be certain but based on feedback from @koshea in https://github.com/vercel/next.js/pull/18921#issuecomment-733744645 I'll assume @RossMcMillan92 is doing the same thing, because when next is building it doesn't leave absolute paths as external.~~
Confirmed in https://github.com/vercel/next.js/pull/18921#issuecomment-734224014

**How did you fix it?**

Only enable `absoluteRuntime` when the preset is running under `babel-loader`
2021-01-11 14:21:58 +00:00
Hyeon Kim (김지현)
552aa9df1a
Prevent unpredictable dependency hosting by explicitly resolve module path on webpack.ProvidePlugin (#20971)
ProvidePlugin replaces certain identifiers with another modules. As a result, 'buffer' and 'process' modules are added as implicit dependencies to all Next.js plugins. This can be problematic. With "Plug'n'Play" strategy, it don't work at all since they fail-fast with implicit dependencies. With "node_modules" strategy, it might seem OK but actually it can be result into unpredictable behavior since in uses dependency [hoisting](https://yarnpkg.com/advanced/lexicon#hoisting).

For example, currently users cannot use next-auth plugin with Plug'n'Play strategy:

![image](https://user-images.githubusercontent.com/4435445/103481517-d5547700-4e1e-11eb-9f23-bc2c9939418e.png)

This patch let Next.js properly handles such cases with `require.resolve`.

Closes https://github.com/vercel/next.js/issues/20955

###### References:
- https://github.com/nextauthjs/next-auth/pull/1034
2021-01-11 12:31:31 +00:00
Tim Neutkens
90ad2cbc44
Update profiling approach to cover webpack runs (#20900) 2021-01-09 20:12:13 -05:00
JJ Kasper
991ad9225a
Update error for mis-matching path in getStaticPaths (#20767)
This updates the error shown when a path doesn't match the dynamic route in `getStaticPaths` to not include the `locale` since this isn't considered when matching against the dynamic route.
2021-01-06 10:27:32 +00:00
Joe Haddad
58ea3bb479
fix(next/babel): read env from caller, not process (#20679)
This PR fixes a bug where `next/babel` would accidentally enable development transforms for a production build (`next build`).

This is tested by the two updated unit tests (which removed a workaround for this bug, and one now properly enables dev transforms).

---

Fixes #18929
Fixes #19001
x-ref #19046
x-ref #17032
2021-01-02 00:36:16 +00:00
Joe Haddad
984ac96dc6
chore: remove old traces of next/data experiment (#20678)
This PR removes some left over traces of the `next/data` experiment, as it has been superseded by RSC.
2021-01-01 22:23:42 +00:00
Joe Haddad
2c75fa0d9e
fix(source map): correctly generate source maps (#20672)
Fixes #20500
2021-01-01 20:30:50 +00:00
JJ Kasper
9c8d04654e
Ensure all entries are cleared from cache on runtime change (#20652) 2021-01-01 12:39:39 -05:00
JJ Kasper
5324e8b6ee
Ensure SSG data 404 handles correctly for non-notFound (#20622)
Follow-up to https://github.com/vercel/next.js/pull/20594 this ensures non-notFound SSG data 404s do cause a hard navigation as this signals a new deployment has occurred and a hard navigation will load the new deployment's version of the page. 

Closes: https://github.com/vercel/next.js/issues/20623
2020-12-30 22:35:02 +00:00
JJ Kasper
75509164ab
Ensure domain locales are redirected client-side (#20562)
This ensures we detect domain specific locales and redirect them client-side. Tests have been added in the `i18n` suite to ensure the domain redirect is applied correctly during a client-side navigation

Fixes: https://github.com/vercel/next.js/issues/19174
2020-12-30 06:44:07 +00:00
Tim Neutkens
5c5108fe0d
Add profiling to webpack loaders (#20392)
Follow-up to #20357 with additional tracers.
2020-12-29 21:21:35 +00:00
Joe Haddad
61e7dea918
deps: upgrade various deps (mainly babel) (#20586)
Fixes #20585
Closes #20406 as it duplicates Babel dependencies
Closes #18926 as it's outdated
2020-12-29 20:10:08 +00:00