packager: DependencyGraph: remove re-exported functions

Reviewed By: davidaurelio, cpojer

Differential Revision: D5052149

fbshipit-source-id: 43f3877ceea038762ded6c42ab0481d215db2118
This commit is contained in:
Jean Lauliac 2017-05-12 10:26:46 -07:00 committed by Facebook Github Bot
parent f7bf4b841b
commit 02d57294fe
2 changed files with 13 additions and 22 deletions

View File

@ -14,7 +14,7 @@
const crypto = require('crypto'); const crypto = require('crypto');
const denodeify = require('denodeify'); const denodeify = require('denodeify');
const fs = require('fs'); const fs = require('fs');
const getAssetDataFromName = require('../node-haste/DependencyGraph').getAssetDataFromName; const getAssetDataFromName = require('../node-haste/lib/getAssetDataFromName');
const path = require('path'); const path = require('path');
import type {AssetData} from '../node-haste/lib/getAssetDataFromName'; import type {AssetData} from '../node-haste/lib/getAssetDataFromName';
@ -55,7 +55,10 @@ class AssetServer {
} }
get(assetPath: string, platform: ?string = null): Promise<Buffer> { get(assetPath: string, platform: ?string = null): Promise<Buffer> {
const assetData = getAssetDataFromName(assetPath, new Set([platform])); const assetData = getAssetDataFromName(
assetPath,
new Set(platform != null ? [platform] : []),
);
return this._getAssetRecord(assetPath, platform).then(record => { return this._getAssetRecord(assetPath, platform).then(record => {
for (let i = 0; i < record.scales.length; i++) { for (let i = 0; i < record.scales.length; i++) {
if (record.scales[i] >= assetData.resolution) { if (record.scales[i] >= assetData.resolution) {
@ -74,7 +77,10 @@ class AssetServer {
scales: Array<number>, scales: Array<number>,
type: string, type: string,
|}> { |}> {
const nameData = getAssetDataFromName(assetPath, new Set([platform])); const nameData = getAssetDataFromName(
assetPath,
new Set(platform != null ? [platform] : []),
);
const {name, type} = nameData; const {name, type} = nameData;
return this._getAssetRecord(assetPath, platform).then(record => { return this._getAssetRecord(assetPath, platform).then(record => {
@ -135,7 +141,10 @@ class AssetServer {
.then(res => { .then(res => {
const dir = res[0]; const dir = res[0];
const files = res[1]; const files = res[1];
const assetData = getAssetDataFromName(filename, new Set([platform])); const assetData = getAssetDataFromName(
filename,
new Set(platform != null ? [platform] : []),
);
const map = this._buildAssetMap(dir, files, platform); const map = this._buildAssetMap(dir, files, platform);

View File

@ -16,18 +16,14 @@ const FilesByDirNameIndex = require('./FilesByDirNameIndex');
const JestHasteMap = require('jest-haste-map'); const JestHasteMap = require('jest-haste-map');
const Module = require('./Module'); const Module = require('./Module');
const ModuleCache = require('./ModuleCache'); const ModuleCache = require('./ModuleCache');
const Polyfill = require('./Polyfill');
const ResolutionRequest = require('./DependencyGraph/ResolutionRequest'); const ResolutionRequest = require('./DependencyGraph/ResolutionRequest');
const ResolutionResponse = require('./DependencyGraph/ResolutionResponse'); const ResolutionResponse = require('./DependencyGraph/ResolutionResponse');
const fs = require('fs'); const fs = require('fs');
const getAssetDataFromName = require('./lib/getAssetDataFromName');
const getInverseDependencies = require('./lib/getInverseDependencies');
const getPlatformExtension = require('./lib/getPlatformExtension'); const getPlatformExtension = require('./lib/getPlatformExtension');
const invariant = require('fbjs/lib/invariant'); const invariant = require('fbjs/lib/invariant');
const isAbsolutePath = require('absolute-path'); const isAbsolutePath = require('absolute-path');
const path = require('path'); const path = require('path');
const replacePatterns = require('./lib/replacePatterns');
const util = require('util'); const util = require('util');
const { const {
@ -288,22 +284,8 @@ class DependencyGraph extends EventEmitter {
return this._moduleCache.createPolyfill(options); return this._moduleCache.createPolyfill(options);
} }
static Module;
static Polyfill;
static getAssetDataFromName;
static replacePatterns;
static getInverseDependencies;
} }
Object.assign(DependencyGraph, {
Module,
Polyfill,
getAssetDataFromName,
replacePatterns,
getInverseDependencies,
});
function NotFoundError() { function NotFoundError() {
/* $FlowFixMe: monkey-patching */ /* $FlowFixMe: monkey-patching */
Error.call(this); Error.call(this);