You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: I know I am mentioning a lot of different repositories from the pinojs organisation but the reason why I am opening this issue here is I believe I have tracked down the root cause of my problem to the realImport method. Feel free to redirect me somewhere else if this is not the appropriate place to have this discussion.
Problem description
I'm in a bit of a tough spot, trying to build a custom transport for pino. My project is built in Typescript and I use Ts-Node to run it. It handles transpilation + execution in memory so I have no generated js files.
The problem I am facing is that I am unable to create a custom transport in Typescript. I have detailed my investigation (with a reproducible example) in an issue in the pinojs repository, mentioning Typescript & v7 transports (apologies for the long texts):
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/sbeaulieu/workspace/test-datadog-pino/app/ts/customTransport.ts [...]
I do not get that error if my transport is a javascript file (which makes sense).
Proposed solution
I am wondering if it would be possible for real-require to be aware of the existence of ts-node (or any other transpiler) and import modules from typescript files successfully? I'm wondering if this solution could be adapted somehow: pinojs/pino#1243 (comment)
I want to point out that this issue does not happen in the scenario where typescript code is transpiled first and then the javascript code is executed. My use case is specific to using ts-node to transpile+run everything on the fly.
Also, does it make sense to approach this problem like that? Maybe the detection of ts-node should happen somewhere else ? I'm not sure.
As of now, I have no idea of a specific solution to my problem but I figured I would at least ask.
Cheers !
The text was updated successfully, but these errors were encountered:
@mcollina While I would absolutely love to send a PR (with tests !), I still have unanswered questions about how to approach the problem 😅 I have no idea how to do it or if it's even possible. I think I would need a bit of guidance first.
I believe we don't really have to touch real-require. I pushed a PR for thread-stream that should be able to help in this situation: pinojs/thread-stream#71
Hello there!
Note: I know I am mentioning a lot of different repositories from the
pinojs
organisation but the reason why I am opening this issue here is I believe I have tracked down the root cause of my problem to therealImport
method. Feel free to redirect me somewhere else if this is not the appropriate place to have this discussion.Problem description
I'm in a bit of a tough spot, trying to build a custom transport for pino. My project is built in Typescript and I use Ts-Node to run it. It handles transpilation + execution in memory so I have no generated js files.
The problem I am facing is that I am unable to create a custom transport in Typescript. I have detailed my investigation (with a reproducible example) in an issue in the pinojs repository, mentioning Typescript & v7 transports (apologies for the long texts):
I believe that the root cause is triggered in the
thread-stream
library, which usesreal-require
: https://github.com/pinojs/thread-stream/blob/22d484fa3b7a8125e0fec872b6fd6a5d8ed2049a/lib/worker.js#L21. This is why I decided to open the issue here.When using a custom transport written in typescript, I can see the following error if I put a breakpoint on the catch statement right after the call to realImport
I do not get that error if my transport is a javascript file (which makes sense).
Proposed solution
I am wondering if it would be possible for
real-require
to be aware of the existence ofts-node
(or any other transpiler) and import modules from typescript files successfully? I'm wondering if this solution could be adapted somehow: pinojs/pino#1243 (comment)I want to point out that this issue does not happen in the scenario where typescript code is transpiled first and then the javascript code is executed. My use case is specific to using ts-node to transpile+run everything on the fly.
Also, does it make sense to approach this problem like that? Maybe the detection of ts-node should happen somewhere else ? I'm not sure.
As of now, I have no idea of a specific solution to my problem but I figured I would at least ask.
Cheers !
The text was updated successfully, but these errors were encountered: