2015-10-09 14:56:00 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2017-05-02 12:28:15 +00:00
|
|
|
require('./setupNodePolyfills');
|
2015-11-10 18:51:39 +00:00
|
|
|
|
2015-10-09 14:56:00 +00:00
|
|
|
var _only = [];
|
|
|
|
|
2016-07-15 13:25:27 +00:00
|
|
|
function registerOnly(onlyList) {
|
|
|
|
require('babel-register')(config(onlyList));
|
|
|
|
}
|
2016-05-21 13:53:32 +00:00
|
|
|
|
2016-07-15 13:25:27 +00:00
|
|
|
function config(onlyList) {
|
|
|
|
_only = _only.concat(onlyList);
|
|
|
|
return {
|
2017-05-11 13:37:32 +00:00
|
|
|
presets: [require('babel-preset-es2015-node')],
|
2016-05-21 13:53:32 +00:00
|
|
|
plugins: [
|
|
|
|
'transform-flow-strip-types',
|
|
|
|
'syntax-trailing-function-commas',
|
|
|
|
'transform-object-rest-spread',
|
packager: introducing async/await, return of the yarn
Summary:
The first time I tried to commit this changeset, it was causing many new packages to be installed, because the dependency would depend on newer versions that what we have installed. So, I had made a diff so upgrade all the babel packages. Unfortunately this caused some problem as the newer versions of Babel are more strict on some syntaxes. Of course, these have to be addressed, but I don't want this changeset to be coupled with Babel upgrades and the issues that arise from it.
So instead, I decided to install the slightly older version of the async-to-generator module. At first I tried with just doing:
yarn add babel-plugin-transform-async-to-generator@6.16.0
But, `yarn` is stubborn: because this module depends on a caret version of `babel-helper-remap-async-to-generator`, it installs the very last version of it, that itself needs more recent versions of other Babel modules. So, instead, I add to install a slightly older version of the dependency manually, then then the plugin:
yarn add babel-helper-remap-async-to-generator@6.16.0
yarn add babel-plugin-transform-async-to-generator@6.16.0
This allows us to have a `yarn.lock` with only a minimal amount of changes, and uncouple this change from any Babel upgrades. Because we only have a few new modules, the `node_modules` folder also stays the same, 133M, and it gives us confidence this will not cause significant startup time regressions.
Reviewed By: cpojer
Differential Revision: D4578733
fbshipit-source-id: deb0f720b895b7196aaf432adec3e56f18663940
2017-02-20 16:35:57 +00:00
|
|
|
'transform-async-to-generator',
|
2017-05-11 13:37:32 +00:00
|
|
|
].map(pluginName => require(`babel-plugin-${pluginName}`)),
|
2016-05-21 13:53:32 +00:00
|
|
|
only: _only,
|
2016-07-15 13:25:27 +00:00
|
|
|
retainLines: true,
|
2016-05-21 13:53:32 +00:00
|
|
|
sourceMaps: 'inline',
|
2016-07-15 13:25:27 +00:00
|
|
|
babelrc: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = registerOnly;
|
|
|
|
exports.config = config;
|