Improve performance of node-haste2 and react-packager

Reviewed By: davidaurelio

Differential Revision: D2911210

fb-gh-sync-id: 8ac2f213e8a9e089281bb065f9a7190d2e0f5b18
shipit-source-id: 8ac2f213e8a9e089281bb065f9a7190d2e0f5b18
This commit is contained in:
Christoph Pojer 2016-02-15 22:33:11 -08:00 коммит произвёл facebook-github-bot-8
Родитель 9856a97267
Коммит 9a918ef48f
24 изменённых файлов: 331 добавлений и 346 удалений

221
npm-shrinkwrap.json сгенерированный
Просмотреть файл

@ -127,30 +127,30 @@
"from": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz", "from": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz",
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz" "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz"
}, },
"globals": {
"version": "6.4.1",
"from": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz",
"resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz"
},
"babylon": { "babylon": {
"version": "5.8.29", "version": "5.8.29",
"from": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz", "from": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz" "resolved": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz"
}, },
"globals": {
"version": "6.4.1",
"from": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz",
"resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz"
},
"js-tokens": { "js-tokens": {
"version": "1.0.1", "version": "1.0.1",
"from": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz", "from": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz" "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz"
}, },
"recast": {
"version": "0.10.33",
"from": "https://registry.npmjs.org/recast/-/recast-0.10.33.tgz",
"resolved": "https://registry.npmjs.org/recast/-/recast-0.10.33.tgz"
},
"regenerator": { "regenerator": {
"version": "0.8.40", "version": "0.8.40",
"from": "https://registry.npmjs.org/regenerator/-/regenerator-0.8.40.tgz", "from": "https://registry.npmjs.org/regenerator/-/regenerator-0.8.40.tgz",
"resolved": "https://registry.npmjs.org/regenerator/-/regenerator-0.8.40.tgz" "resolved": "https://registry.npmjs.org/regenerator/-/regenerator-0.8.40.tgz"
},
"recast": {
"version": "0.10.33",
"from": "https://registry.npmjs.org/recast/-/recast-0.10.33.tgz",
"resolved": "https://registry.npmjs.org/recast/-/recast-0.10.33.tgz"
} }
} }
}, },
@ -228,16 +228,16 @@
"from": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz", "from": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz",
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz" "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz"
}, },
"babylon": {
"version": "5.8.29",
"from": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz"
},
"globals": { "globals": {
"version": "6.4.1", "version": "6.4.1",
"from": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz", "from": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz",
"resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz" "resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz"
}, },
"babylon": {
"version": "5.8.29",
"from": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-5.8.29.tgz"
},
"js-tokens": { "js-tokens": {
"version": "1.0.1", "version": "1.0.1",
"from": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz", "from": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz",
@ -1814,6 +1814,11 @@
"from": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.1.0.tgz", "from": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.1.0.tgz" "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.1.0.tgz"
}, },
"fast-path": {
"version": "1.1.0",
"from": "fast-path@*",
"resolved": "https://registry.npmjs.org/fast-path/-/fast-path-1.1.0.tgz"
},
"fbjs": { "fbjs": {
"version": "0.6.0", "version": "0.6.0",
"from": "https://registry.npmjs.org/fbjs/-/fbjs-0.6.0.tgz", "from": "https://registry.npmjs.org/fbjs/-/fbjs-0.6.0.tgz",
@ -1890,76 +1895,71 @@
} }
} }
}, },
"abbrev": {
"version": "1.0.7",
"from": "abbrev@1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz"
},
"ansi": { "ansi": {
"version": "0.3.0", "version": "0.3.0",
"from": "ansi@~0.3.0", "from": "ansi@~0.3.0",
"resolved": "https://registry.npmjs.org/ansi/-/ansi-0.3.0.tgz" "resolved": "https://registry.npmjs.org/ansi/-/ansi-0.3.0.tgz"
}, },
"ansi-regex": {
"version": "2.0.0",
"from": "ansi-regex@^2.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz"
},
"ansi-styles": { "ansi-styles": {
"version": "2.1.0", "version": "2.1.0",
"from": "ansi-styles@^2.1.0", "from": "ansi-styles@^2.1.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz" "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.1.0.tgz"
}, },
"are-we-there-yet": { "abbrev": {
"version": "1.0.4", "version": "1.0.7",
"from": "are-we-there-yet@~1.0.0", "from": "abbrev@1",
"resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.4.tgz" "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz"
},
"ansi-regex": {
"version": "2.0.0",
"from": "ansi-regex@^2.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz"
}, },
"asn1": { "asn1": {
"version": "0.1.11", "version": "0.1.11",
"from": "asn1@0.1.11", "from": "asn1@0.1.11",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz" "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz"
}, },
"assert-plus": { "are-we-there-yet": {
"version": "0.1.5", "version": "1.0.4",
"from": "assert-plus@^0.1.5", "from": "are-we-there-yet@~1.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz" "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.0.4.tgz"
},
"async": {
"version": "1.5.0",
"from": "async@^1.4.0",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.0.tgz"
}, },
"aws-sign2": { "aws-sign2": {
"version": "0.6.0", "version": "0.6.0",
"from": "aws-sign2@~0.6.0", "from": "aws-sign2@~0.6.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz" "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz"
}, },
"async": {
"version": "1.5.0",
"from": "async@^1.4.0",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.0.tgz"
},
"assert-plus": {
"version": "0.1.5",
"from": "assert-plus@^0.1.5",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz"
},
"balanced-match": { "balanced-match": {
"version": "0.2.1", "version": "0.2.1",
"from": "balanced-match@>=0.2.0 <0.3.0", "from": "balanced-match@>=0.2.0 <0.3.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.1.tgz" "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.1.tgz"
}, },
"block-stream": {
"version": "0.0.8",
"from": "block-stream@*",
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.8.tgz"
},
"boom": { "boom": {
"version": "2.10.1", "version": "2.10.1",
"from": "boom@^2.8.x", "from": "boom@^2.8.x",
"resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz" "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz"
}, },
"block-stream": {
"version": "0.0.8",
"from": "block-stream@*",
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.8.tgz"
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.1", "version": "1.1.1",
"from": "brace-expansion@>=1.0.0 <2.0.0", "from": "brace-expansion@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.1.tgz" "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.1.tgz"
}, },
"caseless": {
"version": "0.11.0",
"from": "caseless@~0.11.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz"
},
"chalk": { "chalk": {
"version": "1.1.1", "version": "1.1.1",
"from": "chalk@^1.1.1", "from": "chalk@^1.1.1",
@ -1970,21 +1970,26 @@
"from": "combined-stream@~1.0.5", "from": "combined-stream@~1.0.5",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz" "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz"
}, },
"caseless": {
"version": "0.11.0",
"from": "caseless@~0.11.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz"
},
"commander": { "commander": {
"version": "2.9.0", "version": "2.9.0",
"from": "commander@^2.8.1", "from": "commander@^2.8.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz" "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz"
}, },
"concat-map": {
"version": "0.0.1",
"from": "concat-map@0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
},
"core-util-is": { "core-util-is": {
"version": "1.0.1", "version": "1.0.1",
"from": "core-util-is@~1.0.0", "from": "core-util-is@~1.0.0",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz"
}, },
"concat-map": {
"version": "0.0.1",
"from": "concat-map@0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
},
"cryptiles": { "cryptiles": {
"version": "2.0.5", "version": "2.0.5",
"from": "cryptiles@2.x.x", "from": "cryptiles@2.x.x",
@ -1995,16 +2000,16 @@
"from": "ctype@0.5.3", "from": "ctype@0.5.3",
"resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz" "resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz"
}, },
"debug": {
"version": "0.7.4",
"from": "debug@~0.7.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz"
},
"deep-extend": { "deep-extend": {
"version": "0.2.11", "version": "0.2.11",
"from": "deep-extend@~0.2.5", "from": "deep-extend@~0.2.5",
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.11.tgz" "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.2.11.tgz"
}, },
"debug": {
"version": "0.7.4",
"from": "debug@~0.7.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz"
},
"delayed-stream": { "delayed-stream": {
"version": "1.0.0", "version": "1.0.0",
"from": "delayed-stream@~1.0.0", "from": "delayed-stream@~1.0.0",
@ -2055,16 +2060,16 @@
"from": "generate-object-property@^1.1.0", "from": "generate-object-property@^1.1.0",
"resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz" "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz"
}, },
"graceful-fs": {
"version": "4.1.2",
"from": "graceful-fs@4.1",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.2.tgz"
},
"graceful-readlink": { "graceful-readlink": {
"version": "1.0.1", "version": "1.0.1",
"from": "graceful-readlink@>= 1.0.0", "from": "graceful-readlink@>= 1.0.0",
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz"
}, },
"graceful-fs": {
"version": "4.1.2",
"from": "graceful-fs@4.1",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.2.tgz"
},
"har-validator": { "har-validator": {
"version": "2.0.2", "version": "2.0.2",
"from": "har-validator@~2.0.2", "from": "har-validator@~2.0.2",
@ -2110,11 +2115,6 @@
"from": "is-my-json-valid@^2.12.2", "from": "is-my-json-valid@^2.12.2",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz" "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz"
}, },
"is-property": {
"version": "1.0.2",
"from": "is-property@^1.0.0",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz"
},
"isarray": { "isarray": {
"version": "0.0.1", "version": "0.0.1",
"from": "isarray@0.0.1", "from": "isarray@0.0.1",
@ -2125,21 +2125,26 @@
"from": "isstream@~0.1.2", "from": "isstream@~0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz" "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz"
}, },
"is-property": {
"version": "1.0.2",
"from": "is-property@^1.0.0",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz"
},
"json-stringify-safe": { "json-stringify-safe": {
"version": "5.0.1", "version": "5.0.1",
"from": "json-stringify-safe@~5.0.1", "from": "json-stringify-safe@~5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz"
}, },
"jsonpointer": {
"version": "2.0.0",
"from": "jsonpointer@2.0.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz"
},
"lodash._basetostring": { "lodash._basetostring": {
"version": "3.0.1", "version": "3.0.1",
"from": "lodash._basetostring@^3.0.0", "from": "lodash._basetostring@^3.0.0",
"resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz" "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz"
}, },
"jsonpointer": {
"version": "2.0.0",
"from": "jsonpointer@2.0.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz"
},
"lodash._createpadding": { "lodash._createpadding": {
"version": "3.6.1", "version": "3.6.1",
"from": "lodash._createpadding@^3.0.0", "from": "lodash._createpadding@^3.0.0",
@ -2150,31 +2155,31 @@
"from": "lodash.pad@^3.0.0", "from": "lodash.pad@^3.0.0",
"resolved": "https://registry.npmjs.org/lodash.pad/-/lodash.pad-3.1.1.tgz" "resolved": "https://registry.npmjs.org/lodash.pad/-/lodash.pad-3.1.1.tgz"
}, },
"lodash.padleft": {
"version": "3.1.1",
"from": "lodash.padleft@^3.0.0",
"resolved": "https://registry.npmjs.org/lodash.padleft/-/lodash.padleft-3.1.1.tgz"
},
"lodash.padright": { "lodash.padright": {
"version": "3.1.1", "version": "3.1.1",
"from": "lodash.padright@^3.0.0", "from": "lodash.padright@^3.0.0",
"resolved": "https://registry.npmjs.org/lodash.padright/-/lodash.padright-3.1.1.tgz" "resolved": "https://registry.npmjs.org/lodash.padright/-/lodash.padright-3.1.1.tgz"
}, },
"lodash.padleft": {
"version": "3.1.1",
"from": "lodash.padleft@^3.0.0",
"resolved": "https://registry.npmjs.org/lodash.padleft/-/lodash.padleft-3.1.1.tgz"
},
"lodash.repeat": { "lodash.repeat": {
"version": "3.0.1", "version": "3.0.1",
"from": "lodash.repeat@^3.0.0", "from": "lodash.repeat@^3.0.0",
"resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.1.tgz" "resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-3.0.1.tgz"
}, },
"mime-db": {
"version": "1.19.0",
"from": "mime-db@~1.19.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.19.0.tgz"
},
"mime-types": { "mime-types": {
"version": "2.1.7", "version": "2.1.7",
"from": "mime-types@~2.1.7", "from": "mime-types@~2.1.7",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.7.tgz" "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.7.tgz"
}, },
"mime-db": {
"version": "1.19.0",
"from": "mime-db@~1.19.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.19.0.tgz"
},
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"from": "minimist@0.0.8", "from": "minimist@0.0.8",
@ -2195,21 +2200,26 @@
"from": "npmlog@~1.2.0", "from": "npmlog@~1.2.0",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-1.2.1.tgz" "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-1.2.1.tgz"
}, },
"oauth-sign": {
"version": "0.8.0",
"from": "oauth-sign@~0.8.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.0.tgz"
},
"once": { "once": {
"version": "1.1.1", "version": "1.1.1",
"from": "once@~1.1.1", "from": "once@~1.1.1",
"resolved": "https://registry.npmjs.org/once/-/once-1.1.1.tgz" "resolved": "https://registry.npmjs.org/once/-/once-1.1.1.tgz"
}, },
"oauth-sign": {
"version": "0.8.0",
"from": "oauth-sign@~0.8.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.0.tgz"
},
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.0", "version": "1.0.0",
"from": "path-is-absolute@>=1.0.0 <2.0.0", "from": "path-is-absolute@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz"
}, },
"qs": {
"version": "5.2.0",
"from": "qs@~5.2.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz"
},
"pinkie": { "pinkie": {
"version": "1.0.0", "version": "1.0.0",
"from": "pinkie@^1.0.0", "from": "pinkie@^1.0.0",
@ -2220,11 +2230,6 @@
"from": "pinkie-promise@^1.0.0", "from": "pinkie-promise@^1.0.0",
"resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-1.0.0.tgz" "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-1.0.0.tgz"
}, },
"qs": {
"version": "5.2.0",
"from": "qs@~5.2.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz"
},
"readable-stream": { "readable-stream": {
"version": "1.1.13", "version": "1.1.13",
"from": "readable-stream@^1.1.13", "from": "readable-stream@^1.1.13",
@ -2235,16 +2240,16 @@
"from": "request@2.x", "from": "request@2.x",
"resolved": "https://registry.npmjs.org/request/-/request-2.65.0.tgz" "resolved": "https://registry.npmjs.org/request/-/request-2.65.0.tgz"
}, },
"semver": {
"version": "5.0.3",
"from": "semver@~5.0.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz"
},
"sntp": { "sntp": {
"version": "1.0.9", "version": "1.0.9",
"from": "sntp@1.x.x", "from": "sntp@1.x.x",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz"
}, },
"semver": {
"version": "5.0.3",
"from": "semver@~5.0.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz"
},
"string_decoder": { "string_decoder": {
"version": "0.10.31", "version": "0.10.31",
"from": "string_decoder@~0.10.x", "from": "string_decoder@~0.10.x",
@ -2255,26 +2260,26 @@
"from": "stringstream@~0.0.4", "from": "stringstream@~0.0.4",
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz" "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz"
}, },
"strip-ansi": {
"version": "3.0.0",
"from": "strip-ansi@^3.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz"
},
"strip-json-comments": { "strip-json-comments": {
"version": "0.1.3", "version": "0.1.3",
"from": "strip-json-comments@0.1.x", "from": "strip-json-comments@0.1.x",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz" "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz"
}, },
"supports-color": {
"version": "2.0.0",
"from": "supports-color@^2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz"
},
"tar": { "tar": {
"version": "2.2.1", "version": "2.2.1",
"from": "tar@~2.2.0", "from": "tar@~2.2.0",
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz" "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz"
}, },
"strip-ansi": {
"version": "3.0.0",
"from": "strip-ansi@^3.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.0.tgz"
},
"supports-color": {
"version": "2.0.0",
"from": "supports-color@^2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz"
},
"tough-cookie": { "tough-cookie": {
"version": "2.2.0", "version": "2.2.0",
"from": "tough-cookie@~2.2.0", "from": "tough-cookie@~2.2.0",

Просмотреть файл

@ -75,7 +75,8 @@
], ],
"unmockedModulePathPatterns": [ "unmockedModulePathPatterns": [
"promise", "promise",
"source-map" "source-map",
"fast-path"
] ]
}, },
"main": "Libraries/react-native/react-native.js", "main": "Libraries/react-native/react-native.js",
@ -122,6 +123,7 @@
"connect": "^2.8.3", "connect": "^2.8.3",
"debug": "^2.2.0", "debug": "^2.2.0",
"event-target-shim": "^1.0.5", "event-target-shim": "^1.0.5",
"fast-path": "^1.1.0",
"fbjs": "^0.6.0", "fbjs": "^0.6.0",
"fbjs-scripts": "^0.4.0", "fbjs-scripts": "^0.4.0",
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",

