Skip to content

Conversation

@RReverser
Copy link

Use the new getCallSites API, which is both a bit simpler to use than V8 one, but also integrates correctly with Node.js source maps support.

For a demo, I renamed example.js to example.ts) and used tsx to run it.

Before:

> npx tsx --enable-source-maps example.ts
There are 4 handle(s) keeping the process running.

# Timeout
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import

# TCPSERVERWRAP
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import

# Timeout
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import

# TCPSERVERWRAP
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import

After:

> npx tsx --enable-source-maps example.ts
There are 4 handle(s) keeping the process running.

# Timeout
example.ts:6  - setInterval(() => {}, 1000)
example.ts:10 - startServer()

# TCPSERVERWRAP
example.ts:7  - server.listen(0)
example.ts:10 - startServer()

# Timeout
example.ts:6  - setInterval(() => {}, 1000)
example.ts:11 - startServer()

# TCPSERVERWRAP
example.ts:7  - server.listen(0)
example.ts:11 - startServer()

Use the new getCallSites API, which is both a bit simpler to use than V8 one, but also integrates correctly with Node.js source maps support.

For a demo, I renamed example.js to example.ts) and used [tsx](https://github.com/privatenumber/tsx) to run it.

Before:

```
> npx tsx --enable-source-maps example.ts
There are 4 handle(s) keeping the process running.

# Timeout
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import

# TCPSERVERWRAP
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import

# Timeout
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import

# TCPSERVERWRAP
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
example.ts:1 - import whyIsNodeRunning from 'why-is-node-running' // should be your first import
```

After:

```
> npx tsx --enable-source-maps example.ts
There are 4 handle(s) keeping the process running.

# Timeout
example.ts:6  - setInterval(() => {}, 1000)
example.ts:10 - startServer()

# TCPSERVERWRAP
example.ts:7  - server.listen(0)
example.ts:10 - startServer()

# Timeout
example.ts:6  - setInterval(() => {}, 1000)
example.ts:11 - startServer()

# TCPSERVERWRAP
example.ts:7  - server.listen(0)
example.ts:11 - startServer()
```
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

Successfully merging this pull request may close these issues.

1 participant