npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rbxts-transform-debug

v2.2.0

Published

Transformer for debugging things in roblox-ts

Downloads

264

Readme

rbxts-transform-debug

A debugging transformer for roblox-ts. Contains helper functions for debugging roblox-ts code with debug information attached.

How it works

Say we have this example code:

import { $dbg, $print } from "rbxts-transform-debug";

export function makeHello(name: string) {
	return $dbg(`Hello from ${name}!`);
}

const x = 42;
$dbg(10 > 20);
$dbg(x);
$print(makeHello("Vorlias"))

The emit would be:

local function makeHello(name)
	return (function(value)
		print("[src/shared/module.ts:4] `Hello from ${name}!` =", value)
		return value
	end)("Hello from " .. name .. "!")
end
local x = 42
print("[src/shared/module.ts:8] 10 > 20 =", 10 > 20)
print("[src/shared/module.ts:9] x =", x)
print("[src/shared/module.ts:10]", makeHello("Vorlias"))

If this code was ran, our output would give:

[src/shared/module.ts:8] 10 > 20 = false
[src/shared/module.ts:9] x = 42
[src/shared/module.ts:2] `Hello from ${name}!` = Hello from Vorlias!
[src/shared/module.ts:10] Hello from Vorlias!

Macros

$dbg

Based on rust's dbg! macro.

Will print out the expression + it's value prefixed by a file name + line number. If it is a complex expression (e.g. a right hand side expression) this will be done via an IIFE, otherwise a regular print statement.

Simple:

const x = 10;
$dbg(x);
print("[source.ts:2] x =", 10)

IIFE:

function test() {
	return 10;
}
const value = $dbg(test());
local function test() 
	return 10
end
local value = (function(value)
	print("[source.ts:4] test() =", value)
	return value
end)(test())

$git

Generates an object with git information. If you pass property names to it, it will filter out the object's properties.

  • .ISODate - An ISO-8601 formatted date of the date and time of the commit when the code was compiled

  • .Timestamp - A unix timestamp of the commit when the code was compiled

  • .LatestTag - The latest tag being used (e.g. v1.1.0) when this code was compiled

  • .CommitHash - The full commit hash (e.g. 342db0bd208658f52a8464ace298765c04a3a78b) this code was compiled on

  • .Commit - The commit hash in seven characters (e.g. 342db0b) this code was compiled on

  • .Branch - The name of the branch this was compiled on

$compileTime

Emits an expression representing the current compile time, if no arguments are specified - this is the unix timestamp. Accepts:

  • "DateTime" - Will emit a DateTime object representing the compile time
  • "UnixTimestamp" - Will emit the compile time as a unix timestamp (default)
  • "UnixTimestampMillis" - Will emit the compile time as unix timestamp in milliseconds
  • "ISO-8601" - Will emit the compile time as an ISO-8601 compatible date/time string

$print

Same as print, but will prefix the print with the file name + line number. Also controlled by the below settings as to whether or not it's emitted.

$print("Hello, World!");
print("[source.ts:1]", "Hello, World!");

$warn

Same as warn, but will prefix the warning with the file name + line number. Also controlled by the below settings. Also controlled by the below settings as to whether or not it's emitted.

$warn("Hello, World!");
warn("[source.ts:1]", "Hello, World!");

Configuration

environmentRequires [Object]

An object of environment variable names mapped to either the required value, or true (if you want to only chekc that it's set)

The purpose of this is to conditionally render the $dbg calls as the debug statements only if environment variables match your set conditions.

enabled [Boolean] (Defaults to true)

Whether or not this transformer actually emits the $dbg as debug statements at all. If false, it will just return the expressions themselves.