-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Use __DEV__
internally instead of process.env.NODE_ENV
.
#8347
Merged
benjamn
merged 4 commits into
release-3.4
from
try-__DEV__-instead-of-process.env.NODE_ENV
Jun 15, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
44a1918
Experiment: use __DEV__ instead of process.env.NODE_ENV.
benjamn fcb2c7d
Temporarily polyfill global.process while importing graphql package.
benjamn 8f68762
Warn about usage of __DEV__ polyfill.
benjamn 56b1cb5
Increase bundlesize limit from 24.5kB to 24.7kB.
benjamn File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ function prepareCJSMinified(input) { | |
compress: { | ||
toplevel: true, | ||
global_defs: { | ||
'@process.env.NODE_ENV': JSON.stringify('production'), | ||
'@__DEV__': 'false', | ||
}, | ||
}, | ||
}), | ||
|
@@ -97,27 +97,6 @@ function prepareBundle({ | |
exports: 'named', | ||
interop: 'esModule', | ||
externalLiveBindings: false, | ||
// In Node.js, where these CommonJS bundles are most commonly used, | ||
// the expression process.env.NODE_ENV can be very expensive to | ||
// evaluate, because process.env is a wrapper for the actual OS | ||
// environment, and lookups are not cached. We need to preserve the | ||
// syntax of process.env.NODE_ENV expressions for dead code | ||
// elimination to work properly, but we can apply our own caching by | ||
// shadowing the global process variable with a stripped-down object | ||
// that saves a snapshot of process.env.NODE_ENV when the bundle is | ||
// first evaluated. If we ever need other process properties, we can | ||
// add more stubs here. | ||
intro: '!(function (process) {', | ||
outro: [ | ||
'}).call(this, {', | ||
' env: {', | ||
' NODE_ENV: typeof process === "object"', | ||
' && process.env', | ||
' && process.env.NODE_ENV', | ||
' || "development"', | ||
' }', | ||
'});', | ||
].join('\n'), | ||
Comment on lines
-100
to
-120
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. This makes PR #7627 obsolete, because we're no longer using |
||
}, | ||
plugins: [ | ||
extensions ? nodeResolve({ extensions }) : nodeResolve(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
/* Core */ | ||
|
||
export { __DEV__ } from "../utilities"; | ||
|
||
export { | ||
ApolloClient, | ||
ApolloClientOptions, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Our
Filesize
CI check is only passing because I went ahead and reconfigured the minifier to replace__DEV__
withfalse
, simulating a production environment.