feathersjs-ecosystem / feathers-reactive

Reactive API extensions for Feathers services
MIT License
216 stars 37 forks source link

Still no full ES5 support? #122

Closed phymous closed 6 years ago

phymous commented 6 years ago

The main attribute of the feathers-reactive's package.json points to lib/index. lib/index imports @feathersjs/commons/lib/utils which itself contains the following ES6 code (snippet):

// A set of lodash-y utility functions that use ES6
const _ = exports._ = {
  each (obj, callback) {
    if (obj && typeof obj.forEach === 'function') {
      obj.forEach(callback);
    } else if (_.isObject(obj)) {
      Object.keys(obj).forEach(key => callback(obj[key], key));
    }
  },
...

This obviously causes a problem for IE11 due to the lacking ES6 support. When I import feathers-reactive/dist/feathers-reactive instead of just feathers-reactive, I get no error in IE 11.

Is this intended?

System configuration

Module versions: feathers-reactive 0.7.1

Browser Version: IE 11

Module Loader: Webpack

daffl commented 6 years ago

Yes, this is intended. As you pointed out, the ES5 version can be found by requiring feathers-reactive/dist/feathers-reactive.

When using the module directly the same module bundler configuration is necessary as when using Feathers directly on the client.

phymous commented 6 years ago

Is the import of feathers-reactive/dist/feathers-reactive somewhere documented?

To be honest, this is the first client library I came across which does not provide the ES5 code per default :-)

Furthermore, isn't transpiling 3rd party code (e.g. by using a bundler like webpack) a bad practice? The Angular CLI, for instance, transpiles only self-written code. What if, for the sake of the example, feathers-reactive would use some non-standard operator which is only supported by a specific babel plugin? Would I have to install this plugin in my bundler setting?

Please correct me if I'm wrong, maybe I am missing something.

daffl commented 6 years ago

It works the same as using Feathers itself on the client. You can either configure your module bundler as documented or use the ES5 transpiled version (just like @feathersjs/client). Like Feathers, feathers-reactive works in Node and on the client and is written with the features that the earliest supported version (6 LTS) of Node supports out of the box - so all standard ES6 (ES2015) features (the current version of JavaScript) without ES modules or anything else that is non-standard or would require other Babel plugins. You can find more about the reasons behind this in https://github.com/feathersjs/feathers/issues/608

A note in the readme for loading the transpiled version would be nice indeed though.