mirror of https://github.com/status-im/metro.git
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
This commit is contained in:
parent
c5dfa2dbd5
commit
cb6bace9c6
|
@ -16,7 +16,7 @@ const {addModuleIdsToModuleWrapper} = require('./util');
|
||||||
import type {OutputFn} from '../types.flow';
|
import type {OutputFn} from '../types.flow';
|
||||||
|
|
||||||
module.exports = (
|
module.exports = (
|
||||||
(modules, filename, idForPath) => {
|
(modules, filename, idForPath, sourceMapPath) => {
|
||||||
let code = '';
|
let code = '';
|
||||||
let line = 0;
|
let line = 0;
|
||||||
const sections = [];
|
const sections = [];
|
||||||
|
@ -37,6 +37,10 @@ module.exports = (
|
||||||
line += countLines(moduleCode);
|
line += countLines(moduleCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sourceMapPath) {
|
||||||
|
code += `/*# sourceMappingURL=${sourceMapPath}*/`;
|
||||||
|
}
|
||||||
|
|
||||||
return {code, map: createIndexMap({file: filename, sections})};
|
return {code, map: createIndexMap({file: filename, sections})};
|
||||||
}: OutputFn);
|
}: OutputFn);
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,9 @@ export type Module = {|
|
||||||
|
|
||||||
export type OutputFn = (
|
export type OutputFn = (
|
||||||
modules: Iterable<Module>,
|
modules: Iterable<Module>,
|
||||||
filename?: string,
|
filename: string,
|
||||||
idForPath: IdForPathFn,
|
idForPath: IdForPathFn,
|
||||||
|
sourceMapPath?: string,
|
||||||
) => OutputResult;
|
) => OutputResult;
|
||||||
|
|
||||||
type OutputResult = {|
|
type OutputResult = {|
|
||||||
|
|
Loading…
Reference in New Issue