Using Browserify With A Minified Javascript Library
Can a minified JavaScript library be 'required' and bundled using Browserify? In other words, does Browserify require the JavaScript file to be in source format? If a JavaScript f
Solution 1:
- In case it's properly exporting its properties (e.g. using exports or module.exports) and loading modules using
require()
then yes. - Of course it can be bundled, but you can't access its properties/data from the result of the
require()
call. However if it's using for example the global object for its exports, you can access it after you require the file.
xyz.js:
window.myExport = "hello";
main.js:
var xyz = require("xyz");
xyz.myExport; // undefinedwindow.myExport; // "hello"
Post a Comment for "Using Browserify With A Minified Javascript Library"