Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fallback locale for locale: false #19322

Merged
merged 4 commits into from Nov 20, 2020

Conversation

ijjk
Copy link
Member

@ijjk ijjk commented Nov 19, 2020

This updates the fallback locale for locale: false to be the defaultLocale instead of the currently active locale as it allows passing through URLs more seamlessly as a URL without the locale prefixed can be treated as the defaultLocale instead of having to worry if the locale matches the currently active locale. This also ensures locale={false} is tested in the i18n-support-catchall suite

Closes: #19048

@ijjk
Copy link
Member Author

ijjk commented Nov 19, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
buildDuration 12.5s 12.2s -345ms
nodeModulesSize 84.9 MB 84.9 MB
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
/ failed reqs 0 0
/ total time (seconds) 2.907 2.81 -0.1
/ avg req/sec 859.99 889.56 +29.57
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.901 1.882 -0.02
/error-in-render avg req/sec 1315.32 1328.46 +13.14
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
677f882d2ed8..4972.js gzip 12.7 kB 12.7 kB
framework.HASH.js gzip 39 kB 39 kB
main-f1a49fb..e45e.js gzip 6.52 kB 6.52 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 58.9 kB 58.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_app-3b0cf13..85f8.js gzip 1.28 kB 1.28 kB
_error-6f635..c393.js gzip 3.44 kB 3.44 kB
hooks-d4ffc3..9e0f.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-b618194..5477.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
index.html gzip 613 B 613 B
link.html gzip 621 B 621 B
withRouter.html gzip 608 B 608 B
Overall change 1.84 kB 1.84 kB

Serverless Mode
General
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
buildDuration 14.7s 14.2s -464ms
nodeModulesSize 84.9 MB 84.9 MB
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
677f882d2ed8..4972.js gzip 12.7 kB 12.7 kB
framework.HASH.js gzip 39 kB 39 kB
main-f1a49fb..e45e.js gzip 6.52 kB 6.52 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 58.9 kB 58.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_app-3b0cf13..85f8.js gzip 1.28 kB 1.28 kB
_error-6f635..c393.js gzip 3.44 kB 3.44 kB
hooks-d4ffc3..9e0f.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-b618194..5477.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_error.js 914 kB 914 kB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 915 kB 915 kB
link.js 973 kB 973 kB
routerDirect.js 966 kB 966 kB
withRouter.js 966 kB 966 kB
Overall change 4.74 MB 4.74 MB
Commit: 5eefaf8

@vercel vercel bot temporarily deployed to Preview November 20, 2020 00:55 Inactive
@ijjk ijjk changed the title Add test for prefetch with locale false Update fallback locale for locale: false Nov 20, 2020
@ijjk
Copy link
Member Author

ijjk commented Nov 20, 2020

Stats from current PR

Default Server Mode (Decrease detected ✓)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
buildDuration 8s 8.3s ⚠️ +317ms
nodeModulesSize 84.9 MB 84.9 MB ⚠️ +170 B
Page Load Tests Overall decrease ⚠️
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
/ failed reqs 0 0
/ total time (seconds) 1.903 1.869 -0.03
/ avg req/sec 1313.55 1337.32 +23.77
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.063 1.095 ⚠️ +0.03
/error-in-render avg req/sec 2352.81 2283.61 ⚠️ -69.2
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
677f882d2ed8..4972.js gzip 12.7 kB 12.7 kB
framework.HASH.js gzip 39 kB 39 kB
main-f1a49fb..e45e.js gzip 6.52 kB 6.52 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 58.9 kB 58.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_app-3b0cf13..85f8.js gzip 1.28 kB 1.28 kB
_error-6f635..c393.js gzip 3.44 kB 3.44 kB
hooks-d4ffc3..9e0f.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-b618194..5477.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
index.html gzip 613 B 613 B
link.html gzip 621 B 621 B
withRouter.html gzip 608 B 607 B -1 B
Overall change 1.84 kB 1.84 kB -1 B

Diffs

Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4d7272f0989b253f541e.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.53ed52b19aad40ca987b.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4d7272f0989b253f541e.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.53ed52b19aad40ca987b.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4d7272f0989b253f541e.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.53ed52b19aad40ca987b.js"
       as="script"
     />
     <link
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4d7272f0989b253f541e.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.53ed52b19aad40ca987b.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4d7272f0989b253f541e.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.53ed52b19aad40ca987b.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4d7272f0989b253f541e.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.53ed52b19aad40ca987b.js"
       async=""
     ></script>
     <script

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
buildDuration 9.7s 9.4s -273ms
nodeModulesSize 84.9 MB 84.9 MB ⚠️ +170 B
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
677f882d2ed8..4972.js gzip 12.7 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-f1a49fb..e45e.js gzip 6.52 kB 6.52 kB
webpack-e067..f178.js gzip 751 B 751 B
677f882d2ed8..fbcb.js gzip N/A 12.7 kB N/A
Overall change 58.9 kB 58.9 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_app-3b0cf13..85f8.js gzip 1.28 kB 1.28 kB
_error-6f635..c393.js gzip 3.44 kB 3.44 kB
hooks-d4ffc3..9e0f.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-b618194..5477.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_error.js 914 kB 914 kB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 915 kB 915 kB
link.js 973 kB 973 kB
routerDirect.js 966 kB 966 kB
withRouter.js 966 kB 966 kB
Overall change 4.74 MB 4.74 MB
Commit: f0b1d6d

