Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
Last active April 16, 2021 05:36
Show Gist options
  • Save donmccurdy/81b9bf0ab37a37ed6a676455b14efa71 to your computer and use it in GitHub Desktop.
Save donmccurdy/81b9bf0ab37a37ed6a676455b14efa71 to your computer and use it in GitHub Desktop.
A minimal set of tools for creating a JavaScript or TypeScript library.

These are the build tools I prefer to use when starting a new JavaScript or TypeScript library. Most libraries I write run both in the browser and in node.js. Each project needs to be lightweight, and to minimize maintenance. And I need build chains for those libraries to pretty much "just work". That last part has become more important over time, as I've maintained more libraries and generally had less time to deal with dependencies and build system issues. For web applications, as opposed to libraries consumed in other projects, these choices may or may not make sense. These are opinionated choices, and will probably change over time.

Almost always:

  • microbundle: Zero-config Rollup bundler, with optional TypeScript support
  • tape: Test runner
  • tap-spec: Clean test output

Occasionally:

package.json:

  "source": "src/index.js",
  "main": "dist/<package>.js",
  "module": "dist/<package>.module.js",
  "unpkg": "dist/<package>.umd.js",
  "types": "dist/<package>.d.ts",
  "scripts": {
    "dist": "microbundle",
    "dev": "microbundle watch",
    "test": "tape test/*.test.js | tap-spec",
    "preversion": "npm run dist && npm test && git add -A dist",
    "postversion": "git push && git push --tags && npm publish"
  },
@donmccurdy
Copy link
Author

Created a GitHub repository template, along these lines: https://github.com/donmccurdy/typescript-library-template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment