-
-
Notifications
You must be signed in to change notification settings - Fork 432
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
How would one transform emitted .d.ts files? #1222
Comments
It's the first time I've heard of this use case.... Does tsc support this directly? |
Yeah, it must do. If you check the |
Just to expand a little on the use-case: I have a code-base which supports both Deno and Node. Deno requires import paths to end in So, to meet the needs of both platforms, my Deno code lies in So, all in all, I'd say this is a perfectly valid use-case :-) |
Interesting! Where does webpack fit into this? |
I use Webpack to transpile the TypeScript (I have |
So this is a web app then? Using webpack implies node. How does Deno fit in? |
It's not a web-app, it's a library. Deno does not need TypeScript compilation, so you directly import the source code of the library as a URL. |
Very interesting - so you're using webpack but you're not building a web app? Sorry I'm a little puzzled... I'm not quite following why you aren't directly using tsc or Deno... wouldn't it be easier? |
You don't need to use Webpack for web apps. I am using Webpack because:
Anyway, are we any closer to fixing the issue? |
I appreciate it's an issue for you. However, this does seem to be a fairly niche use case. That's not to say it's not worth catering for. If you'd like to start work on a prospective PR I'll certainly take a look. Don't worry about tests initially. Let's see where this goes. |
I'm not sure if this is related, but I pretty much had to drop ts-loader and use tsc directly because of a |
Ehh. After some thought, I'm going to have to disagree. This is the cleanest solution I can find, that allows Deno and Node source code in the same repository, instead of maintaining separate branches. I need to support both Deno and Node, as I use this library in both those environments. Simply put, this is somewhat of an X/Y solution. I can appreciate that Deno's style of imports is somewhat unconventional, but it should definitely be catered for. As for the PR: I don't have any experience with this code-base, but I can give it a go. |
Have a go! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The ts-loader readme gives the following type signature for getCustomTransformers:
From a little Googling I found there is a third option: afterDeclarations. If you want to transform emitted d.ts files (which I understand is the aim here) it is afterDeclarations you need to use. I created a small repository based on the CustomTransformers test case. The test only covers the 'before' case, which is probably the most common case to use. I added a transformer for afterDeclarations. The transformation it applies is pointless but it proves that it works as expected. You can see the repository here: https://github.com/appzuka/ts-loader-afterDeclarations-transformer.git The following repository shows how to transform imports in d.ts files, which may be close to your requirement: https://github.com/longlho/ts-transform-json If you are already using afterDeclarations and it is not working for you perhaps you could publish a repository with a minimal test case showing what is not working. |
@resynth1943 did that fix the issue for you? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. Please reopen if you'd like to work on this further. |
Expected Behaviour
The emitted .d.ts files go through the transformers listed within
getCustomTransformers
.Actual Behaviour
They don't.
Steps to Reproduce the Problem
getCustomTransformers
option.Location of a Minimal Repository that Demonstrates the Issue.
Don't have one right now. If this is requested, I'll make one.
Is this intended behaviour?
Would appreciate any help you can give me if it's not.
The text was updated successfully, but these errors were encountered: