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

@build-script/heft-plugins

v0.0.9

Published

## typescript [task]

Downloads

1

Readme

heft plugin collection

typescript [task]

Build typescript project. This plugin not related to heft's internal typescript plugin, but it will read project in "config/typescript.json".

Options:

  • project: tsconfig location, relative to current project.json, override project field in `config/typescript.json``.
  • include/exclude/files: override tsconfig.json, not join!
  • extension: update import statements, add .mjs or .cjs to specifiers (also hook file write).
  • fast: if true, will modify compilerOptions, skip most check to speed up compile. (useful for multi-output)
  • compilerOptions: extends tsconfig.json's compilerOptions field.
    • module: only need when using multi-output. currently only support commonjs and esnext.
    • outDir: like module.
    • plugins: array, append to tsconfig.json's plugins field.

Plugin option:

| field | type | description | | ----------------- | ------- | --------------------------------- | | transform | string | module specifier to require() | | after | boolean | if true, add to after | | afterDeclarations | boolean | if true, add to afterDeclarations | | importName | string | defaults to default | | options | any | direct pass to callback function |

interface IMyTransformCallback<T = ts.SourceFile | ts.Bundle> {
	(context: ts.TransformationContext, program: ts.Program, options: any, ts: typeof ts): ts.Transformer<T>;
}

Note:

  1. If tsconfig.json file not found, and config/rig.json exists, rig package will be used.
    All path-like field (eg. rootDir/typeRoots/declarationDir) in heft.json will resolve to current package root.
    Official ts plugin will resolve inside rig package, this is different.
  2. include/exclude/files/outDir is relative to rootDir in final resolved compilerOptions, not package root or config/ folder.

examples:

{
	"typescript": {
		"taskPlugin": {
			"pluginName": "typescript",
			"pluginPackage": "@build-script/heft-plugins",
			"options": {
				"project": "src/tsconfig.json",
				// "include": [], "exclude": [], "files": []
				"extension": "mjs",
				"compilerOptions": {
					"module": "esnext",
					"outDir": "../lib/mjs",
					"plugins": [{ "transform": "xxx" }]
				}
			}
		}
	},
	"typescript-cjs": {
		"taskDependencies": ["typescript"],
		"taskPlugin": {
			"pluginName": "typescript",
			"pluginPackage": "@build-script/heft-plugins",
			"options": {
				"project": "src/tsconfig.json",
				// "include": [], "exclude": [], "files": []
				"fast": true,
				"extension": "cjs",
				"compilerOptions": {
					"module": "commonjs",
					"outDir": "../lib/cjs",
					"plugins": [{ "transform": "yyy" }]
				}
			}
		}
	}
}

create-index [task]

Collect all exports in all project files, and generate a __create_index.generated.ts beside tsconfig.json.

{
	"create-index": {
		"taskPlugin": {
			"pluginName": "create-index",
			"pluginPackage": "@build-script/heft-plugins",
			"options": {
				"project": "src/tsconfig.json"
				// or:
				// "include": [],
				// "exclude": [],
				// "files": []
			}
		}
	}
}

tip: if you use my typescript plugin, you can place __create_index.generated.ts in tsconfig exclude array.

shell [task]

Like heft's internal run-script-plugin, but allow run any program (eg. python).

Usage:

{
	"task-exec": {
		"taskDependencies": ["typescript"],
		"taskPlugin": {
			"pluginName": "shell",
			"pluginPackage": "@build-script/heft-plugins",
			"options": {
				"interpreter": "python3",
				"interpreterArgs": ["-B"],
				"script": "hello.py", // required
				"args": ["aaa"],
				"env": { "PYTHONUTF8": "1" },
				"inheritEnv": true,
				"workingDirectory": "tests"
			}
		}
	}
}

import-test [task]

Try import() and require() current package, to test if it's importable.

Usage:

{
	"task-test": {
		"taskDependencies": ["typescript"],
		"taskPlugin": {
			"pluginName": "import-test",
			"pluginPackage": "@build-script/heft-plugins"
		}
	}
}