transcranial / keras-js

Run Keras models in the browser, with GPU support using WebGL
https://transcranial.github.io/keras-js
MIT License
4.96k stars 503 forks source link

Do not bundle babel-polyfill with library. Let it be an external peer dependency #109

Open anandanand84 opened 6 years ago

anandanand84 commented 6 years ago

Shipping babel polyfill with the library doesnt play nice with other libraries.

https://github.com/transcranial/keras-js/blob/master/src/index.js#L1

If an application depends on multiple libraries and everything ships with babel-polyfill it will cause

Uncaught Error: only one instance of @babel/polyfill is allowed

Even in cases where the other application doesnt ship with babel polyfill but depend on babel-polyfill, it will fail since the the babel polyfill will be loaded later when this(keras-js) dependency is loaded.

Only solution is to load the babel polyfill first from a cdn or the end application add it as a dependency in their build process

levithomason commented 6 years ago

Agreed. Shipping the polyfill causes unwarranted side-effects for apps loading keras-js as well. It would be ideal if keras-js provided pre-compiled targets. This way users could opt-in to loading the package that suited their needs.

Another option is to rollback the future features relying on the polyfill. I'm not sure what the scope of that would be in this repo.

tiansivive commented 6 years ago

Please fix this, it's causing me major headaches, since keras-je is being included as a third party dependency by a lib i'm using