funcadelic.js icon indicating copy to clipboard operation
funcadelic.js copied to clipboard

Make type class matching resilient to uglification

Open taras opened this issue 6 years ago • 1 comments

Uglify removes Class.name which breaks typeclass matching as explained in https://github.com/microstates/ember/pull/98.

We should not rely on Class.name since it's is not always available. Instead, we could introduce a special type name to ensure that this name is always available. It is a little more verbose but it will be more reliable while classes are still being transpiled.

An alternative API could be,

export const Functor = type(class Functor {
  static typeName = 'Functor'
  map(fn, f) {
    let { map } = this(f);
    return map(fn, f);
  }
});

@cowboyd if you're good with this, I'll make a PR.

taras avatar Dec 16 '18 19:12 taras

Will uglify still barf if you explicitly set the name?

static name = “Functor”

cowboyd avatar Dec 17 '18 01:12 cowboyd