From 5131459f0985437bb71a3713d8e4d31904eac4fc Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Thu, 1 Sep 2022 13:26:58 +0100 Subject: [PATCH 1/7] update default browserlist --- packages/gatsby/src/utils/browserslist.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/gatsby/src/utils/browserslist.ts b/packages/gatsby/src/utils/browserslist.ts index aa841976f9966..51eb81f86d9fa 100644 --- a/packages/gatsby/src/utils/browserslist.ts +++ b/packages/gatsby/src/utils/browserslist.ts @@ -18,10 +18,17 @@ const installedGatsbyVersion = (directory: string): number | undefined => { } export const getBrowsersList = (directory: string): Array => { + const fallbackV1 = [`>1%`, `last 2 versions`, `IE >= 9`] + let fallbackOthers = [`>0.25%`, `not dead`] + + if (true) { + fallbackOthers = fallbackOthers.map( + fallback => fallback + ` and supports es6-module` + ) + } + const fallback = - installedGatsbyVersion(directory) === 1 - ? [`>1%`, `last 2 versions`, `IE >= 9`] - : [`>0.25%`, `not dead`] + installedGatsbyVersion(directory) === 1 ? fallbackV1 : fallbackOthers const config = browserslist.findConfig(directory) From d7c2311065e84302ec3b32ff67b19b77368dae43 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Fri, 2 Sep 2022 11:45:17 +0100 Subject: [PATCH 2/7] add condition --- packages/gatsby/src/utils/browserslist.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/browserslist.ts b/packages/gatsby/src/utils/browserslist.ts index 51eb81f86d9fa..6c80e031c1e96 100644 --- a/packages/gatsby/src/utils/browserslist.ts +++ b/packages/gatsby/src/utils/browserslist.ts @@ -21,7 +21,7 @@ export const getBrowsersList = (directory: string): Array => { const fallbackV1 = [`>1%`, `last 2 versions`, `IE >= 9`] let fallbackOthers = [`>0.25%`, `not dead`] - if (true) { + if (installedGatsbyVersion(directory) === 5) { fallbackOthers = fallbackOthers.map( fallback => fallback + ` and supports es6-module` ) From 0500f00ed87a8c2e53113d894907e2216cad06cc Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Mon, 5 Sep 2022 09:26:08 +0100 Subject: [PATCH 3/7] Update packages/gatsby/src/utils/browserslist.ts Co-authored-by: Ward Peeters --- packages/gatsby/src/utils/browserslist.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/browserslist.ts b/packages/gatsby/src/utils/browserslist.ts index 6c80e031c1e96..b6d0e482a0c74 100644 --- a/packages/gatsby/src/utils/browserslist.ts +++ b/packages/gatsby/src/utils/browserslist.ts @@ -21,7 +21,7 @@ export const getBrowsersList = (directory: string): Array => { const fallbackV1 = [`>1%`, `last 2 versions`, `IE >= 9`] let fallbackOthers = [`>0.25%`, `not dead`] - if (installedGatsbyVersion(directory) === 5) { + if ( _CFLAGS_.MAJOR === '5') { fallbackOthers = fallbackOthers.map( fallback => fallback + ` and supports es6-module` ) From a11acc89b59bce35aba377b7e20d22290a692b81 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 6 Sep 2022 08:10:07 +0100 Subject: [PATCH 4/7] use correct CFLAG --- packages/gatsby/src/utils/browserslist.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/browserslist.ts b/packages/gatsby/src/utils/browserslist.ts index b6d0e482a0c74..9b06bd6168a44 100644 --- a/packages/gatsby/src/utils/browserslist.ts +++ b/packages/gatsby/src/utils/browserslist.ts @@ -21,7 +21,7 @@ export const getBrowsersList = (directory: string): Array => { const fallbackV1 = [`>1%`, `last 2 versions`, `IE >= 9`] let fallbackOthers = [`>0.25%`, `not dead`] - if ( _CFLAGS_.MAJOR === '5') { + if (_CFLAGS_.GATSBY_MAJOR === `5`) { fallbackOthers = fallbackOthers.map( fallback => fallback + ` and supports es6-module` ) From b22dcea5d265f06805128c856de46e43c2b637c0 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 6 Sep 2022 11:05:18 +0100 Subject: [PATCH 5/7] add test --- packages/gatsby/src/utils/__tests__/browserslist.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/__tests__/browserslist.js b/packages/gatsby/src/utils/__tests__/browserslist.js index 2b37953e10f30..d8967ddd4dfad 100644 --- a/packages/gatsby/src/utils/__tests__/browserslist.js +++ b/packages/gatsby/src/utils/__tests__/browserslist.js @@ -28,7 +28,12 @@ describe(`browserslist`, () => { const list = getBrowsersList(BASE) - expect(list).toEqual([`>0.25%`, `not dead`]) + if (_CFLAGS_.GATSBY_MAJOR === `5`) + expect(list).toEqual([ + `>0.25% and supports es6-module`, + `not dead and supports es6-module`, + ]) + else expect(list).toEqual([`>0.25%`, `not dead`]) }) it(`hasES6ModuleSupport returns true if all browsers support es6 modules`, () => { From 8b73eb5888af560c7b24c380dfdb8b38072aa430 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 6 Sep 2022 11:37:24 +0100 Subject: [PATCH 6/7] Update packages/gatsby/src/utils/__tests__/browserslist.js Co-authored-by: Ward Peeters --- packages/gatsby/src/utils/__tests__/browserslist.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/utils/__tests__/browserslist.js b/packages/gatsby/src/utils/__tests__/browserslist.js index d8967ddd4dfad..ac8dddb1bec71 100644 --- a/packages/gatsby/src/utils/__tests__/browserslist.js +++ b/packages/gatsby/src/utils/__tests__/browserslist.js @@ -28,12 +28,14 @@ describe(`browserslist`, () => { const list = getBrowsersList(BASE) - if (_CFLAGS_.GATSBY_MAJOR === `5`) + if (_CFLAGS_.GATSBY_MAJOR === `5`) } expect(list).toEqual([ `>0.25% and supports es6-module`, `not dead and supports es6-module`, ]) - else expect(list).toEqual([`>0.25%`, `not dead`]) + } else { + expect(list).toEqual([`>0.25%`, `not dead`]) + } }) it(`hasES6ModuleSupport returns true if all browsers support es6 modules`, () => { From eea8513af6cda62c6edc65080716445e86247e46 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 6 Sep 2022 12:03:53 +0100 Subject: [PATCH 7/7] lint fix --- packages/gatsby/src/utils/__tests__/browserslist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/src/utils/__tests__/browserslist.js b/packages/gatsby/src/utils/__tests__/browserslist.js index ac8dddb1bec71..0014f4003cff3 100644 --- a/packages/gatsby/src/utils/__tests__/browserslist.js +++ b/packages/gatsby/src/utils/__tests__/browserslist.js @@ -28,7 +28,7 @@ describe(`browserslist`, () => { const list = getBrowsersList(BASE) - if (_CFLAGS_.GATSBY_MAJOR === `5`) } + if (_CFLAGS_.GATSBY_MAJOR === `5`) { expect(list).toEqual([ `>0.25% and supports es6-module`, `not dead and supports es6-module`,