mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-14 09:16:34 +08:00
Summary: @public Fixes [#393](https://github.com/facebook/react-native/issues/393). Currently the transformer assumes line-preserving compilers and defaults to a super-fast source map generation process. However, we need to support compilers that aren't preserving lines. I had feared this wuold slow down the server but I came about a little known peace of the spec that defines an "indexed source map" just for the purpose of concating files: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit Test Plan: 1. runJestTests.sh 2. run server and click around example apps 3. add a custom transporter like babel 4. add a custom file and a debugger statement 5. debug in chrome and make sure it works redbox still works
39 lines
909 B
JavaScript
39 lines
909 B
JavaScript
/**
|
|
* Copyright (c) 2015-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.
|
|
*/
|
|
'use strict';
|
|
|
|
function ModuleTransport(data) {
|
|
assertExists(data, 'code');
|
|
this.code = data.code;
|
|
|
|
assertExists(data, 'sourceCode');
|
|
this.sourceCode = data.sourceCode;
|
|
|
|
assertExists(data, 'sourcePath');
|
|
this.sourcePath = data.sourcePath;
|
|
|
|
this.virtual = data.virtual;
|
|
|
|
if (this.virtual && data.map) {
|
|
throw new Error('Virtual modules cannot have source maps');
|
|
}
|
|
|
|
this.map = data.map;
|
|
|
|
Object.freeze(this);
|
|
}
|
|
|
|
module.exports = ModuleTransport;
|
|
|
|
function assertExists(obj, field) {
|
|
if (obj[field] == null) {
|
|
throw new Error('Modules must have `' + field + '`');
|
|
}
|
|
}
|