rxaviers / cldr-data-npm

Npm module for Unicode CLDR JSON data
MIT License
42 stars 28 forks source link

cldr-data is getting installed twice by end-user applications #9

Closed rxaviers closed 9 years ago

rxaviers commented 9 years ago
$ npm install globalize
\
> cldr-data@26.0.10 install /tmp/node_modules/globalize/node_modules/cldr-data
> node install.js

GET `http://www.unicode.org/Public/cldr/26.0.1/json.zip`
  [========================================] 100% 0.0s
Received 3424K total.
Unpacking it into `./`
/
> cldr-data@26.0.10 install /tmp/node_modules/cldr-data
> node install.js

GET `http://www.unicode.org/Public/cldr/26.0.1/json.zip`
  [========================================] 100% 0.0s
Received 3424K total.
Unpacking it into `./`
cldr-data@26.0.10 node_modules/cldr-data
└── cldr-data-downloader@0.1.2 (progress@1.1.8, q@1.0.1, adm-zip@0.4.4, request-progress@0.3.1, nopt@3.0.1, mkdirp@0.5.0, npmconf@2.0.9, request@2.53.0)

globalize@1.0.0-alpha.17 node_modules/globalize
├── cldr-data@26.0.10 (cldr-data-downloader@0.1.2)
└── cldrjs@0.4.0

$ npm --version
1.4.23
rxaviers commented 9 years ago

It also happens with our example-application.

$ git checkout example-application 
Switched to branch 'example-application'
$ npm install
|
> cldr-data@26.0.10 install /userdata/external/cldr-data-npm/node_modules/cldr-data-example-library-foo/node_modules/cldr-data
> node install.js

GET `http://www.unicode.org/Public/cldr/26.0.1/json.zip`
  [========================================] 100% 0.0s
Received 3424K total.
Unpacking it into `./`
-
> cldr-data@26.0.10 install /userdata/external/cldr-data-npm/node_modules/cldr-data
> node install.js

GET `http://www.unicode.org/Public/cldr/26.0.1/json.zip`
  [========================================] 100% 0.0s
Received 3424K total.
Unpacking it into `./`
grunt-dco@0.0.3 node_modules/grunt-dco
└── dco@1.1.0 (git-tools@0.1.1, sane-email-validation@1.0.0)

matchdep@0.3.0 node_modules/matchdep
├── stack-trace@0.0.7
├── resolve@0.5.1
├── findup-sync@0.1.3 (lodash@2.4.1, glob@3.2.11)
└── globule@0.1.0 (lodash@1.0.1, glob@3.1.21, minimatch@0.2.14)

grunt@0.4.5 node_modules/grunt
├── which@1.0.9
├── dateformat@1.0.2-1.2.3
├── eventemitter2@0.4.14
├── getobject@0.1.0
├── rimraf@2.2.8
├── colors@0.6.2
├── async@0.1.22
├── grunt-legacy-util@0.2.0
├── hooker@0.2.3
├── exit@0.1.2
├── lodash@0.9.2
├── coffee-script@1.3.3
├── underscore.string@2.2.1
├── iconv-lite@0.2.11
├── nopt@1.0.10 (abbrev@1.0.5)
├── minimatch@0.2.14 (sigmund@1.0.0, lru-cache@2.5.0)
├── glob@3.1.21 (inherits@1.0.0, graceful-fs@1.2.3)
├── grunt-legacy-log@0.1.1 (underscore.string@2.3.3, lodash@2.4.1)
├── findup-sync@0.1.3 (lodash@2.4.1, glob@3.2.11)
└── js-yaml@2.0.5 (argparse@0.1.16, esprima@1.0.4)

grunt-contrib-jshint@0.10.0 node_modules/grunt-contrib-jshint
├── hooker@0.2.3
└── jshint@2.5.11 (strip-json-comments@1.0.2, underscore@1.6.0, exit@0.1.2, shelljs@0.3.0, console-browserify@1.1.0, minimatch@1.0.0, cli@0.6.5, htmlparser2@3.8.2)

