从Meteor docs:
使此软件包的用户可以访问另一个软件包(通过传递字符串packagename
)或软件包集合(通过传递字符串数组[packagename1, packagename2]
)。
我不知道这是什么意思。
从this question我知道imply
可以和use
一起使用。api.imply
是做什么的?api.use
和api.imply
到底有什么区别?
最佳答案
api.use
使软件包可以访问其他软件包导出的符号。
例如,如果要在包装代码(see how it's done in the accounts-base package)中使用api.use("random")
符号,则需要Random
(see how the random
package.js
is api.export
ing Random
)。
但是,meteor add
ing accounts-base
不会让整个应用程序访问其使用过的软件包(在这种情况下为random
)。如果您的应用程序需要random
,则仍然需要meteor add
。
另一方面,api.imply
使整个应用程序可以访问该程序包导出的符号。
例如,see how accounts-google
is api.imply
ing accounts-base
。accounts-base
is responsible for exporting the Accounts
symbol,当您使用meteor add accounts-google
时,不仅会在应用程序依赖项中添加accounts-base
,而且还会在应用程序中提供accounts-base
符号,特别是因为它暗含了。accounts-base
既在自己的代码(Accounts
)中使用api.use
,又将其依赖项符号导出到整个应用程序(api.imply
)。api.imply
可以用于制作“影子程序包”,这些影子程序包仅用于引入其他程序包。
例如,在某个时候,MDG将showdown
包重命名为markdown
,他们可能只是声明为meteor remove showdown && meteor add markdown
,但是这需要对最终用户采取一些措施。
他们所做的只是保留了showdown
软件包,而只是保留了make it implying the new markdown
package。
关于meteor - api.imply是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29928376/