Install 3rd party library
- OS? Linux (Ubuntu 16.04)
- 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
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.
@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 !
I am also trying to install ngrx but I cannot find any system-config.ts files in my project to edit?
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.