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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ts-pack

v0.0.13

Published

A simple typescript packer that merges imports into a single file. Without all of the complexity

Readme

ts-pack

npm

Inspired by webpack, this is an attempt at duplicating the basic functionality of merging source files into one output file. The goal is to merge all source files without the overhead of the the module functions and the array containing the exports. File size and initial start-up time, especially for projects using many small modules, should benefit the most from using a packer like this.

This project uses typescript to parse files into an abstract syntax tree, which is then modified using tspoon to produce a single output with the variables from each module (exported and internal) renamed to coexist in a single scope. The output should then be run through a javascript minifier like uglify to produce the final result.

Usage

import * as tsPack from 'ts-pack';

let promise = tsPack.compileFile(
    inFile,         // the input file name, as string
    compilerOptions // (optional) the compiler options, as seen in a tsconfig.json file
);

// Alternatively
let promise = tsPack.compile(
    inFile,         // the input file name, as string
    contents,       // the contents of the input file name, as string
    compilerOptions // (optional) the compiler options, as seen in a tsconfig.json file
);

promise.then((output /* as string */) => {
    // Do something with the output
    // Maybe write it to a file or something
});

Command Line Interface

# Typical usage:
tspack <input> [-o <output>] [-p <path to tsconfig.json file>]
# When a tsconfig file is given, the compilerOptions from it are used to compile the input file

# As well as the usual:
tspack --help    # Open the help; -h also works
tspack --version # Output the current version, including the version of the included typescript

Additional tsconfig.json File Options

This project supports adding additional options into the tsconfig file passed to it.

{
    "compilerOptions": { ... },

    /**
     * This object contains all of the additional options that are used by this transpiler.
     */
    "packOptions": {
        /**
         * Typescript emits its special handler functions once per input file that uses them.
         * setting this to `true` will enable outputting a single custom version of the handlers
         * at the top of the file.
         *
         * @default false
         */
        "emitCustomHandlers": false,

        /**
         * A set of identifiers that should not be mangled. Instead, these identifiers are replaced by their
         * corresponding value. This is useful for using variables declared in another file, as well as swapping
         * out an entire imported library.
         *
         * @default {}
         */
        "alias": {
            "React": "React",
            "database/impl": "database/mongo",
            ...
        },

        /**
         * A set of raw text replacements to perform after the transiling process is complete.
         *
         * @default {}
         */
        "replace": {
            "searchFor": "replaceWith",
            "process.env.NODE_ENV": "production",
            ...
        },

        /**
         * Provides an easy way to wrap the entire output in a immediately-invoked function expression (IIFE).
         * This typically allows the minifier to do a better job.
         * This can be any string, where the substring '%output%' is replaced with the transpiled file contents.
         *
         * @default "%output%"
         */
        "wrapOutput": "(function(){%output%})();",

        /**
         * Provides a way to explicitly exclude imports from the transpilation process.
         * Any import found in this list will stay treated as a regular `require()`.
         *
         * @default []
         */
        "excludeImports": [
            "bluebird",
            "lodash",
            ...
        ]
    }
}

Some notable caveats

  1. It does not support importing via the require() function. Any call to require() will stay as such, and will not get merged. This may be changed at a later date.
  2. Currently, it only supports merging files that are not found in the node_modules folder. This is to avoid trying to merge native/C++ modules. This should not be an issue for the most part, but does mean that it is not possible to include node_modules libraries inline. I am working on a way to configure which libraries should be included or excluded, in much the same way as webpack. This will most likely involve adding additional fields to the tsconfig file.
  3. Caveat emptor. This is probably not production ready. Use at your own risk. I suggest thoroughly testing the output if you plan on using this in your own projects.