-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Feature: Custom module resolution #2771
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
Comments
Could you please explain more about what you need and why? What specifically needs caching? Why does it need to be cached? |
Webpack and Babel are two examples of tools with customized resolution. I think https://github.com/benmosher/eslint-plugin-import#resolvers is decent proof of people wanting a variety of module resolvers. In my particular case, I want to build a Bazel integration for typescript-eslint. Bazel is a polyglot build tool for monorepos. There are two issues with module resolution: (a) The node_modules file layout is tricky to achieve and prevents Bazel from download packages lazily as required by build targets. I need to flexibility to resolve these modules in these various places. It's possible to write a bunch of symlinks/hardlinks but that's complex and not great for performance. So I've implemented Node.js Module.requireFilename, TS resolveModuleNames, Rollup resolveId, ESLint import/resolver, etc. One tool that doesn't allow custom resolution is TS ESLint. |
the import resolvers exist because OTOH we are built on top of TS - so we support exactly what TS supports out of the box. We've never had a usecase for anything more than that because 99.99999% of users don't create custom build scripts on top of the compiler API - Happy to accept a PR if you would like to add in a
interface ModuleResolver {
version: 1;
resolveModuleNames: ModuleResolver;
} Where Off topic:
How much time does this actually save? |
Sure, I get that. FWIW implementing the lower-level API described in #1442 would also meet my needs.
I'd have to think if node_modules stuff (multiple versions of a module name) could be handled.
For big monorepos (5,000+ files), a lot. The majority of a TS compile is type inference and checking. And not only does reusing .d.ts files save re-processing unchanged dependencies, it also allows short-circuited compile if the declaration signature does not change (like a change within a function).
Sounds good. |
In #3484 @uniqueiniquity has added a new API which enables you to really do "whatever you want".
The only requirement we place on it is that all files being linted (and their dependencies, for typechecking purposes) exist within the |
Bundlers often allow custom module resolution. Some build tools cache .d.ts files to save type checking work.
The TS Compiler API allows TS users to customize module resolution via CompilerHost#resolveModuleNames.
I'd like something similar to https://github.com/benmosher/eslint-plugin-import#resolvers to allow me to provide my own module resolver.
The text was updated successfully, but these errors were encountered: