mirror of https://github.com/status-im/metro.git
Move the getBabelRegisterConfig function to the one file that uses it
Reviewed By: rubennorte Differential Revision: D7788532 fbshipit-source-id: 1d08d159574247366492c036f5c530c982ec67b3
This commit is contained in:
parent
86e1a086aa
commit
f64ed1369e
|
@ -47,8 +47,6 @@ function resolvePlugins7(plugins: Array<any>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getBabelRegisterConfig: getBabelRegisterConfig7,
|
|
||||||
|
|
||||||
externalHelpersPlugin: externalHelpersPlugin7,
|
externalHelpersPlugin: externalHelpersPlugin7,
|
||||||
inlineRequiresPlugin: inlineRequiresPlugin7,
|
inlineRequiresPlugin: inlineRequiresPlugin7,
|
||||||
makeHMRConfig: makeHMRConfig7,
|
makeHMRConfig: makeHMRConfig7,
|
||||||
|
@ -112,51 +110,3 @@ function getPreset(name: string) {
|
||||||
//$FlowFixMe: TODO t26372934 this has to be dynamic
|
//$FlowFixMe: TODO t26372934 this has to be dynamic
|
||||||
return require(name);
|
return require(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBabelRegisterConfig7() {
|
|
||||||
// from: metro/packages/metro-babel-register/babel-register.js
|
|
||||||
// (dont use babel-register anymore, it obsoleted with babel 7)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copyright (c) 2015-present, Facebook, Inc.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
require('metro-babel-register/src/node-polyfills');
|
|
||||||
|
|
||||||
var _only = [];
|
|
||||||
|
|
||||||
const PLUGINS = [
|
|
||||||
'transform-flow-strip-types',
|
|
||||||
'proposal-object-rest-spread',
|
|
||||||
'proposal-class-properties',
|
|
||||||
];
|
|
||||||
|
|
||||||
function config(onlyList: Array<string>) {
|
|
||||||
/* $FlowFixMe(>=0.70.0 site=react_native_fb) This comment suppresses an
|
|
||||||
* error found when Flow v0.70 was deployed. To see the error delete this
|
|
||||||
* comment and run Flow. */
|
|
||||||
_only = _only.concat(onlyList);
|
|
||||||
return {
|
|
||||||
presets: [],
|
|
||||||
/* $FlowFixMe(>=0.70.0 site=react_native_fb) This comment suppresses an
|
|
||||||
* error found when Flow v0.70 was deployed. To see the error delete
|
|
||||||
* this comment and run Flow. */
|
|
||||||
plugins: PLUGINS.map(pluginName =>
|
|
||||||
// $FlowFixMe TODO t26372934 plugin require
|
|
||||||
require(`@babel/plugin-${pluginName}`),
|
|
||||||
),
|
|
||||||
only: _only,
|
|
||||||
retainLines: true,
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
babelrc: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,11 +14,58 @@
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const {getBabelRegisterConfig} = require('../../../babel-bridge');
|
|
||||||
const {transformSync} = require('@babel/core');
|
const {transformSync} = require('@babel/core');
|
||||||
|
|
||||||
const babelConfig = getBabelRegisterConfig();
|
const babelConfig = getBabelRegisterConfig();
|
||||||
|
|
||||||
|
function getBabelRegisterConfig() {
|
||||||
|
// from: metro/packages/metro-babel-register/babel-register.js
|
||||||
|
// (dont use babel-register anymore, it obsoleted with babel 7)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2015-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('metro-babel-register/src/node-polyfills');
|
||||||
|
|
||||||
|
var _only = [];
|
||||||
|
|
||||||
|
const PLUGINS = [
|
||||||
|
'transform-flow-strip-types',
|
||||||
|
'proposal-object-rest-spread',
|
||||||
|
'proposal-class-properties',
|
||||||
|
];
|
||||||
|
|
||||||
|
function config(onlyList: Array<string>) {
|
||||||
|
/* $FlowFixMe(>=0.70.0 site=react_native_fb) This comment suppresses an
|
||||||
|
* error found when Flow v0.70 was deployed. To see the error delete this
|
||||||
|
* comment and run Flow. */
|
||||||
|
_only = _only.concat(onlyList);
|
||||||
|
return {
|
||||||
|
presets: [],
|
||||||
|
/* $FlowFixMe(>=0.70.0 site=react_native_fb) This comment suppresses an
|
||||||
|
* error found when Flow v0.70 was deployed. To see the error delete
|
||||||
|
* this comment and run Flow. */
|
||||||
|
plugins: PLUGINS.map(pluginName =>
|
||||||
|
// $FlowFixMe TODO t26372934 plugin require
|
||||||
|
require(`@babel/plugin-${pluginName}`),
|
||||||
|
),
|
||||||
|
only: _only,
|
||||||
|
retainLines: true,
|
||||||
|
sourceMaps: 'inline',
|
||||||
|
babelrc: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
describe('require', () => {
|
describe('require', () => {
|
||||||
const moduleSystemCode = (() => {
|
const moduleSystemCode = (() => {
|
||||||
const {only, ...config} = babelConfig([]);
|
const {only, ...config} = babelConfig([]);
|
||||||
|
|
Loading…
Reference in New Issue