@vercel vercel bot temporarily deployed to Preview November 20, 2020 21:26 Inactive
@ijjk
Copy link
Member Author

ijjk commented Nov 20, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
buildDuration 11.3s 11.3s ⚠️ +16ms
nodeModulesSize 84.9 MB 84.9 MB ⚠️ +170 B
Page Load Tests Overall increase ✓
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
/ failed reqs 0 0
/ total time (seconds) 2.662 2.625 -0.04
/ avg req/sec 939.23 952.3 +13.07
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.655 1.641 -0.01
/error-in-render avg req/sec 1510.36 1523.01 +12.65
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
677f882d2ed8..005c.js gzip 12.8 kB 12.8 kB
framework.HASH.js gzip 39 kB 39 kB
main-9cc22a8..b04f.js gzip 6.53 kB 6.53 kB
webpack-e067..f178.js gzip 751 B 751 B
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_app-3b0cf13..85f8.js gzip 1.28 kB 1.28 kB
_error-6f635..c393.js gzip 3.44 kB 3.44 kB
hooks-d4ffc3..9e0f.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-b618194..5477.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
index.html gzip 615 B 615 B
link.html gzip 622 B 622 B
withRouter.html gzip 608 B 609 B ⚠️ +1 B
Overall change 1.84 kB 1.85 kB ⚠️ +1 B

Diffs

Diff for 677f882d2ed8..e9e6fd1d6.js
@@ -1792,7 +1792,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               break;
                             }
 
-                            this.locale = options.locale || this.locale;
+                            this.locale =
+                              options.locale === false
+                                ? this.defaultLocale
+                                : options.locale || this.locale;
 
                             if (typeof options.locale === "undefined") {
                               options.locale = this.locale;
Diff for index.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2fcbf4190ae9e6fd1d6.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8592ecbddd5517e7e4f9.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2fcbf4190ae9e6fd1d6.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8592ecbddd5517e7e4f9.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2fcbf4190ae9e6fd1d6.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8592ecbddd5517e7e4f9.js"
       as="script"
     />
     <link
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2fcbf4190ae9e6fd1d6.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8592ecbddd5517e7e4f9.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2fcbf4190ae9e6fd1d6.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8592ecbddd5517e7e4f9.js"
       as="script"
     />
     <link
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2fcbf4190ae9e6fd1d6.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8592ecbddd5517e7e4f9.js"
       async=""
     ></script>
     <script

Serverless Mode
General Overall increase ⚠️
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
buildDuration 13.2s 13.4s ⚠️ +234ms
nodeModulesSize 84.9 MB 84.9 MB ⚠️ +170 B
Client Bundles (main, webpack, commons)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
677f882d2ed8..005c.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-9cc22a8..b04f.js gzip 6.53 kB 6.53 kB
webpack-e067..f178.js gzip 751 B 751 B
677f882d2ed8..8b81.js gzip N/A 12.8 kB N/A
Overall change 59 kB 59 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
polyfills-4b..e242.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_app-3b0cf13..85f8.js gzip 1.28 kB 1.28 kB
_error-6f635..c393.js gzip 3.44 kB 3.44 kB
hooks-d4ffc3..9e0f.js gzip 887 B 887 B
index-17468f..5d83.js gzip 227 B 227 B
link-b618194..5477.js gzip 1.61 kB 1.61 kB
routerDirect..924c.js gzip 284 B 284 B
withRouter-7..c13d.js gzip 284 B 284 B
Overall change 8.01 kB 8.01 kB
Client Build Manifests
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles
vercel/next.js canary ijjk/next.js i18n/prefetch-locale-false Change
_error.js 915 kB 915 kB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 915 kB 915 kB
link.js 973 kB 973 kB
routerDirect.js 966 kB 966 kB
withRouter.js 966 kB 966 kB
Overall change 4.74 MB 4.74 MB
Commit: 84fbb79

@kodiakhq kodiakhq bot merged commit e173780 into vercel:canary Nov 20, 2020
kamermans pushed a commit to kamermans/next.js that referenced this pull request Dec 14, 2020
This updates the fallback locale for `locale: false` to be the `defaultLocale` instead of the currently active `locale` as it allows passing through URLs more seamlessly as a URL without the locale prefixed can be treated as the `defaultLocale` instead of having to worry if the locale matches the currently active locale. This also ensures `locale={false}` is tested in the i18n-support-catchall suite

Closes: vercel#19048
@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prefetch in combination with i18n and next/link locale:false result in 404 of defaultLocale
2 participants