简体   繁体   English

流星包加载顺序

[英]Meteor package load order

The order I add packages on Meteor makes any difference in the result ? 我在Meteor上添加包的顺序会对结果产生任何影响吗? Lets say I use bootstrap 3 and accounts ui with bootstrap 3, if I add the latter first or vice versa would work the same way ? 让我说我使用bootstrap 3和帐户ui与bootstrap 3,如果我先添加后者,反之亦然会以相同的方式工作?

In Meteor the package order that you add them in does not matter. 在Meteor中,您添加它们的包顺序无关紧要。

There is a module in meteor called linker that analyses each packages dependencies to ensure that the dependencies load first. meteor中有一个名为linker的模块,它分析每个包的依赖关系,以确保首先加载依赖关系。

For example: If bootstrap-3 is a dependency of accounts-ui-bootstrap-3 then even if bootstrap-3 was added after, it would be loaded first. 例如:如果bootstrap-3accounts-ui-bootstrap-3的依赖项,那么即使之后添加了bootstrap-3 ,它也会先加载。

There isn't currently a way to test for or access an optional dependency from within a package. 目前没有办法在包中测试或访问可选依赖项。 You can test for it's existence by testing if Package['author:package'] is defined. 您可以通过测试是否定义了Package ['author:package']来测试它的存在。 The problem is the load order. 问题是加载顺序。 I got around it temporarily by editing the packages file in .meteor and moving the optional dependency package higher up in the list. 我通过编辑.meteor中的packages文件并在列表中向上移动可选的依赖包来暂时解决它。 I don't think it's a good long term fix though. 我不认为这是一个很好的长期修复。 This should be a Meteor feature suggestion, if it's not already. 这应该是Meteor功能建议,如果它还没有。

Each package has a package.json file that lists what other packages it requires. 每个包都有一个package.json文件,列出了它需要的其他包。 This practice ensures that packages load in a proper order. 这种做法可确保包以正确的顺序加载。 Read these files to troubleshoot load-order issues. 阅读这些文件以解决加载顺序问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM