You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
today I ran into an issue with our production builds being broken, which was ultimately caused by minified builds behaving differently to non-minified builds: Ember.Object.create().hasOwnProperty('_super') is false in non-minified builds, but true in minified ones.
I've actually verified that building in production environment with minifyJS: { enabled: false } isn't making _super an 'own property'. So I assume it's a minification issue and nothing else that might differ for production and development builds.
We stumbled upon this because we were doing for in on an Ember.Object and checking the properties with hasOwnProperty. (yes, it's fishy. no, i don't think it's a good idea. yes, i've changed the code already, but the inconsisteny somewhere remains).
We check to see if a function contains _super / .call / .apply before attempting to super wrap a given method (this saves quite a bit of extra super wrapping for functions that do not need it). Unfortunately, a number of platforms that we support do not support calling func.toString() so we attempt to detect this and fall back to always super wrap everything mode.
We have roughly this code (from here) to detect if we can call toString() and get the original source:
Note that minifier has stripped the trailing semicolon from the function body we are attempting to check against, but sadly our indexOf check still contains the semicolon!
tldr; We super wrap every function in uglified builds.
Hey,
today I ran into an issue with our production builds being broken, which was ultimately caused by minified builds behaving differently to non-minified builds:
Ember.Object.create().hasOwnProperty('_super')
isfalse
in non-minified builds, buttrue
in minified ones.I've actually verified that building in
production
environment withminifyJS: { enabled: false }
isn't making_super
an 'own property'. So I assume it's a minification issue and nothing else that might differ for production and development builds.We stumbled upon this because we were doing
for in
on anEmber.Object
and checking the properties withhasOwnProperty
. (yes, it's fishy. no, i don't think it's a good idea. yes, i've changed the code already, but the inconsisteny somewhere remains).To show this behavior I prepared a demo project here:
https://github.com/dschmidt/ember-dev-prod-inconsistency
(It's just a completely empty project ... but any of your projects should be good)
Just run
ember s
andember s --environment=production
and compare the outputs ofEmber.Object.create().hasOwnProperty('_super')
BR,
Domme
The text was updated successfully, but these errors were encountered: