• Stars
    star
    4,348
  • Rank 9,461 (Top 0.2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Starter kit with zero-config for building a library in TypeScript, featuring RollupJS, Jest, Prettier, TSLint, Semantic Release, and more!

TypeScript library starter

styled with prettier Greenkeeper badge Travis Coveralls Dev Dependencies Donate

A starter project that makes creating a TypeScript library extremely easy.

Usage

git clone https://github.com/alexjoverm/typescript-library-starter.git YOURFOLDERNAME
cd YOURFOLDERNAME

# Run npm install and write your library name when asked. That's all!
npm install

Start coding! package.json and entry files are already set up for you, so don't worry about linking to your main file, typings, etc. Just keep those files with the same name.

Features

Importing library

You can import the generated bundle to use the whole library generated by this starter:

import myLib from 'mylib'

Additionally, you can import the transpiled modules from dist/lib in case you have a modular library:

import something from 'mylib/dist/lib/something'

NPM scripts

  • npm t: Run test suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't πŸ˜‰)

Excluding peerDependencies

On library development, one might want to set some peer dependencies, and thus remove those from the final bundle. You can see in Rollup docs how to do that.

Good news: the setup is here for you, you must only include the dependency name in external property within rollup.config.js. For example, if you want to exclude lodash, just write there external: ['lodash'].

Automatic releases

Prerequisites: you need to create/login accounts and add your project to:

Prerequisite for Windows: Semantic-release uses node-gyp so you will need to install Microsoft's windows-build-tools using this command:

npm install --global --production windows-build-tools

Setup steps

Follow the console instructions to install semantic release and run it (answer NO to "Do you want a .travis.yml file with semantic-release setup?").

Note: make sure you've setup repository.url in your package.json file

npm install -g semantic-release-cli
semantic-release-cli setup
# IMPORTANT!! Answer NO to "Do you want a `.travis.yml` file with semantic-release setup?" question. It is already prepared for you :P

From now on, you'll need to use npm run commit, which is a convenient way to create conventional commits.

Automatic releases are possible thanks to semantic release, which publishes your code automatically on github and npm, plus generates automatically a changelog. This setup is highly influenced by Kent C. Dodds course on egghead.io

Git Hooks

There is already set a precommit hook for formatting your code with Prettier πŸ’…

By default, there are two disabled git hooks. They're set up when you run the npm run semantic-release-prepare script. They make sure:

This makes more sense in combination with automatic releases

FAQ

Array.prototype.from, Promise, Map... is undefined?

TypeScript or Babel only provides down-emits on syntactical features (class, let, async/await...), but not on functional features (Array.prototype.find, Set, Promise...), . For that, you need Polyfills, such as core-js or babel-polyfill (which extends core-js).

For a library, core-js plays very nicely, since you can import just the polyfills you need:

import "core-js/fn/array/find"
import "core-js/fn/string/includes"
import "core-js/fn/promise"
...

What is npm install doing on first run?

It runs the script tools/init which sets up everything for you. In short, it:

  • Configures RollupJS for the build, which creates the bundles
  • Configures package.json (typings file, main file, etc)
  • Renames main src and test files

What if I don't want git-hooks, automatic releases or semantic-release?

Then you may want to:

  • Remove commitmsg, postinstall scripts from package.json. That will not use those git hooks to make sure you make a conventional commit
  • Remove npm run semantic-release from .travis.yml

What if I don't want to use coveralls or report my coverage?

Remove npm run report-coverage from .travis.yml

Resources

Projects using typescript-library-starter

Here are some projects that use typescript-library-starter:

Credits

Made with ❀️ by @alexjoverm and all these wonderful contributors (emoji key):


Ciro

πŸ’» πŸ”§

Marius Schulz

πŸ“–

Alexander Odell

πŸ“–

Ryan Ham

πŸ’»

Chi

πŸ’» πŸ”§ πŸ“–

Matt Mazzola

πŸ’» πŸ”§

Sergii Lischuk

πŸ’»

Steve Lee

πŸ”§

Flavio Corpa

πŸ’»

Dom

πŸ”§

Alex Coles

πŸ“–

David Khourshid

πŸ”§

AarΓ³n GarcΓ­a HervΓ‘s

πŸ“–

Jonathan Hart

πŸ’»

Sanjiv Lobo

πŸ“–

Stefan Aleksovski

πŸ’»

dev.peerapong

πŸ’»

Aaron Groome

πŸ“–

Aaron Reisman

πŸ’»

kid-sk

πŸ“–

Andrea Gottardi

πŸ“–

Yogendra Sharma

πŸ“–

Rayan Salhab

πŸ’»

This project follows the all-contributors specification. Contributions of any kind are welcome!

More Repositories

1

v-lazy-image

Lazy load images using Intersection Observer, apply progressive rendering and css animations.
JavaScript
978
star
2

v-runtime-template

Vue component for compiling templates on the fly using a v-html like API
JavaScript
605
star
3

vue-testing-series

JavaScript
158
star
4

Vue-Typescript-Starter

TypeScript starter project based on Vue-cli webpack template
JavaScript
62
star
5

Egghead-Vuex-TypeScript

JavaScript
48
star
6

Egghead-Typescript-Vuejs-apps

JavaScript
42
star
7

vue-pwa

Vue
20
star
8

narutodose

Vue
17
star
9

vue-styleguidist-example

Example on how to use vue-styleguidist with minimal setup
Vue
14
star
10

alexjover.com

Vue
12
star
11

interviews

Code challenges for interviews I made
JavaScript
11
star
12

Faelo-food-order-app-MEAN.js-

Full-Stack food order system made in MEAN.js
JavaScript
10
star
13

storyblok-nuxt3

Vue
10
star
14

react-native-gps-logger

GPS Logger that runs in background using React Native
Java
9
star
15

links

Links and Resources to keep organized my personal interests
7
star
16

nuxt3-storyblok-ecommerce

JavaScript
6
star
17

blog

My personal blog (src)
CSS
6
star
18

Egghead-Vue-Async-Components

Example that shows how to create async components in Vue
JavaScript
5
star
19

reactive-grocery-app-slides

https://alexjoverm.github.io/reactive-grocery-app-slides/
HTML
5
star
20

javascript-algorithms-es6

A set of algorithms written in ES6+
JavaScript
4
star
21

testing-vue-book-ru

4
star
22

MyWeather

Winner multidevice app made in FireMonkey for the 1st app challenge of Embarcadero Technologies
Pascal
4
star
23

egghead-lessons

JavaScript
4
star
24

MP3PlayerJS

Web-based MP3 player made using MVC pattern in vanilla js (plain javascript)
JavaScript
3
star
25

reactive-grocery-app

TypeScript
3
star
26

angular-bulma

Angular 2 UI component library on top of Bulma css framework
TypeScript
3
star
27

frontend-libs-medley

Vite best-practise example on creating a frontend library for Vue, React and Svelte
JavaScript
3
star
28

GaTe

Strategy and platform 2.5D videogame made in C++ and SFML
C++
2
star
29

gridsome-blog-example

An example on using Gridsome to create a blog
Vue
2
star
30

testing-vue-book-es

2
star
31

Footle

Reservation system for busy people
TypeScript
2
star
32

TreeXplorer

Web-based file explorer made in plain Javascript and. Uses MVC, Browserify and CommonJS for structure.
JavaScript
2
star
33

strapi-nuxt

JavaScript
1
star
34

awesome-resources

Personal list of curated resources
1
star
35

vue-simple-starter

Simple Vue.js starter using Poi
JavaScript
1
star
36

RelaxCoach

Simple project which is a prototype for a breathing techniques & heart-rate measurement applications, made with AngularJS
CSS
1
star
37

frontcast

A FrontEnd screencast platform
Vue
1
star
38

Fullstack-scaffolding

Generated scaffolding project
JavaScript
1
star
39

pruebasph1

Repositorio para pruebas de ph1
JavaScript
1
star
40

IRC-nw.js-chat

IRC chat made in nw.js (node.js based platform that creates cross-platform desktop apps)
CSS
1
star
41

Egghead_lesson-TypeScript_library_starter

Code for the typescript library starter lessons
JavaScript
1
star
42

Footle_deprecated

Reservation system for busy people
JavaScript
1
star
43

ClockMVCBrowserify

Simple Clock MVC project that uses Browserify to organize javacript files
JavaScript
1
star
44

MyWeb

Repo for my Website.
CSS
1
star
45

GCB-creator-lujan

VersiΓ³n que aΓ±ade otro tipo de actividad basada en iframes
JavaScript
1
star
46

Portfolio-client

TypeScript
1
star
47

WebBooks-project-Multimedia-Engineering

WebBooks application made for HyperMedia Development on Multimedia Engineering Degree
CSS
1
star
48

ObserverJS

Simple Observer pattern implementation to use it in hierarchy made in plain javascript
JavaScript
1
star
49

RxJS-FRP-talk

Slides of my talk "RxJS and FRP"
CSS
1
star
50

DBCityFinder

Web-based project that uses DBpedia and SparQL in order to search and filter cities
JavaScript
1
star
51

unnamed-server

TypeScript
1
star
52

AvadaLESS

Light framework and utils library made on LESS
CSS
1
star
53

TripMinder

Repositorio oficial para el TFG TripMinder
JavaScript
1
star
54

APitems

Analytics and charts webapp made for 2nd LOL API Challenge
JavaScript
1
star