From 1152a69432070352c8adbd460c36ce1cbb5d5574 Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Fri, 12 Jan 2018 05:25:27 -0800 Subject: [PATCH] Fold modulegraphs sourcemap file into metro-source-map Reviewed By: rafeca Differential Revision: D6711210 fbshipit-source-id: 1d91df189607c032045f604df75b119a87794ca6 --- packages/metro-source-map/src/source-map.js | 12 ++++++++ .../src/ModuleGraph/output/plain-bundle.js | 4 +-- .../src/ModuleGraph/output/source-map.js | 28 ------------------- 3 files changed, 14 insertions(+), 30 deletions(-) delete mode 100644 packages/metro/src/ModuleGraph/output/source-map.js diff --git a/packages/metro-source-map/src/source-map.js b/packages/metro-source-map/src/source-map.js index 352b9078..42760b34 100644 --- a/packages/metro-source-map/src/source-map.js +++ b/packages/metro-source-map/src/source-map.js @@ -167,7 +167,19 @@ function countLines(string) { return string.split('\n').length; } +function createIndexMap( + file: string, + sections: Array, +): IndexMap { + return { + version: 3, + file, + sections, + }; +} + module.exports = { + createIndexMap, fromRawMappings, toBabelSegments, toSegmentTuple, diff --git a/packages/metro/src/ModuleGraph/output/plain-bundle.js b/packages/metro/src/ModuleGraph/output/plain-bundle.js index f6f53f2b..6e6b5cd7 100644 --- a/packages/metro/src/ModuleGraph/output/plain-bundle.js +++ b/packages/metro/src/ModuleGraph/output/plain-bundle.js @@ -14,8 +14,8 @@ const meta = require('../../shared/output/meta'); -const {createIndexMap} = require('./source-map'); const {getModuleCode, concat} = require('./util'); +const {createIndexMap} = require('metro-source-map'); import type {OutputFn} from '../types.flow'; @@ -52,7 +52,7 @@ function asPlainBundle({ return { code, extraFiles: [[`${filename}.meta`, meta(code)]], - map: createIndexMap({file: filename, sections}), + map: createIndexMap(filename, sections), }; } diff --git a/packages/metro/src/ModuleGraph/output/source-map.js b/packages/metro/src/ModuleGraph/output/source-map.js deleted file mode 100644 index 287065cf..00000000 --- a/packages/metro/src/ModuleGraph/output/source-map.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @flow - * @format - */ - -'use strict'; - -import type {FBSourceMap, IndexMap, IndexMapSection} from 'metro-source-map'; - -export type {FBSourceMap}; - -type CreateIndexMapOptions = {| - file?: string, - sections?: Array, -|}; - -exports.createIndexMap = (opts?: CreateIndexMapOptions): IndexMap => ({ - version: 3, - file: opts && opts.file, - sections: (opts && opts.sections) || [], -});