Eslint-plugin-import: [webpack-resolver] Support Webpack 2.2

Created on 15 Dec 2016  ·  12Comments  ·  Source: benmosher/eslint-plugin-import

Webpack v2.2.0-rc.0 now depends on enhanced-resolve@^3.0.0.

After upgrade webpack (using eslint-import-resolver-webpack), all rules fail with this message:

Resolve error: Cannot find module 'enhanced-resolve/lib/SyncNodeJsInputFileSystem' from '[...]/node_modules/webpack/lib'

Most helpful comment

@isychev what does your .eslintrc look like? I have eslint-import-resolver-webpack v0.8.3 and I'm still having resolve issues.

All 12 comments

I have the same issue. Tried installing enhanced-resolve, but didn't help.

Just merged #689, I'll go ahead and publish it.

Published current Webpack resolver as v0.8.0.

It's not clear to me whether the change in #689 will necessarily have fixed it--just don't know anything about v3 of enhanced-resolve--so please let me know if it works 😅

It's not fixed it for me. Using 0.8.0 with both versions of Webpack 2.1.0-beta.28 and 2.2.0-rc.0 I get different results.

With 2.1.0-beta.28: No issues.

With 2.2.0-rc.0:

11:17  error  Unable to resolve path to module 'vue'         import/no-unresolved
12:23  error  Unable to resolve path to module 'vue-router'  import/no-unresolved
13:21  error  Unable to resolve path to module 'vue-i18n'    import/no-unresolved

The code in question:

// Enable HMR
if (module.hot) module.hot.accept()

// Using Webpack's DefinePlugin we can use global constants such as devMode to have some code (e.g. logging) stay in our codebase but be stripped out during production builds
if (DEVMODE) console.log('Dev mode active')

// Webpack entrypoint for global styles
import './global-styles/index'

// Vue initialisation
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueI18n from 'vue-i18n'
Vue.use(VueRouter)
Vue.use(VueI18n)

import routes from './routes'
const router = new VueRouter({
  mode: 'history',
  routes
})

Vue.config.lang = 'en'
Vue.config.fallbackLang = 'en'
import locales from '../locales/index'
for (const lang of Object.keys(locales)) Vue.locale(lang, locales[lang])

import Base from './Base'
new Vue({ // eslint-disable-line no-new
  router,
  el: document.querySelector('.js-app'),
  render: h => h(Base)
})

It's partially fixed.

689 fixed an error that it was applying the logic for webpack v1 to webpack v2 configs. So there's no more Cannot find module 'enhanced-resolve/lib/SyncNodeJsInputFileSystem' error.

Now using Webpack v2.2.0-rc.0 we're having a problem specific with rule import/no-unresolved. I realized that _every_ external (from node_modules, like importing react, lodash etc.) is unable to resolve. Own modules are being resolved normally.

For me, webpack 2.1.0-beta.28 has no issues, with v2.2.0-rc.0:

The errors

import/no-unresolved
import/no-extraneous-dependencies

are being thrown for any path using an alias via resolve.alias

Other errors for the following lines:

'exports?outdatedBrowser!outdated-browser/outdatedbrowser/outdatedbrowser.js' should be listed in the project's dependencies... import/no-extraneous-dependencies
'exports?outdatedBrowser!outdated-browser/outdatedbrowser/outdatedbrowser.js' import/no-unresolved
'!!style!css!outdated-browser/outdatedbrowser/outdatedbrowser.css' import/no-unresolved

outdated-browser is in my node_modules folder

I'm thinking that's a enhanced-resolve issue. It fails to read the content of package.json for external packages and then it crashes. But here it fails silently as “unable to resolve...”.

I did some console.log in enhanced-resolve code and found this:

descriptionFilePath: '[...]/node_modules/react-router/package.json',
descriptionFileData: undefined,
descriptionFileRoot: '[...]/node_modules/react-router',

That descriptionFileData really should be filled.

I've just submitted https://github.com/webpack/enhanced-resolve/pull/53. I can confirm that it fixes this issue together with #689.

enhanced-resolve v3.0.2 with the fix released. Just tested here.

Everything should work now with dependencies up to date.

Webpack 2 is still not working for me and all absolute resolves are marked as Unable to resolve path to module.

My resolve config looks like this:

resolve: {
    modules: [
      path.join(__dirname, 'src'),
      path.join(__dirname, 'styles'),
      'node_modules'
    ]
  }

Am I missing something?

I solved the problem when upgraded the eslint-import-resolver-webpack to ^0.8.1

@isychev what does your .eslintrc look like? I have eslint-import-resolver-webpack v0.8.3 and I'm still having resolve issues.

Was this page helpful?
0 / 5 - 0 ratings