Question

Is it possible to use libraries such as jquery.js, processing.js and three.js on browserify, so I can completely stop using HTML to require my client libs?

Était-ce utile?

La solution

Yes.

However to work correctly with browserify libraries need to be done browserify style. The good news it's not hard to convert, for most libraries it's mostly just a matter of getting their module.exports set up instead of exporting to window. And for many modules you don't need to do it your self since they're already published in browserify style on npm. jQuery and three are in npm ready for browserify use.

Take a look here so see an example conversion: https://github.com/spine/jqueryify/blob/master/index.js#L8730-L8757

Autres conseils

You might want to have a look at https://github.com/thlorenz/browserify-shim .

It allows using javascript files not compatible with commonJS modules in Browserify.

They have a specific example for jQuery: https://github.com/thlorenz/browserify-shim/tree/master/examples/shim-jquery .

If you are using grunt, grunt-browserify supports browserify-shim as well.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top