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

fix(gatsby): Remove default support for non ESM browsers #36522

Merged
merged 8 commits into from
Sep 7, 2022

Conversation

marvinjude
Copy link
Contributor

@marvinjude marvinjude commented Sep 2, 2022

Description

Drop default support for non-esm browsers in v5

[sc-52423]

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Sep 2, 2022
@marvinjude marvinjude marked this pull request as ready for review September 2, 2022 10:57
Copy link
Contributor

@imjoshin imjoshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests to packages/gatsby/src/utils/__tests__/browserslist.js ?

@imjoshin imjoshin added topic: performance Related to runtime & build performance and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Sep 2, 2022
marvinjude and others added 2 commits September 6, 2022 11:37
Co-authored-by: Ward Peeters <ward@coding-tech.com>
@@ -28,7 +28,14 @@ describe(`browserslist`, () => {

const list = getBrowsersList(BASE)

expect(list).toEqual([`>0.25%`, `not dead`])
if (_CFLAGS_.GATSBY_MAJOR === `5`) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we'll ever get to this point in the tests. Given that CFLAGS are environmental set by the compiler, they won't exist in the tests. I could be wrong, but either way, we won't ever be testing both cases.

Can we add a _CFLAGS_ mock to the setup/teardown? This might need some tweaking, but something like:

let originalCflags
beforeEach(() => {
  originalCflags = _CFLAGS_
  
  # TODO set up mock vars, set them in tests, etc
  _CFLAGS_ = {...}
})

afterEach(() => {
  _CFLAGS_ = originalCflags
})

Copy link
Contributor Author

@marvinjude marvinjude Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do pass in CFLAGS flags to test with babel-preset-gatsby-package.

My thinking is that we'll eventually remove the else block since we'll never hit that when the compile flags becomes 5

cc - @wardpeet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh ok. I won't push too hard on it because the logic is simple, but I'd prefer to have full logic coverage even before the Gatsby 5 launch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: performance Related to runtime & build performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants