mirror of https://github.com/status-im/metro.git
Don’t use unnecessary transforms for node 8
Summary: When running with node 8, the babel plugins `async-to-generator` and `syntax-trailing-function-commas` are unnecessary. Removing them makes runtime transpilation faster, and the resulting code is closer to the original (useful with debugging: less unmapped code areas, better breakpoint support, less renamed variables). Reviewed By: mjesun Differential Revision: D5842305 fbshipit-source-id: d99f719794e4a8f48fd10b0349fbb36f2994666e
This commit is contained in:
parent
2a64bd390e
commit
d56cef3493
|
@ -12,6 +12,19 @@ require('./setupNodePolyfills');
|
|||
|
||||
var _only = [];
|
||||
|
||||
const PLUGINS = [
|
||||
'transform-flow-strip-types',
|
||||
'transform-object-rest-spread',
|
||||
'transform-class-properties',
|
||||
];
|
||||
|
||||
if (/^v[0-7]\./.test(process.version)) {
|
||||
PLUGINS.push(
|
||||
'transform-async-to-generator',
|
||||
'syntax-trailing-function-commas'
|
||||
);
|
||||
}
|
||||
|
||||
function registerOnly(onlyList) {
|
||||
// This prevents `babel-register` from transforming the code of the
|
||||
// plugins/presets that we are require-ing themselves before setting up the
|
||||
|
@ -24,13 +37,7 @@ function config(onlyList) {
|
|||
_only = _only.concat(onlyList);
|
||||
return {
|
||||
presets: [require('babel-preset-es2015-node')],
|
||||
plugins: [
|
||||
'transform-flow-strip-types',
|
||||
'syntax-trailing-function-commas',
|
||||
'transform-object-rest-spread',
|
||||
'transform-async-to-generator',
|
||||
'transform-class-properties',
|
||||
].map(pluginName => require(`babel-plugin-${pluginName}`)),
|
||||
plugins: PLUGINS.map(pluginName => require(`babel-plugin-${pluginName}`)),
|
||||
only: _only,
|
||||
retainLines: true,
|
||||
sourceMaps: 'inline',
|
||||
|
|
Loading…
Reference in New Issue