-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Remove use of Webpack aliases #6430
Comments
I couldn't possibly agree more with this, and I have nothing more to add. +1 |
I'm generally in favor of this change, but I do want to point out that we need to figure out how we expose functionality from core to plugins, or even expose functionality between plugins outside of core. One proposal is to follow what we do with on the server code with the |
For the first one Any ideas on if there is a way to achieve this without requiring all the import code to change to a slew of |
@stacey-gammon Options that I see:
|
Looks like eslint-plugin-import has an ability to write custom resolvers to handle this kind of thing: https://github.com/benmosher/eslint-plugin-import/blob/master/resolvers/README.md There is also one for webpack: https://www.npmjs.com/package/eslint-import-resolver-webpack But I'm not knowledgable enough with our webpack set up to figure that one out. For instance, I can't find a webpack config file (except in the ui_framework, but that's not the one for ui/public). cc @spalger |
You'll find the webpack code in this folder: https://github.com/elastic/kibana/tree/master/src/optimize (we don't use the webpack config files right now, but configure it at runtime instead (see https://github.com/elastic/kibana/blob/master/src/optimize/base_optimizer.js#L53). @tylersmalley is re-working some of that, but might be a bit longer term.) |
The opposite is actually true if you are using an editor with refactoring tools. When I move files around in Webstorm it automatically updates the relative paths in any modules importing that file. That's one reason I find these webpack aliases really annoying, they make a lot of nice tooling useless. The plugin question is a good one, unfortunately I don't have an answer to that. |
One of the benefits of the ES6 import syntax is that it enables static analysis. Our use of webpack aliases limits the benefit by making some import paths dynamic.
I don't know what all the ramifications of this change would be, but I wanted to float the idea of removing our use of aliases.
This can be split up into a number of incremental steps:
src/ui/public
plugins/${plugin.id}
imports with${plugin.directory}/public
require
expressions (is this worth the effort?require
won't gain the same static analysis benefits that import statements do, but it'll be necessary if we want to remove the aliases entirely)The text was updated successfully, but these errors were encountered: