Skip to content
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

Expose module redirection helper for use in ESM hooks #31

Open
cspotcode opened this issue Oct 10, 2021 · 0 comments
Open

Expose module redirection helper for use in ESM hooks #31

cspotcode opened this issue Oct 10, 2021 · 0 comments

Comments

@cspotcode
Copy link
Owner

cspotcode commented Oct 10, 2021

Enhancement to redirection feature added in #23 and #30
We can install a redirector for require() by patching Module._resolveFilename but we can't do that for ESM loader hooks. If a loader hook wants to redirect, it needs to call out to us directly.

Consumers like ts-node who implement their own loader hooks may want to do the same redirection. We can expose a function they can use to do this redirection. Perhaps it can even support our redirection callback? Perhaps not since ESM loaders will eventually run in a separate thread.

Should it be implemented as a loader itself? To support chaining? Probably not since it would be more complex, and most likely the only consumer of this feature is going to be ts-node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant