globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 605 forks source link

Create a development and a production build #823

Open onigoetz opened 6 years ago

onigoetz commented 6 years ago

There are a lot of checks all over the place for example :

validateParameterPresence( unit, "unit" );
validateParameterTypeString( unit, "unit" );

Are they useful in production ?

In the source code of React, there are a lot of checks but they are enabled only in development mode :

For example : https://github.com/facebook/react/blob/master/packages/react-dom/src/client/ReactDOM.js#L1053-L1055

And they change this variable when building : https://github.com/facebook/react/blob/master/scripts/rollup/build.js#L234 They even have babel plugins to automatically wrap some functions with this if (__DEV__) {} condition : https://github.com/facebook/react/blob/master/scripts/rollup/build.js#L88-L91

This could have two advantages :

Is it possible to have something similar in Globalize ?

If yes, I'm willing to do a POC Pull Request

Edit : I know there is a runtime version already, but not everybody can use the production generator to be able to use only the Globalize Runtime, Anyway, these changes would also benefit the runtime version

rxaviers commented 6 years ago

:+1: