[babel] tweak babel options for performance and debugging (#11535)

* [babel] tweak babel options for performance and debugging

* [babel] remove babel-plugin-transform-export-extensions

* [npm] lock new deps to the patch version

* [npm] remove unused deps
This commit is contained in:
Spencer 2017-05-08 15:29:28 -07:00 committed by GitHub
parent 08cbcb75b9
commit 36ecf130ad
35 changed files with 94 additions and 90 deletions

View file

@ -97,14 +97,13 @@
"babel-jest": "19.0.0",
"babel-loader": "6.2.10",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-transform-async-generator-functions": "6.24.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.23.0",
"babel-polyfill": "6.20.0",
"babel-preset-env": "1.1.8",
"babel-preset-es2015": "6.22.0",
"babel-preset-es2015-node": "6.1.1",
"babel-preset-env": "1.4.0",
"babel-preset-react": "6.22.0",
"babel-preset-stage-1": "6.22.0",
"babel-register": "6.18.0",
"babel-runtime": "6.20.0",
"bluebird": "2.9.34",
"body-parser": "1.12.0",
"boom": "2.8.0",
@ -204,6 +203,7 @@
},
"devDependencies": {
"@elastic/eslint-config-kibana": "0.5.0",
"@elastic/eslint-plugin-kibana-custom": "1.0.3",
"@spalger/babel-presets": "0.3.2",
"angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3",
@ -219,7 +219,6 @@
"eslint": "3.11.1",
"eslint-plugin-babel": "4.0.0",
"eslint-plugin-jest": "19.0.1",
"@elastic/eslint-plugin-kibana-custom": "1.0.3",
"eslint-plugin-mocha": "4.7.0",
"eslint-plugin-react": "6.10.3",
"event-stream": "3.3.2",

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import pkg from '../utils/package_json';
import { pkg } from '../utils';
import Command from './command';
import serveCommand from './serve/serve';

View file

@ -81,7 +81,7 @@ module.exports = class ClusterManager {
setupWatching(extraPaths) {
const chokidar = require('chokidar');
const fromRoot = require('../../utils/from_root');
const { fromRoot } = require('../../utils');
const watchPaths = [
fromRoot('src/core_plugins'),

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import pkg from '../utils/package_json';
import { pkg } from '../utils';
import Command from '../cli/command';
import listCommand from './list';
import installCommand from './install';

View file

@ -1,7 +1,7 @@
import { fromRoot } from '../../utils';
import install from './install';
import Logger from '../lib/logger';
import pkg from '../../utils/package_json';
import { pkg } from '../../utils';
import { getConfig } from '../../server/path';
import { parse, parseMilliseconds } from './settings';
import logWarnings from '../lib/log_warnings';

View file

@ -1,5 +1,5 @@
import expect from 'expect.js';
import fromRoot from '../../../utils/from_root';
import { fromRoot } from '../../../utils';
import { parse } from '../settings';
describe('kibana cli', function () {

View file

@ -1,5 +1,5 @@
import expect from 'expect.js';
import fromRoot from '../../../utils/from_root';
import { fromRoot } from '../../../utils';
import { parse } from '../settings';
describe('kibana cli', function () {

View file

@ -2,7 +2,7 @@ import _ from 'lodash';
import expect from 'expect.js';
import isUpgradeable from '../is_upgradeable';
import pkg from '../../../../utils/package_json';
import { pkg } from '../../../../utils';
let version = pkg.version;
describe('plugins/elasticsearch', function () {

View file

@ -1,7 +1,7 @@
import { format } from 'util';
import * as kbnTestServer from '../../../../../test/utils/kbn_server';
import fromRoot from '../../../../utils/from_root';
import { fromRoot } from '../../../../utils';
describe('plugins/elasticsearch', function () {
describe('routes', function () {

View file

@ -1,7 +1,7 @@
import expect from 'expect.js';
import sinon from 'sinon';
import * as kbnTestServer from '../../../../../../test/utils/kbn_server.js';
import fromRoot from '../../../../../utils/from_root';
import { fromRoot } from '../../../../../utils';
import manageUuid from '../manage_uuid';
describe('core_plugins/kibana/server/lib', function () {

View file

@ -1,4 +1,4 @@
import createTransform from '../create_transform';
import { createTransform } from '../create_transform';
import expect from 'expect.js';
import sinon from 'sinon';

View file

@ -1,7 +1,7 @@
import { deepCloneWithBuffers as clone } from '../utils';
import { forEach, noop } from 'lodash';
export default function (deprecations) {
export function createTransform(deprecations) {
return (settings, log = noop) => {
const result = clone(settings);

View file

@ -1,5 +1,5 @@
import expect from 'expect.js';
import rename from '../rename';
import { rename } from '../rename';
import sinon from 'sinon';
describe('deprecation/deprecations', function () {

View file

@ -1,6 +1,6 @@
import expect from 'expect.js';
import sinon from 'sinon';
import unused from '../unused';
import { unused } from '../unused';
describe('deprecation/deprecations', function () {
describe('unused', function () {

View file

@ -1,2 +1,2 @@
export rename from './rename';
export unused from './unused';
export { rename } from './rename';
export { unused } from './unused';

View file

@ -1,7 +1,7 @@
import { get, isUndefined, noop, set } from 'lodash';
import { unset } from '../../utils';
export default function (oldKey, newKey) {
export function rename(oldKey, newKey) {
return (settings, log = noop) => {
const value = get(settings, oldKey);
if (isUndefined(value)) {

View file

@ -1,7 +1,7 @@
import { get, isUndefined, noop } from 'lodash';
import { unset } from '../../utils';
export default function (oldKey) {
export function unused(oldKey) {
return (settings, log = noop) => {
const value = get(settings, oldKey);
if (isUndefined(value)) {

View file

@ -1,2 +1,4 @@
export createTransform from './create_transform';
export * as Deprecations from './deprecations';
import { rename, unused } from './deprecations';
export { createTransform } from './create_transform';
export const Deprecations = { rename, unused };

View file

@ -9,39 +9,47 @@ if (!env.BABEL_CACHE_PATH) {
exports.webpackCacheDir = env.WEBPACK_BABEL_CACHE_DIR || fromRoot('optimize/.webpack.babelcache');
exports.nodePresets = [
[
require.resolve('babel-preset-env'),
{
const commonPreset = {
presets: [
require.resolve('babel-preset-react')
],
plugins: [
require.resolve('babel-plugin-add-module-exports'),
// stage 3
require.resolve('babel-plugin-transform-async-generator-functions'),
require.resolve('babel-plugin-transform-object-rest-spread'),
// stage 2
require.resolve('babel-plugin-transform-class-properties'),
],
}
exports.nodePreset = {
presets: [
[require.resolve('babel-preset-env'), {
targets: {
node: 'current'
}
}
},
useBuiltIns: true,
}],
commonPreset,
],
require.resolve('babel-preset-stage-1'),
require.resolve('babel-preset-react'),
];
};
exports.webpackPresets = [
[
require.resolve('babel-preset-env'),
{
exports.webpackPreset = {
presets: [
[require.resolve('babel-preset-env'), {
targets: {
browsers: [
'last 2 versions',
'> 5%',
'Safari 7' // for PhantomJS support
]
}
}
},
useBuiltIns: true,
}],
commonPreset,
],
require.resolve('babel-preset-stage-1'),
require.resolve('babel-preset-react'),
]
exports.plugins = [
require.resolve('babel-plugin-add-module-exports'),
];
}
exports.devIgnore = [
/[\\\/](node_modules|bower_components)[\\\/]/

View file

@ -1,19 +1,16 @@
const {
nodePresets,
webpackPresets,
plugins,
nodePreset,
webpackPreset,
buildIgnore
} = require('./helpers');
const nodeOptions = {
presets: nodePresets,
plugins,
presets: [nodePreset],
ignore: buildIgnore
};
exports.webpack = {
presets: webpackPresets,
plugins: plugins
presets: [webpackPreset],
};
exports.node = nodeOptions;

View file

@ -1,23 +1,20 @@
// this file is not transpiled in dev
const {
nodePresets,
webpackPresets,
nodePreset,
webpackPreset,
webpackCacheDir,
plugins,
devIgnore
} = require('./helpers');
const nodeOptions = {
presets: nodePresets,
plugins,
presets: [nodePreset],
ignore: devIgnore
};
exports.webpack = {
cacheDirectory: webpackCacheDir,
presets: webpackPresets,
plugins: plugins
presets: [webpackPreset],
};
exports.node = nodeOptions;

View file

@ -0,0 +1,2 @@
// this is in it's own file so babel-preset-env can convert it to just the polyfills necessary
require('babel-polyfill');

View file

@ -1,4 +1,3 @@
// this file is not transpiled in dev
require('babel-polyfill');
require('./options').registerNodeOptions();
require('./polyfills');

View file

@ -10,7 +10,7 @@ import DefinePlugin from 'webpack/lib/DefinePlugin';
import UglifyJsPlugin from 'webpack/lib/optimize/UglifyJsPlugin';
import { defaults, transform } from 'lodash';
import fromRoot from '../utils/from_root';
import { fromRoot } from '../utils';
import babelOptions from './babel/options';
import pkg from '../../package.json';
import { setLoaderQueryParam, makeLoaderString } from './loaders';

View file

@ -1,6 +1,6 @@
import expect from 'expect.js';
import * as kbnTestServer from '../../../../test/utils/kbn_server';
import fromRoot from '../../../utils/from_root';
import { fromRoot } from '../../../utils';
describe('routes', function () {
this.slow(10000);

View file

@ -1,4 +1,4 @@
import fromRoot from '../utils/from_root';
import { fromRoot } from '../utils';
import { includes } from 'lodash';
const arr = v => [].concat(v || []);

View file

@ -1,4 +1,4 @@
import deepCloneWithBuffers from '../deep_clone_with_buffers';
import { deepCloneWithBuffers } from '../deep_clone_with_buffers';
import expect from 'expect.js';
describe('deepCloneWithBuffers()', function () {

View file

@ -1,4 +1,4 @@
import unset from '../unset';
import { unset } from '../unset';
import expect from 'expect.js';
describe('unset(obj, key)', function () {

View file

@ -1,6 +1,6 @@
import { BinderBase } from './binder';
export default class BinderFor extends BinderBase {
export class BinderFor extends BinderBase {
constructor(emitter) {
super();
this.emitter = emitter;
@ -10,4 +10,3 @@ export default class BinderFor extends BinderBase {
super.on(this.emitter, ...args);
}
}

View file

@ -6,6 +6,6 @@ function cloneBuffersCustomizer(val) {
}
}
export default function (vals) {
export function deepCloneWithBuffers(vals) {
return cloneDeep(vals, cloneBuffersCustomizer);
}

View file

@ -1,5 +1,6 @@
import _ from 'lodash';
import { __dirname as root } from './package_json';
import { join, normalize } from 'path';
import { pkg } from './package_json';
import { resolve } from 'path';
module.exports = _.flow(_.partial(join, root), normalize);
export function fromRoot(...args) {
return resolve(pkg.__dirname, ...args);
}

View file

@ -1,11 +1,12 @@
export { BinderBase } from './binder';
export BinderFor from './binder_for';
export deepCloneWithBuffers from './deep_clone_with_buffers';
export fromRoot from './from_root';
export pkg from './package_json';
export unset from './unset';
export { BinderFor } from './binder_for';
export { deepCloneWithBuffers } from './deep_clone_with_buffers';
export { fromRoot } from './from_root';
export { pkg } from './package_json';
export { unset } from './unset';
export { encodeQueryComponent } from './encode_query_component';
export { modifyUrl } from './modify_url';
export { createToolingLog } from './tooling_log';
export {
createConcatStream,
@ -17,6 +18,3 @@ export {
createReduceStream,
createSplitStream,
} from './streams';
export { modifyUrl } from './modify_url';
export { createToolingLog } from './tooling_log';

View file

@ -1,5 +1,7 @@
import { dirname } from 'path';
module.exports = require('../../package.json');
module.exports.__filename = require.resolve('../../package.json');
module.exports.__dirname = dirname(module.exports.__filename);
export const pkg = {
__filename: require.resolve('../../package.json'),
__dirname: dirname(require.resolve('../../package.json')),
...require('../../package.json')
};

View file

@ -1,7 +1,7 @@
import _ from 'lodash';
import toPath from 'lodash/internal/toPath';
module.exports = function unset(object, rawPath) {
export function unset(object, rawPath) {
if (!object) return;
const path = toPath(rawPath);
@ -23,4 +23,4 @@ module.exports = function unset(object, rawPath) {
}
break;
}
};
}

View file

@ -1,7 +1,7 @@
import Promise from 'bluebird';
import _ from 'lodash';
import fromRoot from '../../src/utils/from_root';
import { fromRoot } from '../../src/utils';
import KbnServer from '../../src/server/kbn_server';
import * as i18nVerify from '../utils/i18n_verify_keys';