mirror of https://github.com/status-im/metro.git
Rename functions to clarify output
Reviewed By: mjesun Differential Revision: D6702879 fbshipit-source-id: 23daa9027425c2dd1d020eae9873bab092fff573
This commit is contained in:
parent
4403f81102
commit
5c2fb8d327
|
@ -149,7 +149,7 @@ class Generator {
|
|||
/**
|
||||
* Return the source map as object.
|
||||
*/
|
||||
toMap(file?: string, options: {excludeSource?: boolean}): BabelSourceMap {
|
||||
toMap(file?: string, options?: {excludeSource?: boolean}): BabelSourceMap {
|
||||
let content;
|
||||
|
||||
if (options && options.excludeSource) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @emails oncal+javascript_foundation
|
||||
* @flow
|
||||
* @format
|
||||
*/
|
||||
|
||||
|
@ -14,11 +15,11 @@
|
|||
|
||||
const Generator = require('../Generator');
|
||||
|
||||
const {compactMapping, fromRawMappings, toRawMappings} = require('..');
|
||||
const {toSegmentTuple, fromRawMappings, toBabelSegments} = require('..');
|
||||
|
||||
describe('flattening mappings / compacting', () => {
|
||||
it('flattens simple mappings', () => {
|
||||
expect(compactMapping({generated: {line: 12, column: 34}})).toEqual([
|
||||
expect(toSegmentTuple({generated: {line: 12, column: 34}})).toEqual([
|
||||
12,
|
||||
34,
|
||||
]);
|
||||
|
@ -26,7 +27,7 @@ describe('flattening mappings / compacting', () => {
|
|||
|
||||
it('flattens mappings with a source location', () => {
|
||||
expect(
|
||||
compactMapping({
|
||||
toSegmentTuple({
|
||||
generated: {column: 34, line: 12},
|
||||
original: {column: 78, line: 56},
|
||||
}),
|
||||
|
@ -35,7 +36,7 @@ describe('flattening mappings / compacting', () => {
|
|||
|
||||
it('flattens mappings with a source location and a symbol name', () => {
|
||||
expect(
|
||||
compactMapping({
|
||||
toSegmentTuple({
|
||||
generated: {column: 34, line: 12},
|
||||
name: 'arbitrary',
|
||||
original: {column: 78, line: 56},
|
||||
|
@ -93,7 +94,7 @@ describe('build map from raw mappings', () => {
|
|||
|
||||
describe('convert a sourcemap into raw mappings', () => {
|
||||
expect(
|
||||
toRawMappings({
|
||||
toBabelSegments({
|
||||
mappings:
|
||||
'E;;IAIMA;;;;QAII;;;;YAIIC;E;;ICEEC;;;;;;;;;;;Y;;cCAAA;;;;kBAI8F;;;;gHA8FID',
|
||||
names: ['apples', 'pears', 'bananas'],
|
||||
|
|
|
@ -89,7 +89,7 @@ function fromRawMappings(
|
|||
* Transforms a standard source map object into a Raw Mappings object, to be
|
||||
* used across the bundler.
|
||||
*/
|
||||
function toRawMappings(
|
||||
function toBabelSegments(
|
||||
sourceMap: BabelSourceMap,
|
||||
): Array<BabelSourceMapSegment> {
|
||||
const rawMappings = [];
|
||||
|
@ -112,7 +112,7 @@ function toRawMappings(
|
|||
return rawMappings;
|
||||
}
|
||||
|
||||
function compactMapping(
|
||||
function toSegmentTuple(
|
||||
mapping: BabelSourceMapSegment,
|
||||
): MetroSourceMapSegmentTuple {
|
||||
const {column, line} = mapping.generated;
|
||||
|
@ -172,6 +172,6 @@ function countLines(string) {
|
|||
|
||||
module.exports = {
|
||||
fromRawMappings,
|
||||
toRawMappings,
|
||||
compactMapping,
|
||||
toBabelSegments,
|
||||
toSegmentTuple,
|
||||
};
|
||||
|
|
|
@ -21,9 +21,9 @@ const fs = require('fs');
|
|||
const getTransformCacheKeyFn = require('../lib/getTransformCacheKeyFn');
|
||||
|
||||
const {
|
||||
compactMapping,
|
||||
toSegmentTuple,
|
||||
fromRawMappings,
|
||||
toRawMappings,
|
||||
toBabelSegments,
|
||||
} = require('metro-source-map');
|
||||
|
||||
import type {PostProcessModules} from '../DeltaBundler';
|
||||
|
@ -267,7 +267,7 @@ class Bundler {
|
|||
|
||||
return {
|
||||
code: result.code,
|
||||
map: result.map ? toRawMappings(result.map).map(compactMapping) : [],
|
||||
map: result.map ? toBabelSegments(result.map).map(toSegmentTuple) : [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ const minify = require('./minify');
|
|||
const optimizeDependencies = require('../../ModuleGraph/worker/optimizeDependencies');
|
||||
const path = require('path');
|
||||
|
||||
const {compactMapping} = require('metro-source-map');
|
||||
const {toSegmentTuple} = require('metro-source-map');
|
||||
|
||||
import type {LogEntry} from 'metro-core/src/Logger';
|
||||
import type {BabelSourceMap} from 'babel-core';
|
||||
|
@ -151,7 +151,7 @@ function postTransform(
|
|||
sourceCode,
|
||||
);
|
||||
|
||||
const map = result.rawMappings ? result.rawMappings.map(compactMapping) : [];
|
||||
const map = result.rawMappings ? result.rawMappings.map(toSegmentTuple) : [];
|
||||
|
||||
return {
|
||||
result: {dependencies, code: result.code, map},
|
||||
|
|
|
@ -19,7 +19,7 @@ const debug = require('debug');
|
|||
const invariant = require('fbjs/lib/invariant');
|
||||
|
||||
const {Logger} = require('metro-core');
|
||||
const {fromRawMappings, compactMapping} = require('metro-source-map');
|
||||
const {fromRawMappings, toSegmentTuple} = require('metro-source-map');
|
||||
|
||||
import type {ConfigT as MetroConfig} from './Config';
|
||||
import type Server from './Server';
|
||||
|
@ -27,7 +27,7 @@ import type {TransformCache} from './lib/TransformCaching';
|
|||
import type {Options as ServerOptions} from './shared/types.flow';
|
||||
|
||||
exports.createBlacklist = blacklist;
|
||||
exports.sourceMaps = {fromRawMappings, compactMapping};
|
||||
exports.sourceMaps = {fromRawMappings, compactMapping: toSegmentTuple};
|
||||
exports.createServer = createServer;
|
||||
exports.Logger = Logger;
|
||||
|
||||
|
|
Loading…
Reference in New Issue