-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add plugins support for webpack resolver #320
Conversation
I think plugins could be interesting, but I'd like to avoid having to duplicate config. If it's matching what is configured for Webpack already, I'm hesitant to do anything that doesn't use the configured plugins, without explicit (re-)reference in the ESLint config. I'm not sure I understand exactly what you are proposing, though. If the intent is to support Webpack resolver plugins, I would like someone to spend some time to evaluate using sokra's enhanced-resolve directly, first. I'm assuming this is doable, and that it would reduce the Webpack resolver to something much more like the Node resolver. Would also be more future-proof, presumably; assuming the API doesn't change much, it could even declare enhanced-resolve as a peer dependency and use whatever version the installed Webpack comes with. Does that make sense? Or have I misunderstood your intent? |
@benmosher I saw your enhanced-resolver tracking issue and it's going to be awesome, when it lands! I wanted to propose some temporary hacky solution, that would allow users to use plugins today(even though the duplication is a real issue here). In my case, I had to rewrite the source path after the alias was resolved( I thought it might be a relatively common case for other users, too. Maybe I'm wrong about it. Anyway, this PR is just a proposal of a temporary solution for the problem. I'll totally understand, if you decide to reject it. Although maybe there's something you or someone else can figure out about the duplication problem, before the support for |
Fair enough. Makes sense as a use case. I want to take another look at leveraging enhanced-resolve before merging this, though. If it's not a huge deal to get first-party support for the actual plugins, I want to start there. Will try to take a look this week (or happy to hear from anyone else that is willing to take a stab at it). |
Just pushed This is what I used as a guide: https://github.com/webpack/webpack/blob/v1.13.0/lib/WebpackOptionsApply.js#L321 It's not obvious how |
Closing for now. We can re-open or open a new one, as needed. |
In my project, i use webpack plugin, that modifies path. I'm sure, that so do many other webpack users. For now I have to fork the webpack resolver and apply the plugins inside the
resolve
function.This PR offers an extension point for users to apply plugins. I don't think it's possible at this point to apply plugins automatically, so user will have to do it manually for now. Here's how that would work:
in
webpack.config.js
in
.eslintrc.js
The user is expected to mutate
source
and/orpath
object.Each plugin receives 2 arguments:
source
- is the path to the imported file so far(after resolvingalias
and previous plugins in array)info
is an object with two properties:originalSource
- is the original path to file, as seen in theimport/require
statement itselfrawSource
- is the same as originalSource, but with loader stripped outThere should be a way for the user to share the plugin options(like
resourceRegExp
and replacer function) between the eslint in webpack configs, but I haven't figured out the best way to do it yet.Feedback is welcomed!
TODO: