UNPKG

lasso-require

Version:

Lasso.js plugin to support Node.js style module require in the browser

46 lines (37 loc) 1.12 kB
var transport = require('lasso-modules-client/transport'); exports.create = function(config, lasso) { return { properties: { 'path': 'string', 'paths': 'string[]' }, init: function() { if (!this.paths) { this.paths = []; } if (this.path) { this.paths.push(this.path); } }, getDir: function() { return null; }, read: function(context) { return transport.codeGenerators.searchPath(this.paths, { modulesRuntimeGlobal: config.modulesRuntimeGlobal }); }, getLastModified: function(lassoContext, callback) { callback(null, -1); }, getUnbundledTargetPrefix: function(lassoContext) { return config.unbundledTargetPrefix; }, getUnbundledTarget: function() { return 'lasso-modules-meta'; }, calculateKey: function() { return 'modules-search-path:' + JSON.stringify(this.paths); } }; };