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

@marijn/buildtool

v1.0.0

Published

Tool for building TypeScript packages

Downloads

20,216

Readme

@marijn/buildtool

Utility to build TypeScript projects that conform to a given set of conventions quickly and cleanly. Exports functions that wrap the TypeScript compiler and Rollup to build or watch one or more projects in one go, performing a single shared build (so that files from different projects aren't compiled twice).

Assumes your projects are set up like this:

  • TypeScript files in an src directory, will be compiled to dist/index.js (ES module), dist/index.cjs (CommonJS), and dist/index.d.ts (TypeScript) files.

  • Tests, if any, under test, will be compiled in-place to .js files, which are ES modules.

  • Doc comments prefixed with triple slash /// syntax will be converted to /** JSDoc comments in the output, so that TypeScript tooling picks them up.

API

  • build(main: string | readonly string[], options?: BuildOptions = {}) → Promise
    Build the package with main entry point main, or the set of packages with the given entry point files. Output files will be written to the dist directory one level up from the entry file. Any TypeScript files in a test directory one level up from main files will be built in-place.

  • watch(mains: readonly string[], extra?: readonly string[] = [], options?: BuildOptions = {})
    Build the given packages, along with an optional set of extra files, and keep rebuilding them every time an input file changes.

interface BuildOptions

Options passed to build or watch.

  • sourceMap?: boolean
    Generate sourcemap when generating bundle. defaults to false

  • tsOptions?: any
    Additional compiler options to pass to TypeScript.

  • bundleName?: string
    Base filename to use for the output bundle and declaration files. Defaults to "index".

  • expandLink?: fn(anchor: string) → string | null
    When given, this is used to convert anchor links in the /// comments to full URLs.

  • outputPlugin?: fn(root: string) → Plugin | Promise
    Adds a Rollup output plugin to use.

  • cjsOutputPlugin?: fn(root: string) → Plugin
    Adds an output plugin to use only for CommonJS bundles.

  • pureTopCalls?: boolean
    When set to true, add a /*@__PURE__*/ comment before top level function calls, so that tree shakers will consider them pure. Note that this can break your code if it makes top-level function calls that have side effects.

  • onRebuildStart?: fn(packages: readonly string[])
    Function to call when starting a rebuild via watch, passing the root directories of the packages that are being built. The default is to just log the base names of the directories.

  • onRebuildEnd?: fn(packages: readonly string[])
    Function to call when finishing a rebuild.

Community

This is open source software released under an MIT license.

Development happens on GitHub. Use the bug tracker to report problems.