using jquery with browserify

三世轮回 提交于 2019-12-03 14:13:04

Browserify can process CommonJS modules as well as AMD modules with the deamdify transform so now there should be no need to use a shim.

To be clear I only noticed AMD support in JQuery 2.0.0

jQuery is now CommonJS compliant, as of version 2.1.0

Thorsten Lorenz

jQuery was not CommonJS compliant, i.e. it didn't export itself via module.exports = $ until 2.1.0.

Therefore you needed to shim it via browserify-shim.

browserify-shim will shim any version of jquery or any other non-CommonJS library like Zepto on the fly. Details on how to set this up are included in the readme.

As an alternative you could have also used jquery-browserify, but then you would be tied to the jQuery version that this module made CommonJS compliant.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!