Skip to content

Integration with Angular-CLI #113

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

Closed
mb-jenks opened this issue May 17, 2016 · 5 comments
Closed

Integration with Angular-CLI #113

mb-jenks opened this issue May 17, 2016 · 5 comments
Assignees

Comments

@mb-jenks
Copy link

Is there a way to provide a /dist folder for integrating with angular-cli projects? Because of the mapping associated with the angular-cli build, its really difficult to use the ng2-redux package, specifically its dependency on lodash and the mapping of rxjs within the src files (the angular-cli uses rxjs/Rx).

@SethDavenport
Copy link
Member

@mb-jenks I've only just started playing with angular-cli myself, but it's definitely something we should be able to work with. We'll look into it.

SethDavenport pushed a commit to SethDavenport/ng2-redux that referenced this issue May 22, 2016
Apart from making the lib less complex, it also makes it easier to handle with SystemJS. This is important given that the Angular-CLI has embraced SystemJS instead of our usual webpack toolchain.

Also rejigged the deps a bit:
- typings should be a devdepedency
- Angular and RxJS should be peer deps

Connected to angular-redux#113
@SethDavenport SethDavenport self-assigned this May 22, 2016
SethDavenport pushed a commit to SethDavenport/ng2-redux that referenced this issue May 22, 2016
Apart from making the lib less complex, it also makes it easier to handle with SystemJS. This is important given that the Angular-CLI has embraced SystemJS instead of our usual webpack toolchain.

Also rejigged the deps a bit:
- typings should be a devdepedency
- Angular and RxJS should be peer deps

Connected to angular-redux#113
SethDavenport pushed a commit to SethDavenport/ng2-redux that referenced this issue May 22, 2016
Apart from making the lib less complex, it also makes it easier to handle with SystemJS. This is important given that the Angular-CLI has embraced SystemJS instead of our usual webpack toolchain.

Also rejigged the deps a bit:
- typings should be a devdepedency
- Angular and RxJS should be peer deps

Connected to angular-redux#113
@SethDavenport
Copy link
Member

SethDavenport commented May 22, 2016

With PR #115 , I'm able to generate a lib folder that works with a simple angular-cli app I wrote. The other secret sauce is to add the following configs to your Angular-CLI-generated app (see the angular-cli docs):

in angular-cli-build.js:

/* global require, module */

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

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
       //...
      'redux/dist/redux.js',
      'ng2-redux/lib/**/*.+(js|js.map)'
    ]
  });
};

and in src/system-config.ts:

const map: any = {
  redux: 'vendor/redux/dist/redux.js',
  'ng2-redux': 'vendor/ng2-redux/lib'
};

/** User packages configuration. */
const packages: any = {
  'ng2-redux': {
    format: 'cjs',
    defaultExtension: 'js',
    main: 'index'
  }
};

Ah, the joys of SystemJS I thought I left behind me when we switched to Webpack. Now the CLI is sucking me back into SystemJS' rabbit hole of redundant configs ;)

As an aside, I logged issue angular/angular-cli#882 against the CLI to see if there are plans to simplify bringing in libs from NPM, we'll see if anything transpires there (* cough * ditching SystemJS * cough *).

@mb-jenks
Copy link
Author

mb-jenks commented Jun 3, 2016

Thanks @SethDavenport ! Do you know when the changes will be merged with master? The systemjs configs are a pain but I've got them working for now.

@SethDavenport
Copy link
Member

Waiting for the go-ahead from @e-schultz

e-schultz pushed a commit that referenced this issue Jun 8, 2016
* Remove lodash as a dependency

Apart from making the lib less complex, it also makes it easier to handle with SystemJS. This is important given that the Angular-CLI has embraced SystemJS instead of our usual webpack toolchain.

Also rejigged the deps a bit:
- typings should be a devdepedency
- Angular and RxJS should be peer deps

Connected to #113

* Changed rxjs imports to pull in the parts we need.

This is needed to match the default way Angular-CLI sets up the SystemJS import mappings for RxJs.
Arguably this is the right way to do it anyway; we already switched to this in the v3.x branch.
@e-schultz
Copy link
Member

@mb-jenks @SethDavenport changes are merged in, and a v2.3.4 has just been published on npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants