-
Notifications
You must be signed in to change notification settings - Fork 194
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
Prod Mode #6
Comments
sounds legit |
Agreed. Those constraints are mostly not supposed to be runtime errors and should be catch in development. |
I'm interested in working on this but I am a bit unsure on how to pass the flag to the library? Would you use the export code:
To do different things depending on the environment, like (using global and window as examples):
Or is there a better way? |
What about a method on Immutable that looks like |
Awsesome! The best practice I've seen (which is what React does) is to make it envify-friendly. Basically you do this:
...then run In the development build,
....whereas in the production build, it will instead replace it with this:
Uglify will then see that this conditional will always fail and will strip this code out entirely, meaning the production build will not only avoid adding the extra attributes, it won't even run any conditionals to tell if it's in prod mode! This implicitly means we'd need to introduce a build process to generate the two different files for library consumers. |
I've been wondering about how to do this kind of thing for ever. Very nice solution. No non-JS syntax needed. Alan
|
Should we then move |
That makes sense to me. Let's not check in changes to the compiled files on every commit, though, as that will make the diffs miserable. Instead just leave them out of normal commits, and once per release I'll include updated compiled files in the commit that bumps the version number. Sound good? |
Sounds good! |
In production, it's probably unnecessary to actually freeze objects and throw exceptions when mutating methods are invoked. Those are mainly necessary in development, but by the time the code hits production, if any invariants aren't being followed, you should already know about it.
With that in mind, having a way to turn off the freezing and overriding should speed up performance, particularly in Safari. Adding a quick flag to turn this on would be useful to that end.
The text was updated successfully, but these errors were encountered: