如何为现有的Javascript库创建Angular库包装器? [英] How does one go about creating an Angular library wrapper for an existing Javascript library?

查看:72
本文介绍了如何为现有的Javascript库创建Angular库包装器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设存在一个用普通Javascript编写的Javascript库,并且常用于vanilla,非框架网站。如何创建一个Angular库,它可以很容易地 npm install ed,这样可以使这个库在Angular应用程序中无缝使用?

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?

我无法在Angular文档或更广泛的网络上找到这个过程的任何好的演示。

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

就是说,有一个很棒的Javascript库名为 p5.js ,这与Angular一起使用并不简单。如何创建一个Angular模块,你只需将其导入到你自己的Angular模块中,并使用Angular支持的所有强大功能?

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?

推荐答案

就个人而言,我会选择Angular CLI。 Angular CLI v6内置了ng-packgr。

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.

这篇关于如何为现有的Javascript库创建Angular库包装器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