Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

modulr

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modulr - npm Package Compare versions

Comparing version 0.3.0 to 0.4.1

assets/modulr.sync.resolved.js

4

assets/modulr.sync.js

@@ -5,3 +5,2 @@ // modulr.sync.js (c) 2010 Tobie Langel

_modules = {},
_handlers = [],
_dirStack = [''],

@@ -16,3 +15,3 @@ PREFIX = '__module__', // Poor man's hasOwnProperty

if (mod) { return mod.exports };
if (mod) { return mod.exports; }

@@ -27,2 +26,3 @@ _modules[key] = mod = {

var fn = _factories[key];
delete _factories[key];
if (!fn) { throw 'Can\'t find module "' + identifier + '".'; }

@@ -29,0 +29,0 @@

var fs = require('fs'),
path = require('path');
var RUNTIME_PATH = path.join(__dirname, '..', 'assets', 'modulr.sync.js'),
JS_ESCAPE_REGEXP = /\\|\r?\n|"/g,
INLINE_SCRIPT_SAFE_JS_ESCAPE_REGEXP = /\\|\r?\n|"|<\//g,
JS_ESCAPE_MAP = {
'\\': '\\\\',
'\n': '\\n',
'\r\n': '\\n',
'"': '\\"',
'</': '<\/'
};
var RUNTIME_PATH = path.join(__dirname, '..', 'assets', 'modulr.sync.js');

@@ -25,2 +16,3 @@ exports.createBuilder = createBuilder;

this.inlineSafe = !!config.inlineSafe;
this.config = config;
}

@@ -33,3 +25,3 @@

lazyEval = null,
output = '';
collector = this.createCollector(this.config);

@@ -67,5 +59,5 @@ if (this.lazyEval === true) {

if (lazyEval && (id in lazyEval)) {
output += this.toLazyEvalTransport(deps[id]);
collector.addLazyEvaledModule(deps[id]);
} else {
output += this.toTransport(deps[id]);
collector.addModule(deps[id]);
}

@@ -75,30 +67,21 @@ }

if (result.main) {
output += '\nrequire("' + result.main.id + '");';
collector.addMainModule(result.main);
}
fs.readFile(RUNTIME_PATH, 'utf8', function(err, file) {
err ? callback(err) : callback(null, file + '\n' + output);
fs.readFile(RUNTIME_PATH, 'utf8', function(err, src) {
if (err) {
callback(err);
} else {
collector.addRuntime(src);
result.output = collector.toString();
callback(null, result);
}
});
}
p.toTransport = toTransport;
function toTransport(module) {
var output = '';
output += '\ndefine("';
output += module.id;
output += '", function(require, exports, module) {\n';
output += module.src;
output += '\n});\n';
return output;
p.createCollector = createCollector;
function createCollector(config) {
return require('./collector').create(config);
}
p.toLazyEvalTransport = toLazyEvalTransport;
function toLazyEvalTransport(module) {
var output = '';
output += '\ndefine("' + module.id + '", "';
output += this.escape(module.src, this.inlineSafe);
output += '");\n';
return output;
}
p.findScopedDependencies = findScopedDependencies;

@@ -136,10 +119,2 @@ function findScopedDependencies(modules) {

}
p.escape = escape;
function escape(str, inlineSafe) {
var regexp = inlineSafe ? INLINE_SCRIPT_SAFE_JS_ESCAPE_REGEXP : JS_ESCAPE_REGEXP;
return str.replace(regexp, function(m) {
return JS_ESCAPE_MAP[m];
});
}
})(Builder.prototype);

@@ -17,7 +17,7 @@ var fs = require('fs'),

} else {
builder.create(config).build(result, function(err, output) {
builder.create(config).build(result, function(err, result) {
if (config.verbose) {
log(result);
}
callback(err, output);
callback(err, result);
});

@@ -28,3 +28,7 @@ }

exports.buildFromPackage = function(p, callback) {
exports.buildFromPackage = function(p, configCallback, callback) {
if (!callback) {
callback = configCallback;
configCallback = function() {};
}
fs.stat(p, function(err, stat) {

@@ -34,20 +38,19 @@ if (err) {

} else {
var packageFile, config = {};
var packageFile, root;
if (stat.isDirectory()) {
config.root = p;
root = p;
packageFile = path.join(p, 'package.json');
} else {
config.root = path.rootname(p);
root = path.dirname(p);
packageFile = p;
}
jsonFs.readFile(packageFile, function(err, json) {
var modulrConfig = json.modulr_config;
if (err) {
callback(err);
} else {
config.paths = modulrConfig.paths ? modulrConfig.paths : [];
var config = json.modulr || {};
config.paths = config.paths || [];
config.paths.push('.');
config.lazyEval = modulrConfig.lazy_eval;
config.isPackageAware = true;
config.verbose = !!modulrConfig.verbose;
configCallback(config);
build(json.main, config, callback);

@@ -54,0 +57,0 @@ }

@@ -5,5 +5,5 @@ {

"main": "./main",
"version": "0.3.0",
"version": "0.4.1",
"dependencies": {
"module-grapher" : ">=0.5.0"
"module-grapher" : ">=0.5.2"
},

@@ -10,0 +10,0 @@ "author": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc