Babel transformations refactoring
Summary: Just a small refactoring to only create array with plugins once. This should make transformations a bit faster as all these methods are called many times for each file in the project. Reviewed By: passy Differential Revision: D21308498 fbshipit-source-id: 0ed47f13cebfebd2992817caa207dc55f1dbeb0a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c21ccedf14
commit
b0a0b0f355
@@ -11,6 +11,15 @@ import {default as doTransform} from './transform';
|
||||
import {default as getCacheKey} from './get-cache-key';
|
||||
import {default as flipperEnv} from './flipper-env';
|
||||
|
||||
const presets = [require('@babel/preset-react')];
|
||||
const plugins = [require('./import-react')];
|
||||
if (flipperEnv.FLIPPER_HEADLESS) {
|
||||
plugins.unshift(require('./electron-stubs'));
|
||||
}
|
||||
if (flipperEnv.FLIPPER_FB) {
|
||||
plugins.unshift(require('./fb-stubs'));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
transform,
|
||||
getCacheKey,
|
||||
@@ -25,14 +34,5 @@ function transform({
|
||||
options: any;
|
||||
src: string;
|
||||
}) {
|
||||
const presets = [require('@babel/preset-react')];
|
||||
const plugins = [];
|
||||
if (flipperEnv.FLIPPER_FB) {
|
||||
plugins.push(require('./fb-stubs'));
|
||||
}
|
||||
if (flipperEnv.FLIPPER_HEADLESS) {
|
||||
plugins.push(require('./electron-stubs'));
|
||||
}
|
||||
plugins.push(require('./import-react'));
|
||||
return doTransform({filename, options, src, presets, plugins});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user