klei / ng-dependencies Goto Github PK
View Code? Open in Web Editor NEWAnalyze javascript code using esprima and return a list of objects representing the angular module dependencies in the code.
Analyze javascript code using esprima and return a list of objects representing the angular module dependencies in the code.
Thanks for the great work on this plugin.
angular.module("foo");
syntax works great.
window.angular.module("foo");
syntax does not work.
I couldn't find any documentation on the fact so I ran your tests with window
in front. Here are the tests:
it('should capture simple module declaration with window', function () {
var source = 'window.angular.module("test", []);';
var deps = {
dependencies: ['ng'],
modules: {
'test': []
}
};
lookup(source).should.eql(deps);
});
it('should capture the module dependencies with window', function () {
var source = 'window.angular.module("test", ["one"]);';
var deps = {
dependencies: ['ng', 'one'],
modules: {
'test': ['one']
}
};
lookup(source).should.eql(deps);
});
it('should capture module dependencies at root level with window', function () {
var source = 'window.angular.module("test");\nwindow.angular.module("another").controller("Ctrl", ["$scope", function ($scope) {}]);';
var deps = {
dependencies: ['ng', 'test', 'another'],
modules: {}
};
lookup(source).should.eql(deps);
});
All three tests failed. (Can give output if desired)
Is it possible to get this functionality added? How hard is it? I did a quick check on the code and it looks like the isAngularModuleStatement
just needs to be changed. I might attempt a pull request.
It breaks on the require of gulp-angular-filesort
:
TypeError: Object 0 has no method 'call'
at /Users/[...]/node_modules/gulp-angular-filesort/node_modules/ng-dependencies/node_modules/sugar/release/sugar-full.development.js:6126:12
Related issue on klei/gulp-angular-filesort#20
It looks like sugar breaks 6to5! Overriding prototypes is never a good idea!
TypeError: Object 0 has no method 'call'
at /Users/olivier/Projects/ng-tools/gulp-ng-channels/node_modules/gulp-angular-filesort/node_modules/ng-dependencies/node_modules/sugar/release/sugar-full.development.js:6126:12
at Array.forEach (native)
at extend.keys (/Users/olivier/Projects/ng-tools/gulp-ng-channels/node_modules/gulp-angular-filesort/node_modules/ng-dependencies/node_modules/sugar/release/sugar-full.development.js:6125:12)
at /Users/olivier/Projects/ng-tools/gulp-ng-channels/node_modules/gulp-angular-filesort/node_modules/ng-dependencies/node_modules/sugar/release/sugar-full.development.js:179:25
at Array.map (native)
at Array.<anonymous> (/Users/olivier/Projects/ng-tools/gulp-ng-channels/node_modules/gulp-angular-filesort/node_modules/ng-dependencies/node_modules/sugar/release/sugar-full.development.js:180:23)
at Object.<anonymous> (/Users/olivier/Projects/ng-tools/gulp-ng-channels/node_modules/gulp-6to5/node_modules/6to5-core/lib/6to5/traverse/scope.js:40:86)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/olivier/Projects/ng-tools/gulp-ng-channels/node_modules/gulp-6to5/node_modules/6to5-core/lib/6to5/traverse/index.js:7:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
You can reproduce error with this test
it('should ignore import in source', function () {
var source = 'import angular from "angular";\n' +
'angular.module("test", []);';
var deps = {
dependencies: ['ng'],
modules: {
'test': []
}
};
lookup(source).should.eql(deps);
});
result is Unexpected token error from esprima.
Esprima support ES6 modules, but you must use option sourceType in parse method options.
esprima.parse(source, {sourceType: "module"})
I can send pull request with fix (simply add this option to esprima.parse, or make it configurable by findDependencies options), and import will be ignored - but is it intended behavior?
(function () {
var App;
App = (function () {
function App() {
return ['dep1', 'dep2'];
}
return App;
})();
angular.module('app', new App());
}).call(this);
breaks on https://github.com/klei/ng-dependencies/blob/master/index.js#L32
The above file is the result of ng-classify followed by coffee -> js on this
class App extends App
constructor: ->
return [ 'dep1', 'dep2' ]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.