From 1be94a82552ba164e36b6e73ccfe6922d86a8832 Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Thu, 23 Feb 2017 22:15:41 +0100 Subject: [PATCH] chore(peerDependencies): narrow angular peerDependencies to exclude versions with JSONP bug#13219 - add note in `README.md` regarding angular version and https://github.com/angular/angular/issues/13219 --- README.md | 10 ++++++++++ gulpfile.js | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee1170c0..c940559c 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,16 @@ Install it with npm `npm install ng2-sharebuttons --save` +> **Note**: Make sure you are using a version of `@angular` in the following ranges: +> * `>=2.0.0 and <2.4.6` or +> * `>=2.4.8 and <4.0.0-beta.6` or +> * `>=4.0.0-beta.8` +> +> In fact, a bug(#13219) in `@angular/http`(JSONP) was introduced in [`2.4.6`](https://github.com/angular/angular/commit/1eece50)(resp. [`4.0.0-beta.6`](https://github.com/angular/angular/commit/9e5617e)) and fixed in [`2.4.8`](https://github.com/angular/angular/commit/9ceb5d1)(resp. [`4.0.0-beta.8`](https://github.com/angular/angular/commit/4676df5)). +> It affects JSONP and the count of number of shares for some buttons (linkedin and tumblr). +> +> See angular's [CHANGELOG](https://github.com/angular/angular/blob/master/CHANGELOG.md) for details. + ### SystemJS If you are using SystemJS, you should also adjust your configuration to point to the UMD bundle. diff --git a/gulpfile.js b/gulpfile.js index d5244694..8005a39c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -201,7 +201,16 @@ gulp.task('package', (cb) => { // defines project's dependencies as 'peerDependencies' for final users targetPkgJson.peerDependencies = {}; Object.keys(pkgJson.dependencies).forEach((dependency) => { - targetPkgJson.peerDependencies[dependency] = `^${pkgJson.dependencies[dependency]}`; + if (dependency.startsWith('@angular/')) { + // narrow version of @angular packages to address bug with JSONP inroduced in [2.4.6, 2.4.8[ && [4.0.0-beta.6, 4.0.0-beta.8[ + // see https://github.com/angular/angular/pull/13219 and changelog + targetPkgJson.peerDependencies[dependency] = `>=2.0.0 <2.4.6 || >=2.4.8 <4.0.0-beta.6 || >=4.0.0-beta.8`; + } + else { + targetPkgJson.peerDependencies[dependency] = `^${pkgJson.dependencies[dependency]}`; + + } + }); // copy the needed additional files in the 'dist' folder