cldr-data@26.0.10 node_modules/cldr-data
└── cldr-data-downloader@0.1.2 (progress@1.1.8, q@1.0.1, adm-zip@0.4.4, nopt@3.0.1, request-progress@0.3.1, mkdirp@0.5.0, npmconf@2.0.9, request@2.53.0)

cldr-data-example-library-foo@0.0.1 node_modules/cldr-data-example-library-foo
├── cldr-data@26.0.10 (cldr-data-downloader@0.1.2)
└── cldrjs@0.4.1
rxaviers commented 9 years ago

For some reason, cldr-data is getting installed on both paths below (analogous to what's happening to Globalize).

rxaviers commented 9 years ago
$ npm install globalize@1.0.0-alpha.10
-
> cldr-data@26.0.10 install /tmp/node_modules/cldr-data
> node install.js

GET `http://www.unicode.org/Public/cldr/26.0.1/json.zip`
  [========================================] 100% 0.0s
Received 3424K total.
Unpacking it into `./`
cldr-data@26.0.10 node_modules/cldr-data
└── cldr-data-downloader@0.1.2 (progress@1.1.8, q@1.0.1, adm-zip@0.4.4, nopt@3.0.1, request-progress@0.3.1, mkdirp@0.5.0, npmconf@2.0.9, request@2.53.0)

globalize@1.0.0-alpha.10 node_modules/globalize
└── cldrjs@0.3.9
rxaviers commented 9 years ago

Follow what's happening... Both Globalize and cldr-data-example-library-foo has (a) cldrjs as dependency and (b) cldr-data as peerDependency. Cldrjs, in turn, has (c) cldr-data as peerDependency.

For some unkown reason, the above dependency tree is why two copies are being installed. Because, using cldrjs 0.3.9 (that didn't had cldr-data declared as peerDependency), it installs only one copy as expected (in node_modules/cldr-data, not in node_modules//node_modules/).

rxaviers commented 9 years ago

I'm still unsure why this is happening. I'm confused, because cldr-data@26.0.10 is being installed twice:

npm install globalize.1.0.0-alpha.17

globalize/package.json:

"dependencies": {
  "cldrjs": "0.4.0"
},
"peerDependencies": {
  "cldr-data": ">=25"
},

cldrjs/package.json:

"peerDependencies": {
  "cldr-data": ">=25"
},

I've tested it using node 0.10.36, npm 1.4.28 and 2.5.1 (same behavior on both).

Why are the two copies of cldr-data@26.0.10 getting installed? They are identical and declared as a peer dependency.

├─┬ cldr-data@26.0.10
│ └─┬ cldr-data-downloader@0.1.2
│   ├── adm-zip@0.4.4
│   ├─┬ mkdirp@0.5.0
│   │ └── minimist@0.0.8
│   ├─┬ nopt@3.0.1
│   │ └── abbrev@1.0.5
│   ├─┬ npmconf@2.0.9
│   │ ├─┬ config-chain@1.1.8
│   │ │ └── proto-list@1.2.3
│   │ ├── inherits@2.0.1
│   │ ├── ini@1.3.3
│   │ ├─┬ once@1.3.1
│   │ │ └── wrappy@1.0.1
│   │ ├── osenv@0.1.0
│   │ ├── semver@4.3.1
│   │ └── uid-number@0.0.5
│   ├── progress@1.1.8
│   ├── q@1.0.1
│   ├─┬ request@2.53.0
│   │ ├── aws-sign2@0.5.0
│   │ ├─┬ bl@0.9.4
│   │ │ └─┬ readable-stream@1.0.33
│   │ │   ├── core-util-is@1.0.1
│   │ │   ├── inherits@2.0.1
│   │ │   ├── isarray@0.0.1
│   │ │   └── string_decoder@0.10.31
│   │ ├── caseless@0.9.0
│   │ ├─┬ combined-stream@0.0.7
│   │ │ └── delayed-stream@0.0.5
│   │ ├── forever-agent@0.5.2
│   │ ├─┬ form-data@0.2.0
│   │ │ └── async@0.9.0
│   │ ├─┬ hawk@2.3.1
│   │ │ ├── boom@2.6.1
│   │ │ ├── cryptiles@2.0.4
│   │ │ ├── hoek@2.11.0
│   │ │ └── sntp@1.0.9
│   │ ├─┬ http-signature@0.10.1
│   │ │ ├── asn1@0.1.11
│   │ │ ├── assert-plus@0.1.5
│   │ │ └── ctype@0.5.3
│   │ ├── isstream@0.1.1
│   │ ├── json-stringify-safe@5.0.0
│   │ ├─┬ mime-types@2.0.9
│   │ │ └── mime-db@1.7.0
│   │ ├── node-uuid@1.4.2
│   │ ├── oauth-sign@0.6.0
│   │ ├── qs@2.3.3
│   │ ├── stringstream@0.0.4
│   │ ├─┬ tough-cookie@0.12.1
│   │ │ └── punycode@1.3.2
│   │ └── tunnel-agent@0.4.0
│   └─┬ request-progress@0.3.1
│     └── throttleit@0.0.2
└─┬ globalize@1.0.0-alpha.17
  ├─┬ cldr-data@26.0.10
  │ └─┬ cldr-data-downloader@0.1.2
  │   ├── adm-zip@0.4.4
  │   ├─┬ mkdirp@0.5.0
  │   │ └── minimist@0.0.8
  │   ├─┬ nopt@3.0.1
  │   │ └── abbrev@1.0.5
  │   ├─┬ npmconf@2.0.9
  │   │ ├─┬ config-chain@1.1.8
  │   │ │ └── proto-list@1.2.3
  │   │ ├── inherits@2.0.1
  │   │ ├── ini@1.3.3
  │   │ ├─┬ once@1.3.1
  │   │ │ └── wrappy@1.0.1
  │   │ ├── osenv@0.1.0
  │   │ ├── semver@4.3.1
  │   │ └── uid-number@0.0.5
  │   ├── progress@1.1.8
  │   ├── q@1.0.1
  │   ├─┬ request@2.53.0
  │   │ ├── aws-sign2@0.5.0
  │   │ ├─┬ bl@0.9.4
  │   │ │ └─┬ readable-stream@1.0.33
  │   │ │   ├── core-util-is@1.0.1
  │   │ │   ├── inherits@2.0.1
  │   │ │   ├── isarray@0.0.1
  │   │ │   └── string_decoder@0.10.31
  │   │ ├── caseless@0.9.0
  │   │ ├─┬ combined-stream@0.0.7
  │   │ │ └── delayed-stream@0.0.5
  │   │ ├── forever-agent@0.5.2
  │   │ ├─┬ form-data@0.2.0
  │   │ │ └── async@0.9.0
  │   │ ├─┬ hawk@2.3.1
  │   │ │ ├── boom@2.6.1
  │   │ │ ├── cryptiles@2.0.4
  │   │ │ ├── hoek@2.11.0
  │   │ │ └── sntp@1.0.9
  │   │ ├─┬ http-signature@0.10.1
  │   │ │ ├── asn1@0.1.11
  │   │ │ ├── assert-plus@0.1.5
  │   │ │ └── ctype@0.5.3
  │   │ ├── isstream@0.1.1
  │   │ ├── json-stringify-safe@5.0.0
  │   │ ├─┬ mime-types@2.0.9
  │   │ │ └── mime-db@1.7.0
  │   │ ├── node-uuid@1.4.2
  │   │ ├── oauth-sign@0.6.0
  │   │ ├── qs@2.3.3
  │   │ ├── stringstream@0.0.4
  │   │ ├─┬ tough-cookie@0.12.1
  │   │ │ └── punycode@1.3.2
  │   │ └── tunnel-agent@0.4.0
  │   └─┬ request-progress@0.3.1
  │     └── throttleit@0.0.2
  └── cldrjs@0.4.0
rxaviers commented 9 years ago

Having cldr-data explicitly specified (e.g., npm install globalize cldr-data) solves this problem.

Given peer dependencies won't be automatically installed to fulfill the peerDependency attribute, I think the most sane thing to do here is to educate applications to explicitly specify cldr-data during the install.