From 4a2df475094e1b0498127575266ca5f2823ac063 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 10 Feb 2016 07:26:32 -0700 Subject: [PATCH 1/3] [optimize] extend webpack config so plugins can live anywhere --- src/optimize/BaseOptimizer.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/optimize/BaseOptimizer.js b/src/optimize/BaseOptimizer.js index dd7aba90e208..19a0c2fedd4b 100644 --- a/src/optimize/BaseOptimizer.js +++ b/src/optimize/BaseOptimizer.js @@ -4,14 +4,14 @@ import DirectoryNameAsMain from 'webpack-directory-name-as-main'; import ExtractTextPlugin from 'extract-text-webpack-plugin'; import CommonsChunkPlugin from 'webpack/lib/optimize/CommonsChunkPlugin'; -let utils = require('requirefrom')('src/utils'); -let fromRoot = utils('fromRoot'); +import fromRoot from '../utils/fromRoot'; import babelOptions from './babelOptions'; import { inherits } from 'util'; -import { defaults } from 'lodash'; +import { defaults, transform } from 'lodash'; import { resolve } from 'path'; import { writeFile } from 'fs'; let babelExclude = [/[\/\\](webpackShims|node_modules|bower_components)[\/\\]/]; +import pkg from '../../package.json'; class BaseOptimizer { constructor(opts) { @@ -133,12 +133,20 @@ class BaseOptimizer { resolve: { extensions: ['.js', '.json', '.jsx', '.less', ''], postfixes: [''], - modulesDirectories: ['webpackShims', 'node_modules'], + modulesDirectories: ['webpackShims', 'node_modules', fromRoot('webpackShims'), fromRoot('node_modules')], loaderPostfixes: ['-loader', ''], root: fromRoot('.'), alias: this.env.aliases, unsafeCache: this.unsafeCache, }, + + resolveLoader: { + alias: transform(pkg.dependencies, function (aliases, version, name) { + if (name.endsWith('-loader')) { + aliases[name.replace(/-loader$/, '')] = require.resolve(name); + } + }, {}) + } }; } From 1606a1f7485663c62bd19e2a7e33c2a9f50a9dca Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 10 Feb 2016 07:34:07 -0700 Subject: [PATCH 2/3] [clusterManager] watch the plugin paths for changes --- src/cli/cluster/cluster_manager.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cli/cluster/cluster_manager.js b/src/cli/cluster/cluster_manager.js index 71caff841490..dce3184ba61a 100644 --- a/src/cli/cluster/cluster_manager.js +++ b/src/cli/cluster/cluster_manager.js @@ -63,7 +63,13 @@ module.exports = class ClusterManager { bindAll(this, 'onWatcherAdd', 'onWatcherError', 'onWatcherChange'); - if (opts.watch) this.setupWatching(); + if (opts.watch) { + this.setupWatching([ + ...settings.plugins.paths, + ...settings.plugins.scanDirs + ]); + } + else this.startCluster(); } @@ -75,7 +81,7 @@ module.exports = class ClusterManager { } } - setupWatching() { + setupWatching(extraPaths) { const chokidar = require('chokidar'); const utils = require('requirefrom')('src/utils'); const fromRoot = utils('fromRoot'); @@ -86,7 +92,7 @@ module.exports = class ClusterManager { 'src/ui', 'src/utils', 'config', - 'installedPlugins' + ...extraPaths ], { cwd: fromRoot('.'), ignored: /[\\\/](\..*|node_modules|bower_components|public|__tests__)[\\\/]/ From cd09048fc4c84c0fd16d80033d79ef8b636b5130 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 11 Feb 2016 20:31:31 -0700 Subject: [PATCH 3/3] [babel] skip runtime transform for node code without this, plugins outside of the kibana code base will need to install the babel-runtime. --- src/optimize/babelOptions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/optimize/babelOptions.js b/src/optimize/babelOptions.js index 3fcdc0151456..df98c4b71a81 100644 --- a/src/optimize/babelOptions.js +++ b/src/optimize/babelOptions.js @@ -12,3 +12,5 @@ exports.webpack = { }; exports.node = cloneDeep(exports.webpack); +exports.node.optional = ['asyncToGenerator']; +exports.node.blacklist = ['regenerator'];