All Projects β†’ trekhleb β†’ Angular Library Seed

trekhleb / Angular Library Seed

Licence: mit
🌾 Seed project for Angular libraries that are AOT/JIT compatible and that use external SCSS-styles and HTML-templates

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Angular Library Seed

Universal
Seed project for Angular Universal apps featuring Server-Side Rendering (SSR), Webpack, CLI scaffolding, dev/prod modes, AoT compilation, HMR, SCSS compilation, lazy loading, config, cache, i18n, SEO, and TSLint/codelyzer
Stars: ✭ 669 (+239.59%)
Mutual labels:  aot, starter, seed
angular-gulp-starter
Simple dev/prod build for Angular (2+) using gulp, systemjs, rollup, ngc (AOT), scss, Visual Studio
Stars: ✭ 18 (-90.86%)
Mutual labels:  seed, starter, aot
ng-seed
Simple Angular seed project with commonly used features.
Stars: ✭ 12 (-93.91%)
Mutual labels:  seed, starter, aot
Egeo
EGEO is the open-source UI library used to build Stratio's UI. It includes UI Components, Utilities, Services and much more to build user interfaces quickly and with ease. The library is distributed in AoT mode.
Stars: ✭ 69 (-64.97%)
Mutual labels:  aot, library, aot-compilation
example-app
Example app showcasing fulls1z3's Angular libraries
Stars: ✭ 27 (-86.29%)
Mutual labels:  seed, starter, aot
angular4-seed-starter
An angular4 starter with webpack2+aot+lazyload+hmr+scss(δΈͺδΊΊζ­ηš„angular4 starterοΌŒδ½Ώη”¨webpack2οΌŒεŒ…ε«aot、lazyload、scssγ€ηƒ­ζ›Ώζ’εŠŸθƒ½η­‰η­‰)
Stars: ✭ 23 (-88.32%)
Mutual labels:  starter, aot
angular-webpack-skeleton
This project is deprecated. Please refer to https://github.com/Ks89/angular-cli-skeleton
Stars: ✭ 16 (-91.88%)
Mutual labels:  starter, aot
Angularx Qrcode
Angular4/5/6/7/8/9/10/11 QRCode generator component library for QR Codes (Quick Response) with AOT support based on node-qrcode
Stars: ✭ 281 (+42.64%)
Mutual labels:  aot, aot-compilation
Ngx Cookie Service
Angular (4.2+ ...11) service for cookies. Originally based on the `ng2-cookies` library.
Stars: ✭ 363 (+84.26%)
Mutual labels:  aot, aot-compilation
Angular Seed
🌱 [Deprecated] Extensible, reliable, modular, PWA ready starter project for Angular (2 and beyond) with statically typed build and AoT compilation
Stars: ✭ 4,681 (+2276.14%)
Mutual labels:  seed, aot-compilation
Webpack Starter Basic
A simple webpack starter project for your basic modern web development needs.
Stars: ✭ 552 (+180.2%)
Mutual labels:  starter, seed
node-starter-kit
Node.js / GraphQL project template pre-configured with TypeScript, PostgreSQL, login flow, transactional emails, unit tests, CI/CD workflow.
Stars: ✭ 76 (-61.42%)
Mutual labels:  seed, starter
angular-routing
Angular 13 Example Routing
Stars: ✭ 21 (-89.34%)
Mutual labels:  seed, starter
Angular Library Starter
Build an Angular library compatible with AoT compilation and Tree shaking like an official package
Stars: ✭ 272 (+38.07%)
Mutual labels:  library, aot-compilation
Angular Webpack Starter
A complete Angular 6 and Webpack 4 starter seed with minimal and full featured branches. Full featured branch includes: Material Design 2 (Bootstrap 4 branch available as well), @ngrx, HMR, DLLs and optional use of Universal for server-side rendering - Supports AOT (offline) compilation, sync and lazy loading. Karma/Protractor for e2e/unit tests.
Stars: ✭ 911 (+362.44%)
Mutual labels:  aot, starter
Angular Library Starter Kit
Angular 5 Library Starter Kit based on Angular-CLI
Stars: ✭ 35 (-82.23%)
Mutual labels:  starter, library
Angular Open Source Starter
This is a starter project for creating open-source libraries for Angular. It is a full fledged Angular workspace with demo application and easy library addition. It is designed to be used for open-sourcing libraries on Github and has everything you'd need ready for CI, code coverage, SSR testing, StackBlitz demo deployment and more.
Stars: ✭ 120 (-39.09%)
Mutual labels:  starter, library
angular2-webpack-advance-starter
An advanced Angular2 Webpack Starter project with support for ngrx/store, ngrx/effects, ng2-translate, angulartics2, lodash, NativeScript (*native* mobile), Electron (Mac, Windows and Linux desktop) and more.
Stars: ✭ 49 (-75.13%)
Mutual labels:  seed, starter
Opengl Seed
βšͺ🌱A modern OpenGL starter repo that you could use to get the ball rolling.
Stars: ✭ 20 (-89.85%)
Mutual labels:  starter, seed
Angular Seed Express
[DEPRECATED, Please use https://github.com/vyakymenko/angular-express] Extensible, reliable and modular starter project for Angular 7 with statically typed build AoT compilation, Express server and PM2 Daemon.
Stars: ✭ 107 (-45.69%)
Mutual labels:  seed, aot-compilation

angular-library-seed - the starter for Angular libraries

Build Status codecov npm version

Seed project for Angular libraries that are AOT/JIT compatible and that use external SCSS-styles and HTML-templates.

This project contains TickTock library example. The library itself is small and the only thing it does is displaying current time (Plunker example). But what most important is that the project contains reusable environment for the libraries that allows to build, test, lint, document, explore and publish them.

Read more about architectural challenges and solutions used in this repository.

You might find this project helpful if

  • You want to create library for Angular 4.
  • You want your library to be ready for further AOT or JIT compilation.
  • You want your library to be ready for further usage directly in browsers (let's say UMD bundle loaded by SystemJS).
  • You want to write component styles in external SCSS files.
  • You want to write component templates in external HTML files.
  • You want to have watch-mode for library builds (including AOT build).

Main Features

  • AOT/JIT compatible library build via Angular Compiler (ngc).
  • UMD build via Webpack that allows you to use your library for browser builds. You may play with it on Plunker.
  • Testing with Karma and Jasmine.
  • Test coverage report via Istanbul.
  • Watch modes for building and testing procedures that makes developing process easier.
  • Linting with TSLint and Codelyzer for static code analysis.
  • Exploring your build via Sourcemap Explorer that shows you a treemap visualization to help you debug where all the code is coming from.
  • Documentation generation via Compodoc. Take a look at documentation example.
  • Documentation hosting via GitHub Pages.
  • AOT/JIT/UMD demos via Webpack and SystemJS that allows you to test library builds.
  • Continuous integration with Travis CI.
  • Code coverage badge via Codecov as a reminder to cover code with tests.

Quick Start

# Clone the repository
git clone https://github.com/trekhleb/angular-library-seed.git

# Go to repository folder
cd angular-library-seed

# Install all dependencies
yarn install

# Build the library
yarn build

File Structure

angular-library-seed
  β”œβ”€ demo                         * Folder for demo applications (MAY BE DELETED if not required) 
  |  β”œβ”€ esm                       * AOT/JIT demo project
  |  β”œβ”€ umd                       * UMD demo project
  |  └─ ...                       * More details about this folder may be found in demo folder README file.
  |
  β”œβ”€ src                          * Library sources home folder (THE PLACE FOR YOUR LIBRARY SOURCES)
  |  β”œβ”€ components                * Example of library components with tests
  |  β”œβ”€ services                  * Example of library services with tests
  |  β”œβ”€ index.ts                  * Library entry point that is used by builders
  |  └─ tick-tock.module.ts       * Example of library module
  |
  β”œβ”€ .editorconfig                * Common IDE configuration
  β”œβ”€ .gitignore	                  * List of files that are ignored while publishing to git repo
  β”œβ”€ .npmignore                   * List of files that are ignored while publishing to npm
  β”œβ”€ .travis.yml                  * Travic CI configuration
  β”œβ”€ LICENSE                      * License details
  β”œβ”€ README.md                    * README for you library
  β”œβ”€ gulpfile.js                  * Gulp helper scripts
  β”œβ”€ karma-test-entry.ts          * Entry script for Karma tests
  β”œβ”€ karma.conf.ts                * Karma configuration for our unit tests
  β”œβ”€ package.json                 * NPM dependencies, scripts and package configuration
  β”œβ”€ tsconfig-aot.json            * TypeScript configuration for AOT build
  β”œβ”€ tsconfig.json                * TypeScript configuration for UMD and Test builds
  β”œβ”€ tslint.json                  * TypeScript linting configuration
  β”œβ”€ webpack-test.config.ts       * Webpack configuration for building test version of the library
  β”œβ”€ webpack-umd.config.ts        * Webpack configuration for building UMD bundle
  └─ yarn.lock                    * Yarn lock file that locks dependency versions

Getting Started

Dependencies

Node/NPM

Install latest Node and NPM following the instructions. Make sure you have Node version β‰₯ 7.0 and NPM β‰₯ 4.

  • brew install node for Mac.

Yarn

Yarn package manager is optional but highly recommended. If you prefer to work with npm directly you may ignore this step.

Yarn installs library dependencies faster and also locks theirs versions. It has more advantages but these two are already pretty attractive.

Install Yarn by following the instructions.

  • brew install yarn for Mac.

Installing

  • fork this repository.
  • clone your fork to your local environment.
  • yarn install to install required dependencies (or npm i).

Replace TickTock library with your own library

This step may be optional at first since you might just want to play with existing library example.

Once you're ready to develop your own library you should do the following.

  • Check and re-configure package.json fields like name, version, keywords, description etc. You may read about specifics of npm's package.json handling to do that.
  • Replace the content of src folder with your library sources. Your library must have index.ts file as an entry point for further building.
  • Update demo sources to make them consume your library in case if you want to keep the demo folder.

Build the library

  • yarn build for building the library once (both ESM and AOT versions).
  • yarn build:watch for building the library (both ESM and AOT versions) and watch for file changes.

You may also build UMD bundle and ESM files separately:

  • yarn build:esm - for building AOT/JIT compatible versions of files.
  • yarn build:esm:watch - the same as previous command but in watch-mode.
  • yarn build:umd - for building UMD bundle only.
  • yarn build:umd:watch - the same as previous command but in watch-mode.

Other commands

Lint the code

  • yarn lint for performing static code analysis.

Test the library

  • yarn test for running all your *.spec.ts tests once. Generated code coverage report may be found in coverage folder.
  • yarn test:watch for running all you *.spec.ts and watch for file changes.

Generate documentation

  • yarn docs for generating documentation locally.
  • yarn gh-pages for generating documentation and uploading it to GitHub Pages. Documentation example.

Explore the bundle

  • yarn explorer to find out where all your code in bundle is coming from.

Bump library version

preversion script in this case will automatically run project testing and linting in prior in order to check that the library is ready for publishing.

Publish library to NPM

prepublishOnly script in this case will automatically run project testing and linting in prior in order to check that the library is ready for publishing.

Cleaning

  • yarn clean:tmp command will clean up all temporary files like docs, dist, coverage etc.
  • yarn clean:all command will clean up all temporary files along with node_modules folder.

Library development workflow

In order to debug your library in browser you need to have Angular project that will consume your library, build the application and display it. For your convenience all of that should happen automatically in background so once you change library source code you should instantly see the changes in browser.

There are several ways to go here:

  • Use your real library-consumer project and link your library to it via yarn link command (see below).
  • Use demo applications that are provided for your convenience as a part of this repository.
  • Use Angular-CLI to generate library-consumer project for you and then use yarn link to link your library to it.

Using demo applications

You may take advantage of watch-modes for both library build and demo-projects builds in order to see changes to your library's source code immediately in your browser.

To do so you need to:

  1. Open two console instances.
  2. Launch library build in watch mode in first console instance by running yarn build:watch (assuming that you're in angular-library-seed root folder).
  3. Launch demo project build (JIT version) in watch-mode by running yarn start in second console instance (assuming that you're in angular-library-seed/demo folder).

As a result once you change library source code it will be automatically re-compiled and in turn your JIT demo-project will be automatically re-built and you will be able to see that changes in your browser instantly.

For more details about demo projects, their folder structure and npm commands please take a look at demo projects README.

Using yarn link

In you library root folder:

# Create symbolic link
yarn link

# Build library in watch mode
yarn build:watch

In you project folder that should consume the library:

# Link you library to the project
yarn link "angular-library-seed"

# Build your project. In case of Angular-CLI use the following command.
ng serve --aot

Then you need to import your library into your project's source code.

Now, once you update your library source code it will automatically be re-compiled and your project will be re-built so you may see library changes instantly.

More information about yarn link command.

At the moment of publishing this project there is a bug exists when using yarn link in combination with Angular CLI. The issue is caused by having node_modules folder inside linked library. There is a workaround has been provided that suggests to add a paths property with all Angular dependencies to the tsconfig.json file of the Angular CLI project like it is shown below:

{
  "compilerOptions": {
    "paths": { "@angular/*": ["../node_modules/@angular/*"] }
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].