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

ts-transformers-plantain

v1.10.0

Published

Some custom typescript transformers.

Downloads

27

Readme

ts-transformers-plantain

Some custom typescript transformers.

Dependency Status devDependency Status Build Status: Linux Build Status: Windows Github CI npm version Downloads gzip size type-coverage

install

yarn add ts-transformers-plantain

features

executedCodeTransformer

For every statements, prepend a console log of file name and line number, so when the statement is executed, the file name and line number will be logged in console.

for example:

[executed code]demo/index.tsx:1:1
[executed code]demo/index.tsx:2:3
[executed code]demo/index.tsx:3:3

logger can be disabled by executed-code:disable in comment. children logger can be disabled by executed-code:disable-children in comment.

codeTimeTransformer

For example:

[code time]demo/index.tsx:3:3: 1ms
[code time]demo/index.tsx:3:3: 1ms
[code time]demo/index.tsx:1:1: 16ms

logger can be disabled by code-time:disable in comment. children logger can be disabled by code-time:disable-children in comment.

codeTimeTransformerFactory({ threshold: 1000 }) can be used to log only when code time >= the threshold (>=1000ms for this example)

lastExecutingCodeTransformer

It can be used to record last executing code before exception, it's useful for environment without stacktrace or clear error message, eg, ExtendScript.

For example:

demo/index.tsx:16:3

logger can be disabled by last-executing-code:disable in comment. children logger can be disabled by last-executing-code:disable-children in comment

codeMemoryNodeJsTransformer

For example:

[code memory nodejs]demo/index.tsx:10:3: +0.02MB -> 2.02MB
[code memory nodejs]demo/index.tsx:10:3: +0.01MB -> 2.35MB
[code memory nodejs]demo/index.tsx:10:3: +0.01MB -> 2.62MB
[code memory nodejs]demo/index.tsx:10:3: +0.01MB -> 2.63MB
[code memory nodejs]demo/index.tsx:10:3: +0.01MB -> 2.64MB
[code memory nodejs]demo/index.tsx:10:3: +0.01MB -> 2.65MB
[code memory nodejs]demo/index.tsx:10:3: +0.01MB -> 2.67MB
[code memory nodejs]demo/index.tsx:10:3: +0.01MB -> 2.68MB
[code memory nodejs]demo/index.tsx:4:1: +0.71MB -> 2.71MB

logger can be disabled by code-memory-nodejs:disable in comment. children logger can be disabled by code-memory-nodejs:disable-children in comment.

codeMemoryBrowserTransformer

For example:

[code memory browser]demo/index.tsx:10:3: +0.02MB -> 2.02MB
[code memory browser]demo/index.tsx:10:3: +0.01MB -> 2.35MB
[code memory browser]demo/index.tsx:10:3: +0.01MB -> 2.62MB
[code memory browser]demo/index.tsx:10:3: +0.01MB -> 2.63MB
[code memory browser]demo/index.tsx:10:3: +0.01MB -> 2.64MB
[code memory browser]demo/index.tsx:10:3: +0.01MB -> 2.65MB
[code memory browser]demo/index.tsx:10:3: +0.01MB -> 2.67MB
[code memory browser]demo/index.tsx:10:3: +0.01MB -> 2.68MB
[code memory browser]demo/index.tsx:4:1: +0.71MB -> 2.71MB

logger can be disabled by code-memory-browser:disable in comment. children logger can be disabled by code-memory-browser:disable-children in comment.

executedCodeCoverageTransformer

This transformer will collect all executed code line number, _showCodeCoverage() will print the result in console, eg:

[executed code coverage]demo/index.tsx: 12 / 21 57.14% 27,31,32,34,39,42,45,48,55
[executed code coverage]total: 12 / 21 57.14%

jsxElementPositionTransformer

This transformer will add code position in data-_position for all jsx elements, for example:

React.createElement("button", { onClick: () => console.info(1), "data-_position": 'demo/index.tsx:55:1' });

safeOptimizationTransformer

This transformer will do some safe optiomizaiton, for example:

const a = 'aa'.length // -> const a = 2

usage

with ttypescript

"plugins": [
  {
    "transform": "ts-transformers-plantain",
    "import": "executedCodeTransformer",
    "type": "raw"
  },
]

with ts-loader

import { executedCodeTransformer } from "ts-transformers-plantain"

{
  test: /\.ts$/,
  loader: 'ts-loader',
  options: {
    transpileOnly: true,
    getCustomTransformers: (program) => ({
      before: [executedCodeTransformer]
    })
  }
}