Skip to content

Conversation

@dimaMachina
Copy link
Collaborator

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2023

⚠️ No Changeset found

Latest commit: 8339acb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR


// Parse the search string to get url parameters.
var parameters = {};
const parameters = {};
Copy link
Member

@acao acao Mar 4, 2023

Choose a reason for hiding this comment

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

the reason I use var here is for browser compatibility. this file is not transpiled for browsers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file is used for cypress, also every browser now supports let/const

Copy link
Contributor

Choose a reason for hiding this comment

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

It may not matter to this specific, but "every browser now supports [whatever]" does not account for users who are stuck on older versions, for whatever reason, plenty of which are valid. It is important to keep stock of what the actual user environment requirements are, and make them known, rather than silently relying on what "every browser now supports."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't need to teach lessons of usage var keyword in the script file, graphiql is bundled to esm and cjs with es5 target where var is used instead of let/const.

You should avoid using var in your code and give this work for bundlers.

Copy link
Member

@acao acao Mar 19, 2023

Choose a reason for hiding this comment

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

this example script has always been understood as file that is loaded without a bundler. the html may load a cdn bundled version of graphiql, but this code should run in any browser without any transpiler. many of graphiql's users use an approach such as this, just on jsdelivr about 550,000/month are served using the CDN bundle directly like this, and thus no transpiler is used. this would probably be much higher combined with unpkg stats if we had them, and which we now use in our documentation and is commonly referred to in examples when users have issues

Copy link
Collaborator

Choose a reason for hiding this comment

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

const and let have been fully supported by all modern browsers since the death of Internet Explorer, I think it should be fine to make this change: https://caniuse.com/?search=const

@dimaMachina dimaMachina merged commit b901d61 into graphql:main Apr 14, 2023
@dimaMachina dimaMachina deleted the no-var branch April 14, 2023 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants