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

tsbunch

v0.4.25

Published

A VERY basic TypeScript bundler that doesn't compile to JS

Downloads

75

Readme

npmnpm

📦 TSBunch

A VERY simple bundler for TypeScript files that doesn't transpile them to JS (Multiple .ts -> Single .ts)

Introduction

There are plenty of TypeScript bundlers out there but none that don't also transpile TypeScript into regular JS. This bundler seeks to rectify that by providing a very simple way to concatenate multiple TypeScript modules into one TypeScript file.

The magic behind this bundler is in utilizing TypeScript's namespace feature rather than using the traditional bundler loading pattern.

The impetus behind this was to allow TypeScript projects composed of multiple modules to be uploaded to CodinGame (which only accepts single flat files) either by hand or by using the CodinGame Sync App WITHOUT transpiling those TypeScript files to JavaScript in the process.

Usage

Installing:

$ npm install --save-dev tsbunch

tsbunch(entryFilePath, [outputFilePath], [declarationsFile(s)])

  • entryFilePath: String file path of the bundle entry file
  • outputFilePath: (Optional) Name of output file, will default to out.ts
  • declarationsFile(s): (Optional) Single or array of string file paths to files which will placed at the top of the output file 'outside' of the bundle.

Create a file with the following in it:

const tsbunch = require('tsbunch');
tsbunch('path/to/entryFile.ts', 'path/to/outputFile.ts', 'path/to/declarationsFile.d.ts');

Finally run that file with:

$ node file.js

Caveats

This bundler is using string matching rather than AST's so doesn't fully support the import/export spec:

Supports:
  • import defaultExport from "module-name";
  • import * as name from "module-name";
  • import { export1 } from "module-name";
  • import { export1 as alias1 } from "module-name";
  • import { export1 , export2 } from "module-name";
  • import { export1 , export2 as alias2 , [...] } from "module-name";
  • import defaultExport, { export1 [ , [...] ] } from "module-name";
  • import defaultExport, * as name from "module-name";
  • export let name1, name2, …, nameN; // also var, const
  • export let name1 = …, name2 = …, …, nameN; // also var, const
  • export function functionName(){...}
  • export class ClassName {...}
  • export const { name1, name2: bar } = o;
  • export default expression;
Has Partial Support

The following examples will have their function/class names changed. It's recommended to save them as constants and then export the constants rather than to directly default export them:

  • export default function (…) { … } // also function*
  • export default function name1(…) { … } // also function*
  • export default class { … }
  • export default class name1{ … }
Will Not Work:
  • import { foo , bar } from "module-name/path/to/specific/un-exported/file";
  • import "module-name";
  • var promise = import("module-name");
  • export { name1, name2, …, nameN };
  • export { name1 as default, … };
  • export { variable1 as name1, variable2 as name2, …, nameN };
  • export * from …; // does not set the default export
  • export * as name1 from …;
  • export { name1, name2, …, nameN } from …;
  • export { import1 as name1, import2 as name2, …, nameN } from …;
  • export { default } from …;

TSBunch will also not resolve any circular dependencies. If compilation is taking unusually long, it's recommended to check for these.

Scripts

  • npm run build: compiles TS files
  • npm run test: runs all tests
  • npm run testWatch: runs all tests in watch mode

Todo/Future Improvements

  • Use tsconfig.json for file import

Notes

Credits

Available for Hire

I'm available for freelance, contracts, and consulting both remotely and in the Hudson Valley, NY (USA) area. Some more about me and what I can do for you.

Feel free to drop me a message at:

hi [a+] zweisolutions {●} com

License

MIT