Add metro to paths to be babel-transformed
Reviewed By: fkgozali Differential Revision: D7620341 fbshipit-source-id: fc801c938628f5b6b118b8250d5c63268e19359e
This commit is contained in:
parent
7500b3ec83
commit
af661e4a6f
|
@ -11,7 +11,7 @@ const babelRegisterOnly = require('metro/src/babelRegisterOnly');
|
|||
const escapeRegExp = require('lodash/escapeRegExp');
|
||||
const path = require('path');
|
||||
|
||||
const BABEL_ENABLED_PATHS = ['local-cli'];
|
||||
const BABEL_ENABLED_PATHS = ['local-cli', 'metro'];
|
||||
|
||||
/**
|
||||
* We use absolute paths for matching only the top-level folders reliably. For
|
||||
|
@ -21,9 +21,13 @@ const BABEL_ENABLED_PATHS = ['local-cli'];
|
|||
function buildRegExps(basePath, dirPaths) {
|
||||
return dirPaths.map(
|
||||
folderPath =>
|
||||
folderPath === 'metro'
|
||||
// metro uses flow (for example) which needs to be stripped out w/babel.
|
||||
// it'll resolve to .../metro/packages/metro/src/index.js we want root
|
||||
? path.resolve(require.resolve('metro'), '..', '..', '..', '..')
|
||||
// Babel `only` option works with forward slashes in the RegExp so replace
|
||||
// backslashes for Windows.
|
||||
folderPath instanceof RegExp
|
||||
: folderPath instanceof RegExp
|
||||
? new RegExp(
|
||||
`^${escapeRegExp(
|
||||
path.resolve(basePath, '.').replace(/\\/g, '/')
|
||||
|
|
Loading…
Reference in New Issue