diff --git a/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js b/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js index a2d68e43..514a093e 100644 --- a/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js +++ b/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js @@ -789,7 +789,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['aPackage'], isAsset: false, @@ -832,7 +832,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['aPackage'], isAsset: false, @@ -876,7 +876,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['aPackage'], isAsset: false, @@ -1910,7 +1910,7 @@ describe('traverseDependencies', function() { }, { dependencies: [], - id: '/root/emptyModule.js', + id: 'emptyModule.js', isAsset: false, isPolyfill: false, path: '/root/emptyModule.js', @@ -1980,7 +1980,7 @@ describe('traverseDependencies', function() { }, { dependencies: [], - id: '/root/emptyModule.js', + id: 'emptyModule.js', isAsset: false, isPolyfill: false, path: '/root/emptyModule.js', @@ -2097,7 +2097,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['/root/apple.js'], isAsset: false, @@ -2105,7 +2105,7 @@ describe('traverseDependencies', function() { resolution: undefined, }, { - id: '/root/apple.js', + id: 'apple.js', path: '/root/apple.js', dependencies: [], isAsset: false, @@ -2284,7 +2284,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['./foo'], isAsset: false, @@ -2292,7 +2292,7 @@ describe('traverseDependencies', function() { resolution: undefined, }, { - id: '/root/foo/index.js', + id: 'foo/index.js', path: '/root/foo/index.js', dependencies: ['bar'], isAsset: false, @@ -2335,7 +2335,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['bar'], isAsset: false, @@ -2343,7 +2343,7 @@ describe('traverseDependencies', function() { resolution: undefined, }, { - id: '/root/node_modules/bar.js', + id: 'node_modules/bar.js', path: '/root/node_modules/bar.js', dependencies: [], isAsset: false, @@ -2380,7 +2380,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['bar/lib/foo'], isAsset: false, @@ -2489,7 +2489,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: 'C:\\root\\index.js', + id: 'index.js', path: 'C:\\root\\index.js', dependencies: ['C:/root/apple.js'], isAsset: false, @@ -2497,7 +2497,7 @@ describe('traverseDependencies', function() { resolution: undefined, }, { - id: 'C:\\root\\apple.js', + id: 'apple.js', path: 'C:\\root\\apple.js', dependencies: [], isAsset: false, @@ -3395,7 +3395,7 @@ describe('traverseDependencies', function() { resolution: undefined, }, { - id: '/root/a.ios.js', + id: 'a.ios.js', path: '/root/a.ios.js', dependencies: [], isAsset: false, @@ -3500,7 +3500,7 @@ describe('traverseDependencies', function() { ); expect(deps).toEqual([ { - id: '/root/index.js', + id: 'index.js', path: '/root/index.js', dependencies: ['a/index.js'], isAsset: false, @@ -4336,7 +4336,7 @@ describe('traverseDependencies', function() { resolution: undefined, }, { - id: 'C:\\root\\a.ios.js', + id: 'a.ios.js', path: 'C:\\root\\a.ios.js', dependencies: [], isAsset: false, @@ -5162,7 +5162,7 @@ describe('traverseDependencies', function() { expect(deps).toEqual([ { dependencies: ['./a'], - id: '/root/index.jsx', + id: 'index.jsx', isAsset: false, isPolyfill: false, path: '/root/index.jsx', @@ -5170,7 +5170,7 @@ describe('traverseDependencies', function() { }, { dependencies: [], - id: '/root/a.coffee', + id: 'a.coffee', isAsset: false, isPolyfill: false, path: '/root/a.coffee', @@ -5449,13 +5449,13 @@ describe('traverseDependencies', function() { it('returns correctly a JS module', async () => { const module = dependencyGraph.getModuleForPath('/root/index.js'); - expect(module.getName()).toBe('/root/index.js'); + expect(module.getName()).toBe('index.js'); expect(module.isAsset()).toBe(false); }); it('returns correctly an asset module', async () => { const module = dependencyGraph.getModuleForPath('/root/imgs/a.png'); - expect(module.getName()).toBe('/root/imgs/a.png'); + expect(module.getName()).toBe('imgs/a.png'); expect(module.isAsset()).toBe(true); }); }); diff --git a/packages/metro/src/integration_tests/__tests__/__snapshots__/basic_bundle-test.js.snap b/packages/metro/src/integration_tests/__tests__/__snapshots__/basic_bundle-test.js.snap index 22a156b7..16c3b1f0 100644 --- a/packages/metro/src/integration_tests/__tests__/__snapshots__/basic_bundle-test.js.snap +++ b/packages/metro/src/integration_tests/__tests__/__snapshots__/basic_bundle-test.js.snap @@ -167,7 +167,7 @@ __d(function (global, require, module, exports, _dependencyMap) { asset: asset }; },6,[7]); -__d(/* /test.png */function(global, require, module, exports) {module.exports=require(8).registerAsset({\\"__packager_asset\\":true,\\"httpServerLocation\\":\\"/assets\\",\\"width\\":8,\\"height\\":8,\\"scales\\":[1],\\"hash\\":\\"77d45c1f7fa73c0f6c444a830dc42f67\\",\\"name\\":\\"test\\",\\"type\\":\\"png\\"}); // 8 = /AssetRegistry +__d(/* test.png */function(global, require, module, exports) {module.exports=require(8).registerAsset({\\"__packager_asset\\":true,\\"httpServerLocation\\":\\"/assets\\",\\"width\\":8,\\"height\\":8,\\"scales\\":[1],\\"hash\\":\\"77d45c1f7fa73c0f6c444a830dc42f67\\",\\"name\\":\\"test\\",\\"type\\":\\"png\\"}); // 8 = /AssetRegistry }, 7); __d(function (global, require, module, exports, _dependencyMap) { 'use strict'; @@ -328,7 +328,7 @@ __d(function (global, require, module, exports, _dependencyMap) { asset: asset }; },4,[5]); -__d(/* /test.png */function(global, require, module, exports) {module.exports=require(6).registerAsset({\\"__packager_asset\\":true,\\"httpServerLocation\\":\\"/assets\\",\\"width\\":8,\\"height\\":8,\\"scales\\":[1],\\"hash\\":\\"77d45c1f7fa73c0f6c444a830dc42f67\\",\\"name\\":\\"test\\",\\"type\\":\\"png\\"}); // 6 = /AssetRegistry +__d(/* test.png */function(global, require, module, exports) {module.exports=require(6).registerAsset({\\"__packager_asset\\":true,\\"httpServerLocation\\":\\"/assets\\",\\"width\\":8,\\"height\\":8,\\"scales\\":[1],\\"hash\\":\\"77d45c1f7fa73c0f6c444a830dc42f67\\",\\"name\\":\\"test\\",\\"type\\":\\"png\\"}); // 6 = /AssetRegistry }, 5); __d(function (global, require, module, exports, _dependencyMap) { 'use strict'; diff --git a/packages/metro/src/node-haste/Module.js b/packages/metro/src/node-haste/Module.js index 7fd587de..5a3df290 100644 --- a/packages/metro/src/node-haste/Module.js +++ b/packages/metro/src/node-haste/Module.js @@ -151,8 +151,8 @@ class Module { const p = this.getPackage(); if (!p) { - // Name is full path - return this.path; + // Name is local path + return this.localPath; } const packageName = p.getName(); diff --git a/packages/metro/src/node-haste/__tests__/Module-test.js b/packages/metro/src/node-haste/__tests__/Module-test.js index 38545b2b..ae205083 100644 --- a/packages/metro/src/node-haste/__tests__/Module-test.js +++ b/packages/metro/src/node-haste/__tests__/Module-test.js @@ -68,6 +68,7 @@ describe('Module', () => { cache, file: (options && options.file) || fileName, depGraphHelpers: new DependencyGraphHelpers(), + localPath: (options && options.localPath) || fileName, moduleCache: new ModuleCache({cache}), getTransformCacheKey: () => transformCacheKey, });