First, install Yeoman and generator-angular2-library using npm (assuming you already have node.js pre-installed).
$ npm install -g yo
$ npm install -g generator-angular2-library
make a new directory and cd into it:
$ mkdir angular2-library-name
$ cd angular2-library-name
and generate your new library:
$ yo angular2-library
and create the following files for you:
.
├── README.MD
├── index.ts
├── package.json
├── src
│ ├── sample.component.ts
│ ├── sample.directive.ts
│ ├── sample.pipe.ts
│ └── sample.service.ts
├── tsconfig.json
├── tslint.json
└── typings.json
You can then add or edit *.ts files in the src/ directory and run:
$ npm run tsc
$ npm run lint
Once you have published your library to the NPM registry, you can import it in any Angular application by first installing it using NPM:
$ npm install sample-library # use the name you used to publish to npm
Detailed description available here.