简体   繁体   English

将第三方库与requirejs一起使用

[英]Using 3rd party libraries with requirejs

Hi I trying to organize my code by using requirejs, but I need to use a library that uses google-closure-compiler, the library is box2djs and you can get it from 嗨,我尝试使用requirejs组织代码,但我需要使用使用google-closure-compiler的库,该库为box2djs,您可以从中获取它

https://github.com/leonidax/pl.git https://github.com/leonidax/pl.git

I found that the code calls functions such as goog.require() 我发现代码调用了goog.require()之类的函数

Hoy can I use this library by using RequireJS? 可以通过RequireJS使用此库吗?

Oh, you're asking for a pile of hurt. 哦,你要受伤了。

The closure library and the google dependency model (goog.require, etc) are tightly linked. 闭包库和google依赖模型(goog.require等)紧密相连。

You're better moving to use the closure tools everywhere and trying to hack a composite solution. 您最好在所有地方使用封闭工具,并尝试破解复合解决方案。

I did get google closure library and RequireJS to work together. 我确实得到了谷歌关闭库和RequireJS一起工作。 Just make sure the Closure stuff comes before the RequireJS stuff. 只要确保Closure东西在RequireJS东西之前即可。

<script src='../externalJS/requirejs/require.js'></script>
<script src="../externalJS/closure-library-read-only/closure/goog/base.js"></script>

<script>

    goog.require('goog.structs');
    goog.require('goog.structs.PriorityQueue');

    // i just had to make sure that the closure lib stuff came before the requirejs stuff

    requirejs([
        'loaders_parsers/requiredLibrarys',
    ]);

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

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