From 280ec6e1ebf5bd607fcb3786ae261e34dfe76adb Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 16 May 2017 05:09:59 -0700 Subject: [PATCH] Append `sourceMappingURL` in bundle building function Summary: We appended a `sourceMappingURL` in the same place where we write out the files. This will break output that is not a plain text file, like Random Access Bundles. This moves the corresponding logic into the function that builds the bundle. Reviewed By: cpojer Differential Revision: D5061039 fbshipit-source-id: 17fadb5a687c8d4b1f29439e8bf946bae58eb2d9 --- packager/src/ModuleGraph/output/as-plain-bundle.js | 6 +++++- packager/src/ModuleGraph/types.flow.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packager/src/ModuleGraph/output/as-plain-bundle.js b/packager/src/ModuleGraph/output/as-plain-bundle.js index c05d67d36..601cf5562 100644 --- a/packager/src/ModuleGraph/output/as-plain-bundle.js +++ b/packager/src/ModuleGraph/output/as-plain-bundle.js @@ -16,7 +16,7 @@ const {addModuleIdsToModuleWrapper} = require('./util'); import type {OutputFn} from '../types.flow'; module.exports = ( - (modules, filename, idForPath) => { + (modules, filename, idForPath, sourceMapPath) => { let code = ''; let line = 0; const sections = []; @@ -37,6 +37,10 @@ module.exports = ( line += countLines(moduleCode); } + if (sourceMapPath) { + code += `/*# sourceMappingURL=${sourceMapPath}*/`; + } + return {code, map: createIndexMap({file: filename, sections})}; }: OutputFn); diff --git a/packager/src/ModuleGraph/types.flow.js b/packager/src/ModuleGraph/types.flow.js index 8809cfbda..a7a3cb782 100644 --- a/packager/src/ModuleGraph/types.flow.js +++ b/packager/src/ModuleGraph/types.flow.js @@ -72,8 +72,9 @@ export type Module = {| export type OutputFn = ( modules: Iterable, - filename?: string, + filename: string, idForPath: IdForPathFn, + sourceMapPath?: string, ) => OutputResult; type OutputResult = {|