Commit graph

981 commits

Author SHA1 Message Date
JJ Kasper
c98db81bf4
Remove import type syntax from core files (#20379)
This removes `import type` usage from our core files since `import type` requires a higher TypeScript version than currently expected.

Fixes: https://github.com/vercel/next.js/issues/19300
2020-12-28 22:04:51 +00:00
JJ Kasper
1203b9082b
Ensure path encoding is handled consistently for prerendered pages (#19135)
This ensures we handle encoding/decoding for SSG prerendered/fallback pages correctly. Since we only encode path delimiters when outputting to the disk we need to match this encoding when building the `ssgCacheKey` to look-up the prerendered pages. This also fixes non-ascii prerendered paths (e.g. 商業日語) not matching correctly. 

This does not resolve 👉  https://github.com/vercel/next.js/issues/10084 and further investigation will be needed before addressing non-ascii paths for non-SSG pages. 

The encoding output was tested against https://tst-encoding-l7amu5b9c.vercel.app/ to ensure the values will match correctly on Vercel. 

Closes: https://github.com/vercel/next.js/issues/17582
Closes: https://github.com/vercel/next.js/issues/17642
x-ref: https://github.com/vercel/next.js/pull/14717
2020-12-28 20:08:58 +00:00
Joe Haddad
5f311cddd2
fix Fast Refresh tests with webpack@5 (#20543) 2020-12-28 14:18:51 -05:00
Joe Haddad
64c1f726e0
Fix webpack 5 terser compat (#20378)
This PR fixes webpack 5 compatibility with older betas.
2020-12-22 02:53:23 +00:00
JJ Kasper
788183e8d3
Ensure only backslashes are in pages-manifest with i18n (#20376)
This ensures the pages-manifest only includes forward slashes and not backslashes when adding i18n page references, this also adds tests ensuring we don't regress on this in the i18n-support test suite. 

Fixes: https://github.com/vercel/next.js/issues/20330
2020-12-22 01:51:51 +00:00
Joe Haddad
260ab51974
temporary: re-flag font optimization (#20372)
There's currently two bugs with the font optimization, but we'd really like to ship a stable version.

To unblock the stable release, we're **temporarily** reflagging this. It'll be unflagged on canary again!
2020-12-21 19:26:00 +00:00
Tim Neutkens
a9f1975738
Update experimental profiling (#20357)
Adds profiling for terser and css-minimizer. Will move the old profiler to this new system as well.
2020-12-21 16:02:41 +00:00
Tim Neutkens
72fae8bed4
Move productionBrowserSourceMaps out of experimental (#20267)
Makes https://www.npmjs.com/package/@zeit/next-source-maps a built-in feature so that it can be deprecated.
2020-12-17 15:04:17 +00:00
JJ Kasper
e819e00d0c
Add required server files manifest (#20035)
This keeps track of required server files in a manifest file
2020-12-16 20:46:55 +00:00
Tim Neutkens
5d5383b263
Update font-stylesheet-gathering-plugin to be webpack 5 compatible (#20229)
Solves the following warning:

> (node:1484) [DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE_FN] DeprecationWarning: MainTemplate.requireFn is deprecated (use "__webpack_require__")
2020-12-16 14:35:50 +00:00
Tim Neutkens
8ed132deb6
Update import to prevent loader from erroring in webpack 5 (#20211)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-12-16 08:56:14 +01:00
Tim Neutkens
81e67ce95e
Update terser-webpack-plugin to support webpack 4 (#20089)
Solves some of the cache warnings when using webpack 5
2020-12-12 20:28:53 +00:00
Tim Neutkens
4bca939ff7
Remove aliases that are no longer needed (#19937)
Fixes #19939
2020-12-07 22:35:28 +00:00
Pepijn Senders
3f730fc7b1
Improve way cache version string is created (#19763)
Nitpicky change, but the version string contained a double `|`, implying that there might be an empty value between `process.env.__NEXT_VERSION` and the environment variables.
2020-12-04 14:08:02 +00:00
JJ Kasper
42385f48db
Ensure i18n custom routes resolves correctly (#19766)
This ensures i81n custom routes are resolving correctly, it also corrects redirects for default locales when `locale: false` is not used, and this also simplifies the resolving for custom routes with i18n in `next-server` adding types for the i18n config. This also adds additional tests to prevent regression and starts leveraging a shared `NextConfig` type to allow us to share types for config values. 

Fixes: https://github.com/vercel/next.js/issues/19521
Fixes: https://github.com/vercel/next.js/issues/19403
Fixes: https://github.com/vercel/next.js/issues/19302
Fixes: https://github.com/vercel/next.js/issues/19227
2020-12-04 10:14:55 +00:00
Prateek Bhatnagar
57e156bc49
Making font optimization as default (#19758)
- Making font optimizations as default
- Re-enabling tests
- Fixes #19159
2020-12-04 09:52:54 +00:00
Jeff Escalante
b86a1731e1
Error Message Clarity (#16052)
* make the error message more clear if webpack config comes back undefined

* Update check and add test

* bump

* Update build-output test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-12-01 15:58:52 -06:00
Janicklas Ralph
c8cd77a856
Script loader component (#18281) 2020-12-01 19:10:16 +01:00
Janicklas Ralph
6e4632efe1
Css optimizations (#16539)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-12-01 19:02:07 +01:00
Guy Bedford
9dd5ff2baa
fix: Revert #18921 and inline absolute babel runtime only for YarnPnp (#19542)
This reverts #18921 and ensures that the Babel runtime is only inlined as an absolute path when using PnP as before, but then including the correction this resolution as implemented by @merceyz only in the PnP cases, while keeping the diff to a minimum.
2020-11-25 22:28:39 +00:00
JJ Kasper
899a29cade
Break up the serverless loader into typed handlers (#19511)
This breaks up the `serverless-loader` into typed handlers to allow for easier maintenance and better type-checking/linting. 

Closes: https://github.com/vercel/next.js/issues/19071
2020-11-25 19:56:18 +00:00
JJ Kasper
8193df5309
Fix serverless with next start error case (#19288)
This fixes the case where we were returning page data when rendering `/_error` in `serverless` mode with `next start`

Closes: https://github.com/vercel/next.js/issues/19068
2020-11-19 16:25:54 +00:00
Joe Haddad
30c2dfdc47
Remove old modern mode experiment (#19275)
This PR removes the modern mode experiment because:

- It does not yield meaningful bundle size wins when compared to other initiatives we've taken
- It's not compatible with webpack 5 (which we're upgrading to)
- It's currently broken and causes most apps to malfunction
- There's no champion currently owning the experiment

We can re-introduce this in the future when we'd like to make it a default for all Next.js apps.

Note: **Next.js still supports Differential Loading (`nomodule`) and does it by default.** This PR strictly removes the experimental modern _syntax_, and does not disable our existing modern/legacy polyfilling.

---

Fixes #19200
Fixes #18960
Fixes #14707
Fixes #14465
2020-11-18 18:30:00 +00:00
Joe Haddad
61c3db7368
Fix minifying inline CSS comments (#19167)
We accidentally regressed back in 9.5 and dropped support for inline CSS comments. PostCSS always parses these as pass-through (and not a syntax error), which can cause problems when minifying.

Browsers do a similar thing and ignore the comments.

To ensure we generate valid CSS, this adds support for stripping the CSS comments from the build.

--- 

Fixes #15589
Closes #17130
2020-11-14 15:03:04 +00:00
JJ Kasper
1e61b69e31
Add locale: false for custom-routes + i18n (#19164)
This mirrors the `basePath: false` behavior for custom-routes with `locale: false` to allow users to configure the locales manually (`locale: false`) or have the locales be handled automatically for custom-routes. 

Fixes: https://github.com/vercel/next.js/issues/18927
Fixes: https://github.com/vercel/next.js/issues/18795
2020-11-14 03:35:42 +00:00
Joe Haddad
415d7fd75e
Respect next/babel user provided runtime option (#19136) 2020-11-13 02:41:54 -05:00
JJ Kasper
4866c47d9d
Ensure optional catchall prerendered indexes and i18n (#19116)
This ensures root optional-catch-all index routes with i18n are output to the correct location and are also loaded from the `prerender-manifest` correctly. 

Fixes: https://github.com/vercel/next.js/issues/19095
2020-11-12 18:50:32 +00:00
JJ Kasper
54b70425ab
Ensure i18n with basePath works properly (#19083) 2020-11-12 00:26:48 -05:00
JJ Kasper
41866a135c
Add experimental Next.js plugin version locking (#19084) 2020-11-11 23:59:57 -05:00
JJ Kasper
d1036539d6
Ensure params and locale are parsed correctly in fallback mode (#19063)
This fixes a few things related to optional catch-all routes and i18n. The first thing is it ensures the correct data route is generated on the client so that the locale isn't duplicated for an optional catch-all route, the next is it ensures the browser history is updated correctly when only a locale change is occurring, and then it also ensures we handle the locales and normalizing for fallback optional catch-all pages correctly.

Tests have been added to ensure these cases are covered properly and we don't regress on them, these changes were also tested on Vercel [here](https://next-js-bug-i18n-root-params-nybg44l0b.vercel.app/)

Fixes: https://github.com/vercel/next.js/issues/18633 
Fixes: https://github.com/vercel/next.js/issues/19059
2020-11-11 20:33:44 +00:00
Steven
917d594ca8
Print error during next export with default image loader (#19032)
Fixes #18356
2020-11-11 15:46:48 +00:00
Kristoffer K
d40d7d6562
fix(next): resolve absolute path to @babel/runtime (#18921)
**What's the problem this PR addresses?**

https://github.com/vercel/next.js/pull/18768 started to ncc `@babel/plugin-transform-runtime` which broke its Yarn PnP support since the version of `resolve` it uses can't be patched by Yarn.

Fixes https://github.com/yarnpkg/berry/runs/1359235077?check_suite_focus=true#step:5:79

cc @guybedford

**How did you fix it?**

Resolve the absolute path to `@babel/runtime` so it doesn't have to go through `resolve`

---

Fixes https://github.com/vercel/next.js/issues/19026
2020-11-11 15:18:33 +00:00
JJ Kasper
48acc479f3
Ensure basePath behavior with GS(S)P redirect (#18988)
This ensures we match the `basePath` handling for redirects in `next.config.js` with redirects from `getStaticProps` and `getServerSideProps` and also adds a separate test suite to ensure GS(S)P redirects with `basePath` work correctly

Fixes: https://github.com/vercel/next.js/issues/18984
Closes: https://github.com/vercel/next.js/pull/18892
2020-11-11 07:13:18 +00:00
JJ Kasper
a429a47fe0
Ensure correct defaultLocale is provided for locale domain (#19040)
This ensures we use the `defaultLocale` for a locale domain when rendering non-static pages. Static pages will initially contain the global `defaultLocale` and then be updated on the client since we don't currently prerender a version of the pages for each locale domain. 

Closes: https://github.com/vercel/next.js/issues/18970
2020-11-11 02:09:45 +00:00
Lyderic Dutillieux
50400f7eeb
Fixed wrong function name in error message (#19034)
Changed function name from "getStaticProps" to "getStaticPaths" in Exception message thrown when 'paths' is invalid.
2020-11-10 23:53:08 +00:00
Guy Bedford
8221c180a5
ncc 0.25.0 upgrade and fixes (#18873)
This upgrades to ncc@0.25.0 and fixes the previous bugs including:

* ncc not referenced correctly in build
* Babel type errors
* node-fetch, etag, chalk and raw-body dependencies not building with ncc - these have been "un-ncc'd" for now. As they are relatively small dependencies, this doesn't seem too much of an issue and we can follow up in the tracking ncc issue at https://github.com/vercel/ncc/issues/612.
* `yarn dev` issues

Took a lot of bisecting, but the overall diff isn't too bad here in the end.
2020-11-06 02:33:14 +00:00
Guy Bedford
4dbb65d0f1
yarn dev regression fix, ncc revert (#18861)
This fixes the current regression with an ncc revert for now.

I will continue to follow up with the ncc upgrade in https://github.com/vercel/next.js/pull/18860.
2020-11-06 00:47:31 +00:00
Guy Bedford
64850a8348
ncc Babel inlining (#18768)
This adds inlining for Babel and the Babel plugins used in next.

This is based to the PR at https://github.com/vercel/next.js/pull/18823.

The approach is to make one large bundle and then separate out the individual packages from that in order to avoid duplications.

In the first attempt the Babel bundle size was 10MB... using "resolutions" in the Yarn workspace to reduce the duplicated packages this was brought down to a 2.8MB bundle for Babel and all the used plugins which is exactly the expected file size here.

This will thus add a 2.8MB download size to the next package, but save downloading any babel dependencies separately, removing a large number of package dependencies from the overall install.
2020-11-05 14:23:01 +00:00
JJ Kasper
a5cb28d907
Ensure redirects are handled properly from cache (#18806)
This updates the GS(S)P redirect handling to make sure to handle redirects correctly when coming from the incremental-cache. Additional tests have been added to ensure the redirects work correctly after the cache is populated. 

Fixes: https://github.com/vercel/next.js/issues/18735
Fixes: https://github.com/vercel/next.js/issues/18783
2020-11-04 22:18:44 +00:00
Guy Bedford
a1ea352911
Remove @babel/preset-modules (#18759)
This is a prerequisite to being able to ncc inline the Babel dependencies in next.js.

The removal of preset-modules is based on replacing it with preset-env under `targets: { esmodules: true }`, as per the guidance from the package (https://www.npmjs.com/package/@babel/preset-modules):

> Starting from @babel/preset-env 7.9.0, you can enable the bugfixes: true option to get the same behavior as using @babel/preset-modules, but with support for custom targets. If you need to target browsers with native modules support (like this preset does), you can use targets: { esmodules: true }.

From the above, I'm pretty sure this is entirely a backwards compatible change, apart from the change to the runtime plugin list being visible. Perhaps @developit can confirm this as well.
2020-11-04 06:53:39 +00:00
JJ Kasper
7b6a61a750
Ensure correct locale is used for non-prefixed path (#18708)
When visiting a non-locale prefixed path (`/hello` instead of `/fr/hello`) we don't trigger locale redirects currently so if another locale is matched we need to ensure this is reset to the `defaultLocale` for rendering to prevent a mis-match on the client and the server.

This also fixes hydration errors from occurring with `asPath` for `getServerSideProps` pages due to `normalizeLocalePath` expecting only a pathname and `asPath` containing `hash` and `query values also. 

Fixes: https://github.com/vercel/next.js/issues/18337
Fixes: https://github.com/vercel/next.js/issues/18510
2020-11-02 23:00:41 +00:00
JJ Kasper
a8d8f9aef9
Ensure localeDetection: false doesn't detect from header (#18695)
This ensures we don't detect the locale from the header when `localeDetection` is set to `false`

Fixes: https://github.com/vercel/next.js/issues/18482
2020-11-02 21:02:15 +00:00
JJ Kasper
faf4a0ab80
Ensure getStaticProps isn't called without params with i18n (#18702)
This corrects additional fallback pages being generated without the fallback flag causing `getStaticProps` to be called without params with i18n. The revalidation aspect of the issue has been corrected separately in https://github.com/vercel/next.js/pull/18569

Fixes: https://github.com/vercel/next.js/issues/18404
2020-11-02 20:41:34 +00:00
Carmelo Scandaliato
197d46ddb9
Remove the static optimization indicator (#18629)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-11-02 09:27:36 +01:00
JJ Kasper
fb07e95847
Ensure correct params are used with i18n revalidation (#18569)
This makes sure we don't use invalid `x-now-route-matches` which can occur when `i18n` default locale is visited and a prerendered page is matched. To correct this we first check if we are able to derive the correct params from the URL and then bail on parsing `x-now-route-matches` if we are. Additional test cases are being added in the builder to ensure we don't regress on this

x-ref: https://github.com/vercel/next.js/discussions/18443
Fixes #18602
2020-11-01 04:49:48 +00:00
JJ Kasper
4263318836
Ensure i18n context values are provided for blocking 404 (#18513)
This ensures we provide the current `locale`, `locales`, and `defaultLocale` in the context when rendering the 404 for a blocking SSG page

Fixes: https://github.com/vercel/next.js/issues/18505
2020-10-30 01:42:28 +00:00
Joe Haddad
9a13dd3466
Enable i18n feature flag (#18303) 2020-10-27 10:30:34 -05:00
JJ Kasper
0f25051470
Ensure getStaticProps is called for SSG 404 in blocking mode (#18300)
This ensures that when using a `pages/404` file with `getStaticProps` that we call `getStaticProps` in `fallback: 'blocking'` mode

Fixes: https://github.com/vercel/next.js/issues/18293
2020-10-27 15:11:51 +00:00
JJ Kasper
26c438b49d
Record leveraged configs (#18175)
This records new configs being leveraged
2020-10-27 13:46:18 +00:00
Steven
f773a1a44a
Rename iconSizes to imageSizes, remove size limitation (#18294)
This does two things:

- Rename `iconSizes` to `imageSizes`.
- Give priority to `imageSizes` regardless of `deviceSizes` as a means to opt-out of the srcset behavior.
2020-10-27 13:19:23 +00:00