Uncaught ReferenceError: define is not defined
如果开发人员决定不使用它,我希望我的JavaScript应用程序不依赖于AMD加载程序.但是,由于应用程序的复杂性,我想用它来处理我的应用程序的依赖项.
是否有可用的编译器编译JavaScript以消除AMD依赖?我已经看到了Grunt的一些嗡嗡声,但是没有找到关于这是否是Grunt功能的直接答案.
解决方法
If you are building a library for use on web pages that may not use RequireJS or an AMD loader,you can use the optimizer to combine all your modules into one file,then wrap them in a function and use an AMD API shim. This allows you to ship code that does not ship with all of RequireJS,and allows you to export any kind of API that works on a plain web page without an AMD loader.
07001 is an AMD API shim that is very small,so it can be used in place of require.js when all of your modules are built into one file using the RequireJS optimizer. The wrap build config option will put a function wrapper around the code,or you can provide your own wrapper if you need to do extra logic.