-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Support for TypeScript files #5
Comments
Does the built-in Node.js |
Can you make a small reproduction? I did indeed notice the introduction of the error when I ported the code back two weeks ago, and checked that it’s thrown for a file such as |
Here's the reproduction https://github.com/ifiokjr/import-meta-resolve-ts
|
Thinking beyond my short-term needs, it probably makes sense to remove the extension restrictions. There are many file extensions which can legitimately be resolved. Would it make sense to remove the file extension restriction entirely? |
I don’t think so. Node has that map for some reason. But it doesn’t fail on this case. We also have that map, but it fails. The problem is not that there is a map. The problem is the divergence from Node |
Closes GH-5. Closes GH-6. Reviewed-by: Titus Wormer <[email protected]> Reviewed-by: Nicolò Ribaudo <[email protected]>
@wooorm I also expected it work, especially when using a TypeScript specific loader like ts-node. If node --loader=ts-node/esm index.ts |
This issue is solved. |
I still face the similar issue with the latest version. Lemme try to share a reproduction repo |
Here you go. https://github.com/thetutlage/imr-issue I see the issue is when the file has |
You are talking about loaders. Unrelated to this issue. More related to #10. If you are going to use experimental APIs (loaders), you can just as well use |
Thanks for explaining! Maybe, I had a wrong expectations from the package. I thought it is a drop-in polyfill for But, it is fine, if you think that this use case is out of scope of this package. I just wanted to highlight my use case :) |
For your second paragraph: take a look at the readme, the differences section, I guess loader can be added there in the CLI flags (if it isn't already) But that gives an indication of how giant the scope of Node is! I think by the point all those flags are implemented, you almost have a copy of Node! I think it would be cool to have some of these, particularly loaders, but that would probably be a new optional API (as CLI args have to be parsed, so it has to be Node that's executed from the CLI). And it would likely be a lot of work, which I'm not interested in currently doing |
Yup, makes sense! Also, for a while (until it is experimental), the resolve API will be a moving target, so it might be wiser to cherry pick which features are worth implementing. Anyways, thanks for your time :) |
Description
Is it possible to add builtin support for
.ts
,.mts
and.cts
files?I'm using this library and running tests on a TypeScript monorepo codebase. During development the "exports" field entrypoints redirect to TypeScript files via symlinks. This breaks with the following error.
I'm happy to open a PR and add the extensions, if you think it's a good idea.
import-meta-resolve/lib/get-format.js
Lines 14 to 22 in 937d3f3
The text was updated successfully, but these errors were encountered: