Angular2-jwt: Compatibility with Angular2 CLI

Created on 19 Mar 2016  路  5Comments  路  Source: auth0/angular2-jwt

Can angular2-jwt be added to the DefinitelyTyped repo, like angular-jwt had been?

Adding it to the DefinitelyTyped repo is currently the path for compatibility with the Angular2 CLI

See: https://github.com/angular/angular-cli/issues/274

Most helpful comment

You'll need to add the following to get angular2-jwt to work with angular-cli:

In angular-cli-build.js:

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      // existing code
      // .....
      'angular2-jwt/**/*.+(js|js.map)'  // <---------------------------
    ]
  });
};

In system-config.ts:

/** Map relative paths to URLs. */
const map: any = {
  'angular2-jwt': 'vendor/angular2-jwt'  // <---------------------------
};

/** User packages configuration. */
const packages: any = {
  'angular2-jwt': {                      // <---------------------------
    main: 'angular2-jwt.js'              // <---------------------------
  },
};

Above seems to be working for me.
Source: https://github.com/angular/angular-cli/wiki/3rd-party-libs

All 5 comments

It is a native typescript library and as such does not need to be added to definitely typed.

got it - so typings install npm:angular2-jwt should do the trick?

I don't think you should need to do anything. typescript will pick up the typings from the node_modules/angular2-jwt folder. You should only need typings for projects that don't distribute their typings in their npm module.

Could be wrong though.

I added the following line in angular-cli-build.js:

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      // existing code
      // .....
      'angular2-jwt/**/*.+(js|js.map)' // <---------------------------
    ]
  });
};

Would this solve your issue? The .d.ts files are also in the npm package in case you need them for other purposes.

You'll need to add the following to get angular2-jwt to work with angular-cli:

In angular-cli-build.js:

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      // existing code
      // .....
      'angular2-jwt/**/*.+(js|js.map)'  // <---------------------------
    ]
  });
};

In system-config.ts:

/** Map relative paths to URLs. */
const map: any = {
  'angular2-jwt': 'vendor/angular2-jwt'  // <---------------------------
};

/** User packages configuration. */
const packages: any = {
  'angular2-jwt': {                      // <---------------------------
    main: 'angular2-jwt.js'              // <---------------------------
  },
};

Above seems to be working for me.
Source: https://github.com/angular/angular-cli/wiki/3rd-party-libs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leosvelperez picture leosvelperez  路  5Comments

n0490b picture n0490b  路  4Comments

wannabegeek picture wannabegeek  路  3Comments

Eddman picture Eddman  路  3Comments

sfabriece picture sfabriece  路  4Comments