Comments (2)
Hi @mikestead - would something like this work?
if (typeof process!=='undefined' && process.env.NODE_ENV!=='production') {
} else {
}
FWIW, I have found that you have to add a tiny bit extra in DefinePlugin to get things removed:
new DefinePlugin({
process: {},
'process.env': {},
'process.env.NODE_ENV': JSON.stringify('production')
})
from proptypes.
Thanks for the input and tip, if I add process
and process.env
to the define plugin with no changes to PropTypes lib I do indeed see a little more code removed, and from react-router as well as preact/preact-compat.
libs.e47828f.js 129 kB 1, 2 [emitted] libs
I guess that's for code that also checks the parent chain of process.env.NODE_ENV
in a conditional.
You are also correct the following does seem to work, and without touching the DefinePlugin
.
if (typeof process!=='undefined' && process.env.NODE_ENV!=='production') {
But we're obv not checking for env
here. If I add that check code isn't stripped... unless I go make those additions to the DefinePlugin :)
For backwards compatibility I tried switching it to
if (typeof process!=='undefined' && process.env.NODE_ENV==='production') {
and inverting the if else blocks, but then the code wasn't stripped. I guess Uglify may only like stripping from the if block?
If I swap back and then add process
and process.env
to DefinePlugin
I can use an OR
if (typeof process==='undefined' || !process.env || process.env.NODE_ENV!=='production') { // dev
Let me know what you want to do, if anything and I'm happy to open a pull request.
from proptypes.
Related Issues (9)
- How to use ? HOT 4
- Support for PropTypes.symbol HOT 3
- Licensing is murky HOT 5
- proptypes changes impacted inferno-compat HOT 2
- disabled is not published in npm HOT 1
- [Suggestion] Give npm package name back to React team HOT 1
- Difference with React's prop-types HOT 1
- Deprecate the package in favor of the official prop-type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proptypes.