-
-
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 webpack 2 support #475
Conversation
} catch (e) { | ||
// Something has gone wrong (or we're in a test). Use our own bundled | ||
// enhanced-resolve. | ||
webpackRequire = require |
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.
Should never hit this in real use given the peer dependency. It's really just for tests.
|
||
var SyncNodeJsInputFileSystem = require('enhanced-resolve/lib/SyncNodeJsInputFileSystem') | ||
var syncFS = new SyncNodeJsInputFileSystem() | ||
return EnhancedResolve.create.sync(assign({}, resolveConfig, webpack2DefaultResolveConfig)) |
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... this plus the config defaults below are (I think) all it takes. Neat.
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.
I think the order of resolveConfig
and webpack2DefaultResolveConfig
should be reversed, so that the custom resolveConfig overrides the values on webpack2DefaultResolveConfig. Great job!
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.
Oops, you're right.
var resolver = new Resolver(syncFS) | ||
function createWebpack1ResolveSync(webpackRequire, resolveConfig, plugins) { | ||
var Resolver = webpackRequire('enhanced-resolve/lib/Resolver') | ||
var SyncNodeJsInputFileSystem = webpackRequire('enhanced-resolve/lib/SyncNodeJsInputFileSystem') |
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.
https://github.com/webpack/enhanced-resolve/blob/v0.9.1/lib/SyncNodeJsInputFileSystem.js
This file system object has no caching attached to it AFAICT, so the penalty for constructing it on-the-fly should be trivial.
This diff looks worse than it is. It really just does:
|
@taion thanks for the detailed breakdown! |
Trying taion's branch on a small webpack2 project, after removing the $ git clone https://github.com/taion/eslint-plugin-import
...
$ rm -rf node_modules/eslint-import-resolver-webpack
$ ln -s ../eslint-plugin-import/resolvers/webpack node_modules/eslint-import-resolver-webpack
$ $(npm bin)/eslint src | grep no-unresolved | wc -l
15
$ cd eslint-plugin-import && git checkout webpack-2 && cd ..
Branch webpack-2 set up to track remote branch webpack-2 from origin.
Switched to a new branch 'webpack-2'
$ $(npm bin)/eslint src | grep no-unresolved | wc -l
0 |
@Kovensky if I'm reading this right, you lost 15 is that.. good? i.e. were there 15 wrong reports that were fixed, or are 15 correct reports now missing? |
@benmosher there were 15 wrong reports that were fixed. The wrong reports were happening even for relative imports (!) or things that could be found inside a |
Merged and published as v0.5.0 to npm. @taion, thanks again! |
Closes #265
Fixed some lint failures in the plugin along the way.
I don't have test coverage because it seems like it'd be a bunch of additional work to scaffold it into place, because it would require tooling to install dependencies for the test fixtures.
I tested manually and it works on my project, though.