twopluszero / next-images

Import images in Next.js (supports jpg, jpeg, svg, png and gif images)
MIT License
948 stars 67 forks source link

Resolve loaders relative to next-images #18

Closed elliottsj closed 5 years ago

elliottsj commented 5 years ago

This fixes an issue where url-loader cannot be resolved when using strict package managers such as pnpm or yarn pnp:

Module not found: Can't resolve 'url-loader' in '/path/to/project'

Most users don't notice this because npm and yarn by default hoist transitive dependencies to the root, so url-loader can be resolved from the app's webpack config:

node_modules/
  next-images/
  url-loader/
  file-loader/

However, more strict package managers do not perform hoisting:

node_modules/
  next-images/
    node_modules/
      url-loader/
      file-loader/

So 'url-loader' cannot be resolved from the root.