Skip to content

Commit

Permalink
Remove compactMapping call from JS transformer
Browse files Browse the repository at this point in the history
Reviewed By: mjesun

Differential Revision: D6136200

fbshipit-source-id: a38cf19c247f60c0bfee01c39fae070043a76332
  • Loading branch information
rafeca authored and facebook-github-bot committed Oct 25, 2017
1 parent fa4091c commit d74685f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/metro-bundler/src/JSTransformer/worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const inline = require('./inline');
const invariant = require('fbjs/lib/invariant');
const minify = require('./minify');

const {compactMapping} = require('../../Bundler/source-map');

import type {LogEntry} from '../../Logger/Types';
import type {MappingsMap} from '../../lib/SourceMap';
import type {LocalPath} from '../../node-haste/lib/toLocalPath';
Expand Down Expand Up @@ -123,6 +125,11 @@ const transformCode: TransformCode = asyncify(
src: sourceCode,
});

// TODO: Add more robust check once the transformer only returns rawMappings
if (Array.isArray(transformed.map)) {
transformed.map = transformed.map.map(compactMapping);
}

invariant(
transformed != null,
'Missing transform results despite having no error.',
Expand Down
6 changes: 1 addition & 5 deletions packages/metro-bundler/src/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const makeHMRConfig = require('babel-preset-react-native/configs/hmr');
const path = require('path');
const resolvePlugins = require('babel-preset-react-native/lib/resolvePlugins');

const {compactMapping} = require('./Bundler/source-map');

import type {Plugins as BabelPlugins} from 'babel-core';
import type {Transformer, TransformOptions} from './JSTransformer/worker';

Expand Down Expand Up @@ -161,9 +159,7 @@ function transform({filename, options, src, plugins}: Params) {
ast,
code: result.code,
filename,
map: options.generateSourceMaps
? result.map
: result.rawMappings.map(compactMapping),
map: options.generateSourceMaps ? result.map : result.rawMappings,
};
}
} finally {
Expand Down

0 comments on commit d74685f

Please sign in to comment.