-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[autoloading] opt into autoloading with require #5871
Conversation
Currently there is a long list of modules that is autoloaded for every app. This is because a number of angular directives/filters/services are not properly required by the code that needs them and rather than attempt to track down the relationships between every part of the app and the rest autoloading just makes sure that all of the defined modules are included. Since this was implicit it caused new apps which didn't need anything but chrome styles to be really heavy. This change makes autoloading something you opt into by requiring a ui/autoload/* module. The options include: - `ui/autoload/styles` - include the base styles used by Kibana. This includes all of the styles listed in the ui/styles directory. - `ui/autoload/directives` - `ui/autoload/filters` - `ui/autoload/modules` - include angular and several ui modules that one might expect to be loaded by default. This list is hard coded into this file. - `ui/autoload/all` - includes all of the above lists In order to support this change all plugins will likely need to update and include a `ui/autoload/*` module in their public/index.js file.
Big fan of this change! Explicit > implicit 💯 |
I agree with @kjbekkelund and looking forward to seeing this get through! |
get autoload() { | ||
console.warn( | ||
`${this.package.id} accessed the autoload lists which are no longer available via the Plugin API.` + | ||
'Use the `ui/autoload/*` modules instead.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
LGTM. Just had a question asked out of curiosity. |
@@ -0,0 +1,2 @@ | |||
const context = require.context('../styles', false, /[\/\\](?!mixins|variables|_|\.)[^\/\\]+\.less/); | |||
context.keys().forEach(key => context(key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be changed to
context.keys().forEach(context);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I just don't like passing the other arguments (index and list). This feels concise enough.
[autoloading] opt into autoloading with require
With elastic#5871 we removed support for configuration-based autoloading and moved to require-based autoloading. This change is difficult for plugin authors to make in a backwards compatible way so I thought it would make sense to start helping plugin authors know which features are/are not available to them with a simple collection of "supports" flags. For now it just shows that `autoload: false`, so that plugins can expose an alternate main file which includes the autoloads they require
Currently there is a long list of modules that is autoloaded for every app. This is because a number of angular directives/filters/services are not properly required by the code that needs them and rather than attempt to track down the relationships between every part of the app, autoloading makes sure that all of the defined modules are included. Since this is currently included by default it caused new apps, which didn't need anything but chrome styles, to be really heavy and slow to reoptimize.
This change makes autoloading something you opt into by requiring a ui/autoload/* module. The options include:
require('ui/autoload/styles')
require('ui/autoload/directives')
require('ui/autoload/filters')
require('ui/autoload/modules')
require('ui/autoload/all')
In order to support this change all plugins will likely need to update and include a
ui/autoload/*
module in their public/index.js file.