-
Notifications
You must be signed in to change notification settings - Fork 2k
instanceOf: disable dev instanceOf checks if NODE_ENV not set #4188
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
base: next
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { inspect } from './inspect.js'; | ||
|
||
/* c8 ignore next 3 */ | ||
const isProduction = | ||
const isDevelopment = | ||
globalThis.process != null && | ||
// eslint-disable-next-line no-undef | ||
process.env.NODE_ENV === 'production'; | ||
process.env.NODE_ENV === 'development'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: const isProduction = process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'test'; Then the lower lines in this PR shouldn't be needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this is now: const isProduction = globalThis.process == null || (process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'test'); retaining the check to see whether process is defined globally There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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......? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Long-term solution: 3 versions of this file - one with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yaacovCR What problems are you seeing? 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 |
||
|
||
/** | ||
* A replacement for instanceof which includes an error warning when multi-realm | ||
|
@@ -13,13 +13,8 @@ const isProduction = | |
* See: https://webpack.js.org/guides/production/ | ||
*/ | ||
export const instanceOf: (value: unknown, constructor: Constructor) => boolean = | ||
/* c8 ignore next 6 */ | ||
// FIXME: https://github.com/graphql/graphql-js/issues/2317 | ||
isProduction | ||
isDevelopment | ||
? function instanceOf(value: unknown, constructor: Constructor): boolean { | ||
return value instanceof constructor; | ||
} | ||
: function instanceOf(value: unknown, constructor: Constructor): boolean { | ||
if (value instanceof constructor) { | ||
return true; | ||
} | ||
|
@@ -50,6 +45,11 @@ spurious results.`, | |
} | ||
} | ||
return false; | ||
} | ||
: /* c8 ignore next 4 */ | ||
// FIXME: https://github.com/graphql/graphql-js/issues/2317 | ||
function instanceOf(value: unknown, constructor: Constructor): boolean { | ||
return value instanceof constructor; | ||
}; | ||
|
||
interface Constructor extends Function { | ||
|
Uh oh!
There was an error while loading. Please reload this page.