Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
instanceOf: disable dev instanceOf checks if NODE_ENV not set #4188
base: main
Are you sure you want to change the base?
instanceOf: disable dev instanceOf checks if NODE_ENV not set #4188
Changes from 1 commit
b1daf03
9654570
079409e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test
anddevelopment
should both invoke the non-production behavior.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To minimize the size of this PR, I'd personally rewrite this to just:
Then the lower lines in this PR shouldn't be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9654570
so this is now:
retaining the check to see whether process is defined globally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JoviDeCroock/graphql-minifier-experiments#1
I have not gone through all the bundlers, but I think that flipping the default would require us changing our instructions about what to set globalThis.process to, now we would have to set to null
https://github.com/graphql/graphql-js/blob/16.x.x/website/docs/tutorials/going-to-production.md
and if I remember correctly, the reason that is in at all is to support cloudflare.
So I am not sure if I want to move forward with this PR actually.... as if we have a better long-term solution, we should move to that without this intermediate stage......?
@JoviDeCroock @benjie @phryneas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long-term solution: 3 versions of this file - one with the
development
export condition, without any of this logic, one with theproduction
export condition without any of this, and onedefault
that falls back to this (or a similar) solution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phryneas I closed #4221 because once we use an imports map, it becomes tricky to use graphql in browsers in a bundler-free manner. I think unfortunately using the exports map and publishing instanceOf might have the same problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaacovCR What problems are you seeing?
Generally, I'd say that unless we publish only a single file, users will have to adopt import maps, but that's the future of ESM on the web anyways.
PS: see https://github.com/apollographql/apollo-client/blob/main/integration-tests/browser-esm/html/jspm-prepared.html for an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(That said, if we were to continue with #4221, we would need to ship a rolled-up
browser
entry point that didn't referenceimports
- maybe with a separatedevelopment
andproduction
build.To be honest, I don't really think we'd need sub-entrypoint
browser
builds, people who run without a bundler probably don't care about saving bundlesize anyways.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure if we want to require the use of an import map but I would definitely defer to @JoviDeCroock on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phryneas Import maps are still being adopted and imho aren't in a well enough state yet for a reference implementation based on a standard to adopt nor is the spec far along enough for it. My two cents here being that either we remove
instanceof
all together and replace it with a branded symbol/types only approach or we keep the status quo but default to production instead.