1
packager/react-packager/index.js поставляемый
Просмотреть файл

@ -10,6 +10,7 @@
require('../babelRegisterOnly')([/react-packager\/src/]); require('../babelRegisterOnly')([/react-packager\/src/]);
require('fast-path').replace();
useGracefulFs(); useGracefulFs();
var debug = require('debug'); var debug = require('debug');

Просмотреть файл

@ -51,11 +51,9 @@ class Cache {
throw new Error('Use absolute paths'); throw new Error('Use absolute paths');
} }
var recordP = this.has(filepath, field) return this.has(filepath, field)
? this._data[filepath].data[field] ? this._data[filepath].data[field]
: this.set(filepath, field, loaderCb(filepath)); : this.set(filepath, field, loaderCb(filepath));
return recordP.then(record => record);
} }
invalidate(filepath, field) { invalidate(filepath, field) {

Просмотреть файл

@ -9,7 +9,7 @@
'use strict'; 'use strict';
const crypto = require('crypto'); const crypto = require('crypto');
const path = require('path'); const path = require('fast-path');
function getCacheFilePath(tmpdir, ...args) { function getCacheFilePath(tmpdir, ...args) {
const hash = crypto.createHash('md5'); const hash = crypto.createHash('md5');

Просмотреть файл

@ -8,7 +8,7 @@
*/ */
'use strict'; 'use strict';
const path = require('path'); const path = require('fast-path');
class DependencyGraphHelpers { class DependencyGraphHelpers {
constructor({ providesModuleNodeModules, assetExts }) { constructor({ providesModuleNodeModules, assetExts }) {
@ -17,17 +17,13 @@ class DependencyGraphHelpers {
} }
isNodeModulesDir(file) { isNodeModulesDir(file) {
let parts = path.normalize(file).split(path.sep); const index = file.lastIndexOf('/node_modules/');
const indexOfNodeModules = parts.lastIndexOf('node_modules'); if (index === -1) {
if (indexOfNodeModules === -1) {
return false; return false;
} }
parts = parts.slice(indexOfNodeModules + 1); const parts = file.substr(index + 14).split(path.sep);
const dirs = this._providesModuleNodeModules; const dirs = this._providesModuleNodeModules;
for (let i = 0; i < dirs.length; i++) { for (let i = 0; i < dirs.length; i++) {
if (parts.indexOf(dirs[i]) > -1) { if (parts.indexOf(dirs[i]) > -1) {
return false; return false;
@ -42,7 +38,7 @@ class DependencyGraphHelpers {
} }
extname(name) { extname(name) {
return path.extname(name).replace(/^\./, ''); return path.extname(name).substr(1);
} }
} }

Просмотреть файл

@ -11,7 +11,7 @@
const AssetModule_DEPRECATED = require('../AssetModule_DEPRECATED'); const AssetModule_DEPRECATED = require('../AssetModule_DEPRECATED');
const Fastfs = require('../fastfs'); const Fastfs = require('../fastfs');
const debug = require('debug')('ReactNativePackager:DependencyGraph'); const debug = require('debug')('ReactNativePackager:DependencyGraph');
const path = require('path'); const path = require('fast-path');
const Promise = require('promise'); const Promise = require('promise');
class DeprecatedAssetMap { class DeprecatedAssetMap {
@ -23,8 +23,9 @@ class DeprecatedAssetMap {
ignoreFilePath, ignoreFilePath,
helpers, helpers,
activity, activity,
enabled,
}) { }) {
if (roots == null || roots.length === 0) { if (roots == null || roots.length === 0 || !enabled) {
this._disabled = true; this._disabled = true;
return; return;
} }
@ -32,16 +33,19 @@ class DeprecatedAssetMap {
this._helpers = helpers; this._helpers = helpers;
this._map = Object.create(null); this._map = Object.create(null);
this._assetExts = assetExts; this._assetExts = assetExts;
this._activity = activity;
if (!this._disabled) {
this._fastfs = new Fastfs( this._fastfs = new Fastfs(
'Assets', 'Assets',
roots, roots,
fileWatcher, fileWatcher,
{ ignore: ignoreFilePath, crawling: fsCrawl, activity } { ignore: ignoreFilePath, crawling: fsCrawl, activity }
); );
this._activity = activity;
this._fastfs.on('change', this._processFileChange.bind(this)); this._fastfs.on('change', this._processFileChange.bind(this));
} }
}
build() { build() {
if (this._disabled) { if (this._disabled) {
@ -89,7 +93,7 @@ class DeprecatedAssetMap {
if (this._assetExts.indexOf(ext) !== -1) { if (this._assetExts.indexOf(ext) !== -1) {
const name = assetName(file, ext); const name = assetName(file, ext);
if (this._map[name] != null) { if (this._map[name] != null) {
debug('Conflcting assets', name); debug('Conflicting assets', name);
} }
this._map[name] = new AssetModule_DEPRECATED({ file }); this._map[name] = new AssetModule_DEPRECATED({ file });

Просмотреть файл

@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
'use strict'; 'use strict';
const path = require('path'); const path = require('fast-path');
const getPlatformExtension = require('../lib/getPlatformExtension'); const getPlatformExtension = require('../lib/getPlatformExtension');
const Promise = require('promise'); const Promise = require('promise');
@ -31,18 +31,18 @@ class HasteMap {
build() { build() {
this._map = Object.create(null); this._map = Object.create(null);
const promises = [];
let promises = this._fastfs.findFilesByExts(this._extensions, { this._fastfs.getAllFiles().forEach(filePath => {
ignore: (file) => this._helpers.isNodeModulesDir(file), if (!this._helpers.isNodeModulesDir(filePath)) {
}).map(file => this._processHasteModule(file)); if (this._extensions.indexOf(path.extname(filePath).substr(1)) !== -1) {
promises.push(this._processHasteModule(filePath));
promises = promises.concat( }
this._fastfs.findFilesByName('package.json', { if (filePath.endsWith('/package.json')) {
ignore: (file) => this._helpers.isNodeModulesDir(file), promises.push(this._processHastePackage(filePath));
}).map(file => this._processHastePackage(file)) }
); }
});
return Promise.all(promises); return Promise.all(promises).then(() => this._map);
} }
processFileChange(type, absPath) { processFileChange(type, absPath) {
@ -106,7 +106,7 @@ class HasteMap {
_processHastePackage(file) { _processHastePackage(file) {
file = path.resolve(file); file = path.resolve(file);
const p = this._moduleCache.getPackage(file, this._fastfs); const p = this._moduleCache.getPackage(file);
return p.isHaste() return p.isHaste()
.then(isHaste => isHaste && p.getName() .then(isHaste => isHaste && p.getName()
.then(name => this._updateHasteMap(name, p))) .then(name => this._updateHasteMap(name, p)))

Просмотреть файл

@ -10,7 +10,8 @@
const debug = require('debug')('ReactNativePackager:DependencyGraph'); const debug = require('debug')('ReactNativePackager:DependencyGraph');
const util = require('util'); const util = require('util');
const path = require('path'); const path = require('fast-path');
const realPath = require('path');
const isAbsolutePath = require('absolute-path'); const isAbsolutePath = require('absolute-path');
const getAssetDataFromName = require('../lib/getAssetDataFromName'); const getAssetDataFromName = require('../lib/getAssetDataFromName');
const Promise = require('promise'); const Promise = require('promise');
@ -287,7 +288,7 @@ class ResolutionRequest {
const searchQueue = []; const searchQueue = [];
for (let currDir = path.dirname(fromModule.path); for (let currDir = path.dirname(fromModule.path);
currDir !== path.parse(fromModule.path).root; currDir !== realPath.parse(fromModule.path).root;
currDir = path.dirname(currDir)) { currDir = path.dirname(currDir)) {
searchQueue.push( searchQueue.push(
path.join(currDir, 'node_modules', realModuleName) path.join(currDir, 'node_modules', realModuleName)

Просмотреть файл

@ -14,7 +14,7 @@ const Promise = require('promise');
const crawl = require('../crawlers'); const crawl = require('../crawlers');
const getPlatformExtension = require('../lib/getPlatformExtension'); const getPlatformExtension = require('../lib/getPlatformExtension');
const isAbsolutePath = require('absolute-path'); const isAbsolutePath = require('absolute-path');
const path = require('path'); const path = require('fast-path');
const util = require('util'); const util = require('util');
const DependencyGraphHelpers = require('./DependencyGraphHelpers'); const DependencyGraphHelpers = require('./DependencyGraphHelpers');
const ResolutionRequest = require('./ResolutionRequest'); const ResolutionRequest = require('./ResolutionRequest');
@ -46,6 +46,7 @@ class DependencyGraph {
extractRequires, extractRequires,
transformCode, transformCode,
shouldThrowOnUnresolvedErrors = () => true, shouldThrowOnUnresolvedErrors = () => true,
enableAssetMap,
}) { }) {
this._opts = { this._opts = {
activity: activity || defaultActivity, activity: activity || defaultActivity,
@ -60,8 +61,9 @@ class DependencyGraph {
extensions: extensions || ['js', 'json'], extensions: extensions || ['js', 'json'],
mocksPattern, mocksPattern,
extractRequires, extractRequires,
shouldThrowOnUnresolvedErrors,
transformCode, transformCode,
shouldThrowOnUnresolvedErrors,
enableAssetMap: enableAssetMap || true,
}; };
this._cache = cache; this._cache = cache;
this._helpers = new DependencyGraphHelpers(this._opts); this._helpers = new DependencyGraphHelpers(this._opts);
@ -121,25 +123,33 @@ class DependencyGraph {
ignoreFilePath: this._opts.ignoreFilePath, ignoreFilePath: this._opts.ignoreFilePath,
assetExts: this._opts.assetExts, assetExts: this._opts.assetExts,
activity: this._opts.activity, activity: this._opts.activity,
enabled: this._opts.enableAssetMap,
}); });
this._loading = Promise.all([ this._loading = Promise.all([
this._fastfs.build() this._fastfs.build()
.then(() => { .then(() => {
const hasteActivity = activity.startEvent('Building Haste Map'); const hasteActivity = activity.startEvent('Building Haste Map');
return this._hasteMap.build().then(() => activity.endEvent(hasteActivity)); return this._hasteMap.build().then(map => {
activity.endEvent(hasteActivity);
return map;
});
}), }),
this._deprecatedAssetMap.build(), this._deprecatedAssetMap.build(),
]).then(() => ]).then(
activity.endEvent(depGraphActivity) response => {
).catch(err => { activity.endEvent(depGraphActivity);
return response[0]; // Return the haste map
},
err => {
const error = new Error( const error = new Error(
`Failed to build DependencyGraph: ${err.message}` `Failed to build DependencyGraph: ${err.message}`
); );
error.type = ERROR_BUILDING_DEP_GRAPH; error.type = ERROR_BUILDING_DEP_GRAPH;
error.stack = err.stack; error.stack = err.stack;
throw error; throw error;
}); }
);
return this._loading; return this._loading;
} }

Просмотреть файл

@ -10,4 +10,5 @@
module.exports = { module.exports = {
WatchmanWatcher: jest.genMockFromModule('sane/src/watchman_watcher'), WatchmanWatcher: jest.genMockFromModule('sane/src/watchman_watcher'),
NodeWatcher: jest.genMockFromModule('sane/src/node_watcher'),
}; };

Просмотреть файл

@ -13,23 +13,27 @@ jest
.dontMock('events') .dontMock('events')
.dontMock('../') .dontMock('../')
.setMock('child_process', { .setMock('child_process', {
exec: function(cmd, cb) { exec: (cmd, cb) => cb(null, '/usr/bin/watchman'),
cb(null, '/usr/bin/watchman');
},
}); });
var sane = require('sane'); const sane = require('sane');
describe('FileWatcher', function() { describe('FileWatcher', () => {
var Watcher; let WatchmanWatcher;
var FileWatcher; let NodeWatcher;
var config; let FileWatcher;
let config;
beforeEach(() => {
WatchmanWatcher = sane.WatchmanWatcher;
WatchmanWatcher.prototype.once.mockImplementation(
(type, callback) => callback()
);
NodeWatcher = sane.NodeWatcher;
NodeWatcher.prototype.once.mockImplementation(
(type, callback) => callback()
);
beforeEach(function() {
Watcher = sane.WatchmanWatcher;
Watcher.prototype.once.mockImplementation(function(type, callback) {
callback();
});
FileWatcher = require('../'); FileWatcher = require('../');
config = [{ config = [{
@ -41,38 +45,45 @@ describe('FileWatcher', function() {
}]; }];
}); });
pit('it should get the watcher instance when ready', function() { pit('gets the watcher instance when ready', () => {
var fileWatcher = new FileWatcher(config); const fileWatcher = new FileWatcher(config, {useWatchman: true});
return fileWatcher.getWatchers().then(function(watchers) { return fileWatcher.getWatchers().then(watchers => {
watchers.forEach(function(watcher) { watchers.forEach(watcher => {
expect(watcher instanceof Watcher).toBe(true); expect(watcher instanceof WatchmanWatcher).toBe(true);
}); });
}); });
}); });
pit('should emit events', function() { pit('gets the node watcher if watchman is disabled', () => {
var cb; const fileWatcher = new FileWatcher(config, {useWatchman: false});
Watcher.prototype.on.mockImplementation(function(type, callback) { return fileWatcher.getWatchers().then(watchers => {
watchers.forEach(watcher => {
expect(watcher instanceof NodeWatcher).toBe(true);
});
});
});
pit('emits events', () => {
let cb;
WatchmanWatcher.prototype.on.mockImplementation((type, callback) => {
cb = callback; cb = callback;
}); });
var fileWatcher = new FileWatcher(config); const fileWatcher = new FileWatcher(config, {useWatchman: true});
var handler = jest.genMockFn(); const handler = jest.genMockFn();
fileWatcher.on('all', handler); fileWatcher.on('all', handler);
return fileWatcher.getWatchers().then(function() { return fileWatcher.getWatchers().then(watchers => {
cb(1, 2, 3, 4); cb(1, 2, 3, 4);
jest.runAllTimers(); jest.runAllTimers();
expect(handler.mock.calls[0]).toEqual([1, 2, 3, 4]); expect(handler.mock.calls[0]).toEqual([1, 2, 3, 4]);
}); });
}); });
pit('it should end the watcher', function() { pit('ends the watcher', () => {
var fileWatcher = new FileWatcher(config); const fileWatcher = new FileWatcher(config, {useWatchman: true});
Watcher.prototype.close.mockImplementation(function(callback) { WatchmanWatcher.prototype.close.mockImplementation(callback => callback());
callback();
});
return fileWatcher.end().then(function() { return fileWatcher.end().then(() => {
expect(Watcher.prototype.close).toBeCalled(); expect(WatchmanWatcher.prototype.close).toBeCalled();
}); });
}); });
}); });

Просмотреть файл

@ -30,17 +30,18 @@ let inited = false;
class FileWatcher extends EventEmitter { class FileWatcher extends EventEmitter {
constructor(rootConfigs) { constructor(rootConfigs, options) {
if (inited) { if (inited) {
throw new Error('FileWatcher can only be instantiated once'); throw new Error('FileWatcher can only be instantiated once');
} }
inited = true; inited = true;
super(); super();
this._useWatchman = options.useWatchman;
this._watcherByRoot = Object.create(null); this._watcherByRoot = Object.create(null);
this._loading = Promise.all( this._loading = Promise.all(
rootConfigs.map(createWatcher) rootConfigs.map(rootConfig => this._createWatcher(rootConfig))
).then(watchers => { ).then(watchers => {
watchers.forEach((watcher, i) => { watchers.forEach((watcher, i) => {
this._watcherByRoot[rootConfigs[i].dir] = watcher; this._watcherByRoot[rootConfigs[i].dir] = watcher;
@ -65,9 +66,9 @@ class FileWatcher extends EventEmitter {
} }
isWatchman() { isWatchman() {
return detectingWatcherClass.then( return this._useWatchman ? detectingWatcherClass.then(
Watcher => Watcher === sane.WatchmanWatcher Watcher => Watcher === sane.WatchmanWatcher
); ) : Promise.resolve(false);
} }
end() { end() {
@ -79,6 +80,30 @@ class FileWatcher extends EventEmitter {
); );
} }
_createWatcher(rootConfig) {
return detectingWatcherClass.then(Watcher => {
if (!this._useWatchman) {
Watcher = sane.NodeWatcher;
}
const watcher = new Watcher(rootConfig.dir, {
glob: rootConfig.globs,
dot: false,
});
return new Promise((resolve, reject) => {
const rejectTimeout = setTimeout(
() => reject(new Error(timeoutMessage(Watcher))),
MAX_WAIT_TIME
);
watcher.once('ready', () => {
clearTimeout(rejectTimeout);
resolve(watcher);
});
});
});
}
static createDummyWatcher() { static createDummyWatcher() {
return Object.assign(new EventEmitter(), { return Object.assign(new EventEmitter(), {
isWatchman: () => Promise.resolve(false), isWatchman: () => Promise.resolve(false),
@ -87,26 +112,6 @@ class FileWatcher extends EventEmitter {
} }
} }
function createWatcher(rootConfig) {
return detectingWatcherClass.then(function(Watcher) {
const watcher = new Watcher(rootConfig.dir, {
glob: rootConfig.globs,
dot: false,
});
return new Promise(function(resolve, reject) {
const rejectTimeout = setTimeout(function() {
reject(new Error(timeoutMessage(Watcher)));
}, MAX_WAIT_TIME);
watcher.once('ready', function() {
clearTimeout(rejectTimeout);
resolve(watcher);
});
});
});
}
function timeoutMessage(Watcher) { function timeoutMessage(Watcher) {
const lines = [ const lines = [
'Watcher took too long to load (' + Watcher.name + ')', 'Watcher took too long to load (' + Watcher.name + ')',

Просмотреть файл

@ -12,7 +12,7 @@ const crypto = require('crypto');
const docblock = require('./DependencyGraph/docblock'); const docblock = require('./DependencyGraph/docblock');
const isAbsolutePath = require('absolute-path'); const isAbsolutePath = require('absolute-path');
const jsonStableStringify = require('json-stable-stringify'); const jsonStableStringify = require('json-stable-stringify');
const path = require('path'); const path = require('fast-path');
const extractRequires = require('./lib/extractRequires'); const extractRequires = require('./lib/extractRequires');
class Module { class Module {
@ -30,7 +30,7 @@ class Module {
throw new Error('Expected file to be absolute path but got ' + file); throw new Error('Expected file to be absolute path but got ' + file);
} }
this.path = path.resolve(file); this.path = file;
this.type = 'Module'; this.type = 'Module';
this._fastfs = fastfs; this._fastfs = fastfs;
@ -132,7 +132,7 @@ class Module {
const fileContentPromise = this._fastfs.readFile(this.path); const fileContentPromise = this._fastfs.readFile(this.path);
return Promise.all([ return Promise.all([
fileContentPromise, fileContentPromise,
this._readDocBlock(fileContentPromise) this._readDocBlock(fileContentPromise),
]).then(([code, {id, moduleDocBlock}]) => { ]).then(([code, {id, moduleDocBlock}]) => {
// Ignore requires in JSON files or generated code. An example of this // Ignore requires in JSON files or generated code. An example of this
// is prebuilt files like the SourceMap library. // is prebuilt files like the SourceMap library.
@ -151,7 +151,7 @@ class Module {
return {id, code, dependencies, map}; return {id, code, dependencies, map};
}); });
} }
}) });
} }
); );
} }

Просмотреть файл

@ -3,7 +3,7 @@
const AssetModule = require('./AssetModule'); const AssetModule = require('./AssetModule');
const Package = require('./Package'); const Package = require('./Package');
const Module = require('./Module'); const Module = require('./Module');
const path = require('path'); const path = require('fast-path');
class ModuleCache { class ModuleCache {
@ -26,7 +26,6 @@ class ModuleCache {
} }
getModule(filePath) { getModule(filePath) {
filePath = path.resolve(filePath);
if (!this._moduleCache[filePath]) { if (!this._moduleCache[filePath]) {
this._moduleCache[filePath] = new Module({ this._moduleCache[filePath] = new Module({
file: filePath, file: filePath,
@ -46,7 +45,6 @@ class ModuleCache {
} }
getAssetModule(filePath) { getAssetModule(filePath) {
filePath = path.resolve(filePath);
if (!this._moduleCache[filePath]) { if (!this._moduleCache[filePath]) {
this._moduleCache[filePath] = new AssetModule({ this._moduleCache[filePath] = new AssetModule({
file: filePath, file: filePath,
@ -59,7 +57,6 @@ class ModuleCache {
} }
getPackage(filePath) { getPackage(filePath) {
filePath = path.resolve(filePath);
if (!this._packageCache[filePath]) { if (!this._packageCache[filePath]) {
this._packageCache[filePath] = new Package({ this._packageCache[filePath] = new Package({
file: filePath, file: filePath,

Просмотреть файл

@ -1,12 +1,12 @@
'use strict'; 'use strict';
const isAbsolutePath = require('absolute-path'); const isAbsolutePath = require('absolute-path');
const path = require('path'); const path = require('fast-path');
class Package { class Package {
constructor({ file, fastfs, cache }) { constructor({ file, fastfs, cache }) {
this.path = path.resolve(file); this.path = file;
this.root = path.dirname(this.path); this.root = path.dirname(this.path);
this._fastfs = fastfs; this._fastfs = fastfs;
this.type = 'Package'; this.type = 'Package';

Просмотреть файл

@ -202,9 +202,9 @@ describe('Module', () => {
let transformCode; let transformCode;
const fileContents = 'arbitrary(code);'; const fileContents = 'arbitrary(code);';
const exampleCode = ` const exampleCode = `
require('a'); ${'require'}('a');
arbitrary.code('b'); ${'System.import'}('b');
require('c');`; ${'require'}('c');`;
beforeEach(function() { beforeEach(function() {
transformCode = jest.genMockFn(); transformCode = jest.genMockFn();
@ -281,7 +281,7 @@ describe('Module', () => {
const callsEqual = ([path1, key1], [path2, key2]) => { const callsEqual = ([path1, key1], [path2, key2]) => {
expect(path1).toEqual(path2); expect(path1).toEqual(path2);
expect(key1).toEqual(key2); expect(key1).toEqual(key2);
} };
it('gets dependencies from the cache with the same cache key for the same transform options', () => { it('gets dependencies from the cache with the same cache key for the same transform options', () => {
const options = {some: 'options'}; const options = {some: 'options'};
@ -293,7 +293,6 @@ describe('Module', () => {
}); });
it('gets dependencies from the cache with the same cache key for the equivalent transform options', () => { it('gets dependencies from the cache with the same cache key for the equivalent transform options', () => {
const options = {some: 'options'};
module.getDependencies({a: 'b', c: 'd'}); // first call module.getDependencies({a: 'b', c: 'd'}); // first call
module.getDependencies({c: 'd', a: 'b'}); // second call module.getDependencies({c: 'd', a: 'b'}); // second call
@ -318,7 +317,6 @@ describe('Module', () => {
}); });
it('gets code from the cache with the same cache key for the equivalent transform options', () => { it('gets code from the cache with the same cache key for the equivalent transform options', () => {
const options = {some: 'options'};
module.getCode({a: 'b', c: 'd'}); // first call module.getCode({a: 'b', c: 'd'}); // first call
module.getCode({c: 'd', a: 'b'}); // second call module.getCode({c: 'd', a: 'b'}); // second call

Просмотреть файл

@ -3,7 +3,7 @@
const Promise = require('promise'); const Promise = require('promise');
const debug = require('debug')('ReactNativePackager:DependencyGraph'); const debug = require('debug')('ReactNativePackager:DependencyGraph');
const fs = require('graceful-fs'); const fs = require('graceful-fs');
const path = require('path'); const path = require('fast-path');
const readDir = Promise.denodeify(fs.readdir); const readDir = Promise.denodeify(fs.readdir);
const stat = Promise.denodeify(fs.stat); const stat = Promise.denodeify(fs.stat);

Просмотреть файл

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const Promise = require('promise'); const Promise = require('promise');
const path = require('path'); const path = require('fast-path');
function watchmanRecReadDir(roots, {ignore, fileWatcher, exts}) { function watchmanRecReadDir(roots, {ignore, fileWatcher, exts}) {
const files = []; const files = [];
@ -38,20 +38,16 @@ function watchmanRecReadDir(roots, {ignore, fileWatcher, exts}) {
const cmd = Promise.denodeify(watcher.client.command.bind(watcher.client)); const cmd = Promise.denodeify(watcher.client.command.bind(watcher.client));
return cmd(['query', watchedRoot, { return cmd(['query', watchedRoot, {
'suffix': exts, suffix: exts,
'expression': ['allof', ['type', 'f'], 'exists', dirExpr], expression: ['allof', ['type', 'f'], 'exists', dirExpr],
'fields': ['name'], fields: ['name'],
}]).then(resp => { }]).then(resp => {
if ('warning' in resp) { if ('warning' in resp) {
console.warn('watchman warning: ', resp.warning); console.warn('watchman warning: ', resp.warning);
} }
resp.files.forEach(filePath => { resp.files.forEach(filePath => {
filePath = path.join( filePath = watchedRoot + path.sep + filePath;
watchedRoot,
filePath
);
if (!ignore(filePath)) { if (!ignore(filePath)) {
files.push(filePath); files.push(filePath);
} }
@ -64,7 +60,7 @@ function watchmanRecReadDir(roots, {ignore, fileWatcher, exts}) {
} }
function isDescendant(root, child) { function isDescendant(root, child) {
return path.relative(root, child).indexOf('..') !== 0; return child.startsWith(root);
} }
module.exports = watchmanRecReadDir; module.exports = watchmanRecReadDir;

Просмотреть файл

@ -12,7 +12,7 @@ const Promise = require('promise');
const {EventEmitter} = require('events'); const {EventEmitter} = require('events');
const fs = require('graceful-fs'); const fs = require('graceful-fs');
const path = require('path'); const path = require('fast-path');
// workaround for https://github.com/isaacs/node-graceful-fs/issues/56 // workaround for https://github.com/isaacs/node-graceful-fs/issues/56
// fs.close is patched, whereas graceful-fs.close is not. // fs.close is patched, whereas graceful-fs.close is not.
@ -21,8 +21,6 @@ const fsClose = require('fs').close;
const readFile = Promise.denodeify(fs.readFile); const readFile = Promise.denodeify(fs.readFile);
const stat = Promise.denodeify(fs.stat); const stat = Promise.denodeify(fs.stat);
const hasOwn = Object.prototype.hasOwnProperty;
const NOT_FOUND_IN_ROOTS = 'NotFoundInRootsError'; const NOT_FOUND_IN_ROOTS = 'NotFoundInRootsError';
class Fastfs extends EventEmitter { class Fastfs extends EventEmitter {
@ -31,17 +29,20 @@ class Fastfs extends EventEmitter {
this._name = name; this._name = name;
this._fileWatcher = fileWatcher; this._fileWatcher = fileWatcher;
this._ignore = ignore; this._ignore = ignore;
this._roots = roots.map(root => new File(root, { isDir: true })); this._roots = roots.map(root => {
// If the path ends in a separator ("/"), remove it to make string
// operations on paths safer.
if (root.endsWith(path.sep)) {
root = root.substr(0, root.length - 1);
}
return new File(root, true);
});
this._fastPaths = Object.create(null); this._fastPaths = Object.create(null);
this._crawling = crawling; this._crawling = crawling;
this._activity = activity; this._activity = activity;
} }
build() { build() {
const rootsPattern = new RegExp(
'^(' + this._roots.map(root => escapeRegExp(root.path)).join('|') + ')'
);
return this._crawling.then(files => { return this._crawling.then(files => {
let fastfsActivity; let fastfsActivity;
const activity = this._activity; const activity = this._activity;
@ -49,18 +50,16 @@ class Fastfs extends EventEmitter {
fastfsActivity = activity.startEvent('Building in-memory fs for ' + this._name); fastfsActivity = activity.startEvent('Building in-memory fs for ' + this._name);
} }
files.forEach(filePath => { files.forEach(filePath => {
if (filePath.match(rootsPattern)) { const root = this._getRoot(filePath);
const newFile = new File(filePath, { isDir: false }); if (root) {
const parent = this._fastPaths[path.dirname(filePath)]; const newFile = new File(filePath, false);
const dirname = filePath.substr(0, filePath.lastIndexOf(path.sep));
const parent = this._fastPaths[dirname];
this._fastPaths[filePath] = newFile;
if (parent) { if (parent) {
parent.addChild(newFile); parent.addChild(newFile, this._fastPaths);
} else { } else {
this._add(newFile); root.addChild(newFile, this._fastPaths);
for (let file = newFile; file; file = file.parent) {
if (!this._fastPaths[file.path]) {
this._fastPaths[file.path] = file;
}
}
} }
} }
}); });
@ -72,42 +71,24 @@ class Fastfs extends EventEmitter {
} }
stat(filePath) { stat(filePath) {
return Promise.resolve().then(() => { return Promise.resolve().then(() => this._getFile(filePath).stat());
const file = this._getFile(filePath);
return file.stat();
});
} }
getAllFiles() { getAllFiles() {
// one-level-deep flatten of files return Object.keys(this._fastPaths)
return [].concat(...this._roots.map(root => root.getFiles())); .filter(filePath => !this._fastPaths[filePath].isDir);
}
findFilesByExt(ext, { ignore } = {}) {
return this.findFilesByExts([ext], {ignore});
} }
findFilesByExts(exts, { ignore } = {}) { findFilesByExts(exts, { ignore } = {}) {
return this.getAllFiles() return this.getAllFiles()
.filter(file => ( .filter(filePath => (
exts.indexOf(file.ext()) !== -1 && (!ignore || !ignore(file.path)) exts.indexOf(path.extname(filePath).substr(1)) !== -1 &&
)) (!ignore || !ignore(filePath))
.map(file => file.path); ));
}
findFilesByName(name, { ignore } = {}) {
return this.getAllFiles()
.filter(
file => path.basename(file.path) === name &&
(!ignore || !ignore(file.path))
)
.map(file => file.path);
} }
matchFilesByPattern(pattern) { matchFilesByPattern(pattern) {
return this.getAllFiles() return this.getAllFiles().filter(file => file.match(pattern));
.filter(file => file.path.match(pattern))
.map(file => file.path);
} }
readFile(filePath) { readFile(filePath) {
@ -198,25 +179,25 @@ class Fastfs extends EventEmitter {
_getFile(filePath) { _getFile(filePath) {
filePath = path.normalize(filePath); filePath = path.normalize(filePath);
if (!hasOwn.call(this._fastPaths, filePath)) { if (!this._fastPaths[filePath]) {
this._fastPaths[filePath] = this._getAndAssertRoot(filePath).getFileFromPath(filePath); const file = this._getAndAssertRoot(filePath).getFileFromPath(filePath);
if (file) {
this._fastPaths[filePath] = file;
}
} }
return this._fastPaths[filePath]; return this._fastPaths[filePath];
} }
_add(file) { _processFileChange(type, filePath, rootPath, fstat) {
this._getAndAssertRoot(file.path).addChild(file); const absPath = path.join(rootPath, filePath);
}
_processFileChange(type, filePath, root, fstat) {
const absPath = path.join(root, filePath);
if (this._ignore(absPath) || (fstat && fstat.isDirectory())) { if (this._ignore(absPath) || (fstat && fstat.isDirectory())) {
return; return;
} }
// Make sure this event belongs to one of our roots. // Make sure this event belongs to one of our roots.
if (!this._getRoot(absPath)) { const root = this._getRoot(absPath);
if (!root) {
return; return;
} }
@ -230,20 +211,19 @@ class Fastfs extends EventEmitter {
delete this._fastPaths[path.normalize(absPath)]; delete this._fastPaths[path.normalize(absPath)];
if (type !== 'delete') { if (type !== 'delete') {
this._add(new File(absPath, { isDir: false })); const file = new File(absPath, false);
root.addChild(file, this._fastPaths);
} }
this.emit('change', type, filePath, root, fstat); this.emit('change', type, filePath, rootPath, fstat);
} }
} }
class File { class File {
constructor(filePath, { isDir }) { constructor(filePath, isDir) {
this.path = filePath; this.path = filePath;
this.isDir = Boolean(isDir); this.isDir = isDir;
if (this.isDir) { this.children = this.isDir ? Object.create(null) : null;
this.children = Object.create(null);
}
} }
read() { read() {
@ -270,29 +250,24 @@ class File {
return this._stat; return this._stat;
} }
addChild(file) { addChild(file, fileMap) {
const parts = path.relative(this.path, file.path).split(path.sep); const parts = file.path.substr(this.path.length + 1).split(path.sep);
if (parts.length === 0) {
return;
}
if (parts.length === 1) { if (parts.length === 1) {
this.children[parts[0]] = file; this.children[parts[0]] = file;
file.parent = this; file.parent = this;
} else if (this.children[parts[0]]) { } else if (this.children[parts[0]]) {
this.children[parts[0]].addChild(file); this.children[parts[0]].addChild(file, fileMap);
} else { } else {
const dir = new File(path.join(this.path, parts[0]), { isDir: true }); const dir = new File(this.path + path.sep + parts[0], true);
dir.parent = this; dir.parent = this;
this.children[parts[0]] = dir; this.children[parts[0]] = dir;
dir.addChild(file); fileMap[dir.path] = dir;
dir.addChild(file, fileMap);
} }
} }
getFileFromPath(filePath) { getFileFromPath(filePath) {
const parts = path.relative(this.path, filePath) const parts = path.relative(this.path, filePath).split(path.sep);
.split(path.sep);
/*eslint consistent-this:0*/ /*eslint consistent-this:0*/
let file = this; let file = this;
@ -313,21 +288,8 @@ class File {
return file; return file;
} }
getFiles() {
let files = [];
Object.keys(this.children).forEach(key => {
const file = this.children[key];
if (file.isDir) {
files = files.concat(file.getFiles());
} else {
files.push(file);
}
});
return files;
}
ext() { ext() {
return path.extname(this.path).replace(/^\./, ''); return path.extname(this.path).substr(1);
} }
remove() { remove() {
@ -392,11 +354,7 @@ function makeReadCallback(fd, predicate, callback) {
} }
function isDescendant(root, child) { function isDescendant(root, child) {
return path.relative(root, child).indexOf('..') !== 0; return child.startsWith(root);
}
function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
} }
module.exports = Fastfs; module.exports = Fastfs;

Просмотреть файл

@ -39,7 +39,7 @@ function extractRequires(code) {
.replace(replacePatterns.REQUIRE_RE, (match, pre, quot, dep, post) => { .replace(replacePatterns.REQUIRE_RE, (match, pre, quot, dep, post) => {
deps.sync.push(dep); deps.sync.push(dep);
return match; return match;
}) });
return {code, deps}; return {code, deps};
} }

Просмотреть файл

@ -8,7 +8,7 @@
*/ */
'use strict'; 'use strict';
const path = require('path'); const path = require('fast-path');
const getPlatformExtension = require('./getPlatformExtension'); const getPlatformExtension = require('./getPlatformExtension');
function getAssetDataFromName(filename) { function getAssetDataFromName(filename) {

Просмотреть файл

@ -8,19 +8,21 @@
*/ */
'use strict'; 'use strict';
const SUPPORTED_PLATFORM_EXTS = ['android', 'ios', 'web']; const SUPPORTED_PLATFORM_EXTS = {
android: true,
const re = new RegExp( ios: true,
'[^\\.]+\\.(' + SUPPORTED_PLATFORM_EXTS.join('|') + ')\\.\\w+$' web: true,
); };
// Extract platform extension: index.ios.js -> ios // Extract platform extension: index.ios.js -> ios
function getPlatformExtension(file) { function getPlatformExtension(file) {
const match = file.match(re); const last = file.lastIndexOf('.');
if (match && match[1]) { const secondToLast = file.lastIndexOf('.', last - 1);
return match[1]; if (secondToLast === -1) {
}
return null; return null;
}
const platform = file.substring(secondToLast + 1, last);
return SUPPORTED_PLATFORM_EXTS[platform] ? platform : null;
} }
module.exports = getPlatformExtension; module.exports = getPlatformExtension;

2
packager/react-packager/src/Server/index.js поставляемый
Просмотреть файл

@ -182,7 +182,7 @@ class Server {
this._fileWatcher = options.nonPersistent this._fileWatcher = options.nonPersistent
? FileWatcher.createDummyWatcher() ? FileWatcher.createDummyWatcher()
: new FileWatcher(watchRootConfigs); : new FileWatcher(watchRootConfigs, {useWatchman: true});
this._assetServer = new AssetServer({ this._assetServer = new AssetServer({
projectRoots: opts.projectRoots, projectRoots: opts.projectRoots,