import-js/eslint-plugin-import

Option to preserve symlinks in `no-unresolved` for monorepos

Open

#1,706 opened on Mar 29, 2020

View on GitHub
 (4 comments) (10 reactions) (0 assignees)JavaScript (4,946 stars) (1,540 forks)batch import
help wanted

Description

I'm currently converting my codebase to a monorepo, and I've stumbled across an issue with no-unresolved. Even though the sibling package I reference is symlinked into node_modules, it doesn't actually see it.

To skirt this, I've tried:

  • The no-unresolved ignore option, but this doesn't actually ensure the sibling is required and symlinked in place.
  • The resolver-node, but like above, this doesn't actually ensure the package is actually symlinked in node_modules.
  • The resolver-webpack, but even though I specifically preserve symlinks in my config, you override it. Also, using this resolver only helps subprojects using webpack.
  • The third-party resolver-lerna, but doing so requires I sacrifice detection of absolute imports (which I currently use resolver-node for, but which I could use resolver-webpack for... in subprojects that use webpack).

As you can see, all of these potential solutions are just patches. If there's something I missed, please point the way. But given the prevalence of monorepo solutions—all of which rely on symlinks—I think it's safe to say the best option is to solve for the symlink problem itself. There's been quite a few issues raised on this topic.

Solutions I see:

  • A no-unresolved option that preserves symlinks.
  • A global option for import/preserve-symlinks that preserves symlinks.

Anyway, thanks for your time!

Contributor guide