How does one go about creating an Angular library wrapper for an existing Javascript library?

有些话、适合烂在心里 提交于 2020-01-12 13:04:26

问题


Suppose there exists a Javascript library written in plain Javascript and commonly used on vanilla, non-frameworked websites. How does one go about creating an Angular library that can easily be npm installed that would make the library seamless to use in an Angular app?

I cannot find any good demonstrations of this process in the Angular docs or on the wider web.

Just for instance, there is a fantastic Javascript library called p5.js, which is not straightforward to use with Angular. How would one go about creating an Angular module that you can simply import into your own Angular module and use all of its great features with full Angular support?


回答1:


Personally, I would go with Angular CLI. Angular CLI v6 has ng-packgr built in.

Take a look at the create library story. Its pretty straightforward and it will get you started quickly and guide you with the best practices for updates as well.

Update: For Angular CLI v7 and later, see documentation here



来源:https://stackoverflow.com/questions/51354584/how-does-one-go-about-creating-an-angular-library-wrapper-for-an-existing-javasc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!