Giter Club home page Giter Club logo

ng-dependencies's Issues

findDependencies ends with Unexpected token error if file contains import keyword

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?

Sugar dep breaks 6to5!

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)

window.angular.module("foo") not understood.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.