diff --git a/packages/metro-bundler/src/AssetServer/index.js b/packages/metro-bundler/src/AssetServer/index.js index e2ffd01c..79fe9ca8 100644 --- a/packages/metro-bundler/src/AssetServer/index.js +++ b/packages/metro-bundler/src/AssetServer/index.js @@ -14,7 +14,7 @@ const crypto = require('crypto'); const denodeify = require('denodeify'); const fs = require('fs'); -const getAssetDataFromName = require('../node-haste/DependencyGraph').getAssetDataFromName; +const getAssetDataFromName = require('../node-haste/lib/getAssetDataFromName'); const path = require('path'); import type {AssetData} from '../node-haste/lib/getAssetDataFromName'; @@ -55,7 +55,10 @@ class AssetServer { } get(assetPath: string, platform: ?string = null): Promise { - const assetData = getAssetDataFromName(assetPath, new Set([platform])); + const assetData = getAssetDataFromName( + assetPath, + new Set(platform != null ? [platform] : []), + ); return this._getAssetRecord(assetPath, platform).then(record => { for (let i = 0; i < record.scales.length; i++) { if (record.scales[i] >= assetData.resolution) { @@ -74,7 +77,10 @@ class AssetServer { scales: Array, type: string, |}> { - const nameData = getAssetDataFromName(assetPath, new Set([platform])); + const nameData = getAssetDataFromName( + assetPath, + new Set(platform != null ? [platform] : []), + ); const {name, type} = nameData; return this._getAssetRecord(assetPath, platform).then(record => { @@ -135,7 +141,10 @@ class AssetServer { .then(res => { const dir = res[0]; 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); diff --git a/packages/metro-bundler/src/node-haste/DependencyGraph.js b/packages/metro-bundler/src/node-haste/DependencyGraph.js index c0e547f1..369e81b2 100644 --- a/packages/metro-bundler/src/node-haste/DependencyGraph.js +++ b/packages/metro-bundler/src/node-haste/DependencyGraph.js @@ -16,18 +16,14 @@ const FilesByDirNameIndex = require('./FilesByDirNameIndex'); const JestHasteMap = require('jest-haste-map'); const Module = require('./Module'); const ModuleCache = require('./ModuleCache'); -const Polyfill = require('./Polyfill'); const ResolutionRequest = require('./DependencyGraph/ResolutionRequest'); const ResolutionResponse = require('./DependencyGraph/ResolutionResponse'); const fs = require('fs'); -const getAssetDataFromName = require('./lib/getAssetDataFromName'); -const getInverseDependencies = require('./lib/getInverseDependencies'); const getPlatformExtension = require('./lib/getPlatformExtension'); const invariant = require('fbjs/lib/invariant'); const isAbsolutePath = require('absolute-path'); const path = require('path'); -const replacePatterns = require('./lib/replacePatterns'); const util = require('util'); const { @@ -288,22 +284,8 @@ class DependencyGraph extends EventEmitter { 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() { /* $FlowFixMe: monkey-patching */ Error.call(this);