I am working on usercript - in particular this usercript - which was designed to encapsulate functionality in modules. To be able to perform automatic testing, I would like to separate the modules into my own files and use the node.js module for export and require the functions to be combined into one file for use in Greasemonkey or in simple browser extensions.
My first thought was to simply copy the modules into my own files as such
module.js
var exportedModule = (function (){ var Module = {
And then you have a central file that requires each of these modules, maybe compile them with something like Browserify .
script.js
var importedModule = require(./module); importedModule.init();
Is it possible?
source share