-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Labels
Description
What problem does this feature solve?
Access to process.env is a slow, system-bound call.
After react restructured their project to cache access to process.env, they had a 2.4x - 3.8x performance improvement for server-side rendering,
This should also be done for vue, vue-server-renderer, vuex ... anything that accesses process.env.
What does the proposed API look like?
An easy strategy might be to replace references to process.env.NODE_ENV with a reference to a singleton that checks process.env.NODE_ENV.
// foo.js
if (process.env.NODE_ENV !== 'production') {
// do stuff
}
becomes
// isDevEnv.js
export default process.env.NODE_ENV !== 'production';
// foo.js
import isDevEnv from './isDevEnv';
if (isDevEnv) {
// do stuff
}
mrsideshowjack