Socket
Socket
Sign inDemoInstall

commonjs-walker

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonjs-walker - npm Package Compare versions

Comparing version 3.0.3 to 4.0.0

test/fixtures/walker/as/a.js

21

index.js

@@ -19,15 +19,7 @@ 'use strict';

}
options['as'] || (options['as'] = {});
return new Walker(entry, options, callback);
}
walker.OPTIONS = {
BROWSER: {
detectCyclic: true,
strictRequire: true,
allowAbsolutePath: false,
extensions: ['.js', '.json']
}
};
function makeDefault (object, key, value) {

@@ -162,2 +154,4 @@ object[key] = key in object

async.each(dependencies, function (dep, done) {
var origin = dep;
if (dep.indexOf('/') === 0 && !options.allowAbsolutePath) {

@@ -175,5 +169,10 @@ return done({

if (!self._isRelativePath(dep)) {
return self._dealDependency(dep, dep, node, done);
// we only map top level id for now
dep = options['as'][dep] || dep;
}
if (!self._isRelativePath(dep)) {
return self._dealDependency(origin, dep, node, done);
}
resolve(dep, {

@@ -194,3 +193,3 @@ basedir: node_path.dirname(path),

self._dealDependency(dep, real, node, done);
self._dealDependency(origin, real, node, done);
});

@@ -197,0 +196,0 @@ }, callback);

{
"name": "commonjs-walker",
"version": "3.0.3",
"version": "4.0.0",
"description": "Analyzer and tree walker for commonjs.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -93,2 +93,3 @@ # commonjs-walker [![NPM version](https://badge.fury.io/js/commonjs-walker.png)](http://badge.fury.io/js/commonjs-walker) [![Build Status](https://travis-ci.org/kaelzhang/node-commonjs-walker.png?branch=master)](https://travis-ci.org/kaelzhang/node-commonjs-walker)

extensions | `Array` | `['.js', '.json', '.node']` | see `options.extensions` section
as | `Object` | `{}` | An object map that define the alias of the parameter of `require`

@@ -111,6 +112,4 @@ <!-- parseForeignModule | `Boolean` | true | will try to resolve foreign modules by `require.resolve()`. Set this option to false to handle foreign modules yourself. -->

## walker.OPTIONS.BROWSER
## Frequent Options for Browsers
An usual preset of options for browsers, as
```js

@@ -117,0 +116,0 @@ {

@@ -201,2 +201,30 @@ 'use strict';

}
},
{
desc: '#15: package.as',
options: {
'as': {
'a': './a'
}
},
file: 'as/index.js',
expect: function (err, path, nodes, entry) {
expect(err).to.equal(null);
var a = node_path.join( node_path.dirname(path), 'a.js' );
expect('a' in entry.dependencies).to.equal(true);
expect(entry.dependencies['a']).to.equal(a);
}
},
{
desc: '#15: package.as, foreign',
options: {
'as': {
'a': 'b'
}
},
file: 'as/foreign.js',
expect: function (err, path, nodes, entry) {
expect(err).to.equal(null);
expect(entry.dependencies['a']).to.equal('b');
}
}

@@ -203,0 +231,0 @@ ];

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