I’d like to understand why model.constructor.name is not available in prod builds while it works in dev and test envs for models defined with the ES6 class syntax.
Looks like the name is being mangled during minification. There might be an uglify / terser setting to prevent this, but since by the time it gets to minification (due to targets configuration) I’m not sure that they know which things are constructors vs normal functions.
The reason modelName is present is because ember-data adds it manually after lookup up any given model class.
I’ve tested this with minifyJS: true in a dev build and constructor.name is working, so minification might not be the only thing involved in this behaviour.
Sorry for being unclear above, I’m saying that the combination of transpiling to your production targets (which includes IE11 in the demo repo) and minification that is the cause.
In a dev build, your targets are essentially only evergreen browsers that all support native class syntax directly and therefore the model is not transpiled down to ES5. When terser/uglify runs against a native class it does preserve the constructor.name (as one of your recent comments confirmed).
However, in a prod build your apps targets include IE11 which means that native class syntax is not supported and therefore it is transpiled away before minification (see example of transpilation here). Then when minification happens it sees “just” a function bound to the local closure scope (e.g. function Article(){}) which gets the normal function name mangling.
I don’t know to what part of the framework this might be related, but it would be great if we could rely on constructor.name whatever the build env.
Ultimately, this isn’t really an “Ember” thing its just how transpilation + minification works…