Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install 3rd party library #738

Closed
maxime1992 opened this issue May 12, 2016 · 5 comments
Closed

Install 3rd party library #738

maxime1992 opened this issue May 12, 2016 · 5 comments

Comments

@maxime1992
Copy link
Contributor

  1. OS? Linux (Ubuntu 16.04)
  2. Ng Version : 0.0.39
    Node : 5.11.1
    OS : Linux x64

I'm trying to add @ngrx to my NG2 app.

I followed the 3rd party libs https://github.com/angular/angular-cli/wiki/3rd-party-libs but still can't figure out how I should do that.

If I do that :

const barrels: string[] = [
  // Angular specific barrels.
  '@angular/core',
  '@angular/common',
  '@angular/compiler',
  '@angular/http',
  '@angular/router',
  '@angular/platform-browser',
  '@angular/platform-browser-dynamic',
  '@ngrx/store',
  ...

(notice the line '@ngrx/store' that I added by hand)

and that :

System.config({
  map: {
    '@angular': 'vendor/@angular',
    'rxjs': 'vendor/rxjs',
    'main': 'main.js',
    '@ngrx': 'vendor/@ngrx'
  },
  packages: cliSystemConfigPackages
});

(notice the line '@ngrx': 'vendor/@ngrx' that I added by hand)

BUT, those lines are after that :

////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
 * Everything underneath this line is managed by the CLI.
 **********************************************************************************************/

So I think I should put them somewhere here instead :

/***********************************************************************************************
 * User Configuration.
 **********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
   // here ?
};

/** User packages configuration. */
const packages: any = {
   // here ?
};

I just don't understand where to put it, any help on that would be nice :)

Thanks

@quentint
Copy link

I just updated the wiki and I think this section and this one could help.

Does it?

@dancoto
Copy link

dancoto commented May 13, 2016

In your system-config.ts file

/***********************************************************************************************
 * User Configuration.
 **********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
  '@ngrx': 'vendor/@ngrx'
};
// Thirdparty barrels.
  'rxjs',
  '@ngrx/store'

// Apply the CLI SystemJS configuration.
System.config({
  map: {
    '@angular': 'vendor/@angular',
    'rxjs': 'vendor/rxjs',
    'main': 'main.js',
    '@ngrx': 'vendor/@ngrx'
  },
  packages: _cliSystemConfig
});

Then in the angular-cli-build.js

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/*.js',
      'es6-shim/es6-shim.js',
      'reflect-metadata/*.js',
      'rxjs/**/*.js',
      '@angular/**/*.js',
      '@ngrx/**/*.js'
    ]
  });
};

That should get you going.

@maxime1992
Copy link
Contributor Author

@dcoto thanks for you help. I did try what you wrote and it's very similar to what I had.
Yes it's working, but as I say in my initial question, I feel like there's something wrong as we are writing after those lines :

////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
 * Everything underneath this line is managed by the CLI.
 **********************************************************************************************/

@quentint thank you too for your quick answer. Your update of the wiki did help a lot, it's working fine now by just updating the lines before those managed by the cli :

/***********************************************************************************************
 * User Configuration.
 **********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
    '@ngrx': 'vendor/@ngrx'
};

/** User packages configuration. */
const packages: any = {
    '@ngrx/store': {
        format: 'cjs',
        defaultExtension: 'js',
        main: 'index.js'
    },
};

// nothing as changed after that

Cheers !

@mangopop
Copy link

I am also trying to install ngrx but I cannot find any system-config.ts files in my project to edit?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants