Próbuję wykorzystać browserify zasadniczo na razie w celu podziału dużego pliku .js na mniejsze, ale to nie idzie.
Nie idzie to znaczy komenda
browserify script.js -o bundle.js
nie generuje żadnego pliku bundle.js, zaś komenda
browserify script.js > bundle.js
generuje pusty plik bundle.js
Fragmenty pliku script.js
const usr = require("./userfunctions.js");
zaś plik userfunctions wygląda tak:
const userfunctions = (function () {
return {
name: {
getSurname: function getSurname(str) {
const lastspace = function lastspace(x) {
return x.lastIndexOf(" ");
};
return lastspace(str) === -1 ? str : str.slice(lastspace(str) + 1);
},
getFirstname: function getFirstname(str) {
const lastspace = function lastspace(y) {
return y.lastIndexOf(" ");
};
return lastspace(str) === -1 ? str : str.slice(0, lastspace(str));
},
processedFirstName: function processedFirstName(str) {
return `By ${this.getFirstname(str)}`;
},
},
};
}());
module.exports = userfunctions;
Dlaczego tak się dzieje? Z opisu te browserify było proste jak konstrukcja młotka szewskiego.