Add --sourcemap-sources-root to RN packager

Reviewed By: davidaurelio

Differential Revision: D4357122

fbshipit-source-id: dc19474aa54ea4684a6b1c586a9d1e5da0980327
This commit is contained in:
Chris Hopman
2017-01-04 20:45:55 -08:00
committed by Facebook Github Bot
parent 482c73de86
commit da59258372
6 changed files with 70 additions and 14 deletions

View File

@@ -11,6 +11,7 @@
'use strict';
const meta = require('./meta');
const relativizeSourceMap = require('../../../packager/react-packager/src/lib/relativizeSourceMap');
const writeFile = require('./writeFile');
import type Bundle from '../../../packager/react-packager/src/Bundler/Bundle';
@@ -24,10 +25,11 @@ function buildBundle(packagerClient: Server, requestOptions: RequestOptions) {
});
}
function createCodeWithMap(bundle: Bundle, dev: boolean): * {
function createCodeWithMap(bundle: Bundle, dev: boolean, sourceMapSourcesRoot?: string): * {
const sourceMap = relativizeSourceMap(bundle.getSourceMap({dev}), sourceMapSourcesRoot);
return {
code: bundle.getSource({dev}),
map: JSON.stringify(bundle.getSourceMap({dev})),
map: JSON.stringify(sourceMap),
};
}
@@ -40,11 +42,12 @@ function saveBundleAndMap(
bundleOutput,
bundleEncoding: encoding,
dev,
sourcemapOutput
sourcemapOutput,
sourcemapSourcesRoot
} = options;
log('start');
const codeWithMap = createCodeWithMap(bundle, !!dev);
const codeWithMap = createCodeWithMap(bundle, !!dev, sourcemapSourcesRoot);
log('finish');
log('Writing bundle output to:', bundleOutput);