-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
feat: optionally strip non-client or non-server code #6149
Conversation
What will happen to jsdom case? |
Codecov Report
@@ Coverage Diff @@
## dev #6149 +/- ##
==========================================
- Coverage 95.79% 95.69% -0.11%
==========================================
Files 78 78
Lines 2714 2718 +4
Branches 702 706 +4
==========================================
+ Hits 2600 2601 +1
Misses 99 99
- Partials 15 18 +3
Continue to review full report at Codecov.
|
Made it optional but couldn't find a better name for it 🙈 |
@@ -120,6 +120,12 @@ export default class WebpackBaseConfig { | |||
'process.mode': JSON.stringify(this.mode), | |||
'process.static': this.buildContext.isStatic | |||
} | |||
if (this.buildContext.buildOptions.aggressiveCodeRemoval) { | |||
env['typeof process'] = JSON.stringify(this.isServer ? 'object' : 'undefined') |
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.
Values are the same. Can we refactor the right hand part to a const?
Types of changes
Description
We already have
process.client
andprocess.server
that take care of separating "client" and "server" code (if needed). However, it can sometimes be hard to control that in 3rd party dependencies.With this change, the webpack define plugin will set the
typeof window
check toobject
on client andundefined
on server, so the code can (and will be) correctly removed by webpack.Checklist: