From 2510b30f08a1a9c32b7d1a7d84a6ee259305be3e Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 2 Feb 2016 10:12:58 -0700 Subject: [PATCH 1/2] [autoload] support autoload without breaking bwc --- index.js | 11 +++++++++-- public/app_with_autoload.js | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 public/app_with_autoload.js diff --git a/index.js b/index.js index 20ba7478b8119..0bdfc9608bff0 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,13 @@ var path = require('path'); module.exports = function (kibana) { + var mainFile = 'plugins/timelion/app'; + if (Object.getOwnPropertyDescriptor(kibana.constructor.prototype, 'autoload').get) { + // the autoload list has been replaced with a getter that complains about + // improper access, bypass that getter by seeing if it is defined + mainFile = 'plugins/timelion/app_with_autoload'; + } + return new kibana.Plugin({ require: ['kibana', 'elasticsearch'], uiExports: { @@ -9,7 +16,7 @@ module.exports = function (kibana) { title: 'Timelion', description: 'Time series expressions for everything', icon: 'plugins/timelion/icon.svg', - main: 'plugins/timelion/app', + main: mainFile, injectVars: function (server, options) { var config = server.config(); return { @@ -51,4 +58,4 @@ module.exports = function (kibana) { }, init: require('./init.js'), }); -};; +}; diff --git a/public/app_with_autoload.js b/public/app_with_autoload.js new file mode 100644 index 0000000000000..66d538a260174 --- /dev/null +++ b/public/app_with_autoload.js @@ -0,0 +1,2 @@ +require('ui/autoload/all'); +require('./app'); From a099523171dbffae64126299eb78a0e437df1719 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 3 Feb 2016 13:41:40 -0700 Subject: [PATCH 2/2] [autoload] support 4.x defined autoload as an own prop --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 0bdfc9608bff0..8b6f7ee218d88 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,11 @@ var path = require('path'); module.exports = function (kibana) { var mainFile = 'plugins/timelion/app'; - if (Object.getOwnPropertyDescriptor(kibana.constructor.prototype, 'autoload').get) { + + var ownDescriptor = Object.getOwnPropertyDescriptor(kibana, 'autoload'); + var protoDescriptor = Object.getOwnPropertyDescriptor(kibana.constructor.prototype, 'autoload'); + var descriptor = ownDescriptor || protoDescriptor || {}; + if (descriptor.get) { // the autoload list has been replaced with a getter that complains about // improper access, bypass that getter by seeing if it is defined mainFile = 'plugins/timelion/app_with_autoload';