question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose configuration hook for custom module resolution

See original GitHub issue

Following on from #6012 and #5039, it’d be nice to have the ability to add TypeScript to projects with heterogeneous module resolution/packaging systems and have typechecking work.

The paths and baseUrl configuration options get us a long way, but they don’t deal well with module loaders that are less widely used, frequently changing, or that allow for complex module resolution rules. Letting the user entirely outsource all module resolution concerns using the configuration would allow type checking to work regardless of the user’s preference of npm, bower, requirejs, browserify, jspm, webpack, etc.

A simple approach might be to have a tsconfig option for a parametrized command line invocation (similar to npm scripts) that is able to resolve modules. Each package manager can distribute a tool that implements module resolution according to its own needs, which the users can install and point to in their tsconfig.json.

Exactly how extensive the API needs to be is up for debate. It could be something as simple as a function that maps requested module names to file system paths, or a more abstract implementation of something like System from here, which could open up more interesting use cases (e.g. “virtual” modules built using code generation, or F# style type providers).

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:75
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

26reactions
arcaniscommented, Oct 21, 2018

Just saw this issue - I’d be quite interested as well to have such a hook. Would allow me to start making experiments to integrate PnP with Typescript 🙂

13reactions
muzuigetcommented, May 27, 2021

Year 2021, still looking forward on this.

This document https://www.typescriptlang.org/docs/handbook/module-resolution.html#module-resolution-strategies now is some complex, why not just give a hook function for user to do the resolve.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module Resolution - webpack
A resolver is a library which helps in locating a module by its absolute path. A module can be required as a dependency...
Read more >
Module Author Guide · Nuxt Advanced
A powerful configuration and hooks system makes it possible to customize almost every aspect of Nuxt ... Nuxt exposes a powerful API called...
Read more >
Documentation - Module Resolution - TypeScript
Setting baseUrl informs the compiler where to find modules. All module imports with non-relative names are assumed to be relative to the baseUrl...
Read more >
Configuring Vitest
To configure vitest itself, add test property in your Vite config. ... Define custom aliases when running inside tests.
Read more >
ts-node - npm
This is accomplished by hooking node's module loading APIs, ... Resolve config relative to the current directory instead of the directory of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found