GithubHelp home page GithubHelp logo

anthonymedinawork / ng-packagr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ng-packagr/ng-packagr

0.0 0.0 0.0 22.47 MB

Compile and package Angular libraries in Angular Package Format (APF)

License: MIT License

TypeScript 95.46% JavaScript 2.61% HTML 0.48% CSS 0.08% Shell 0.29% SCSS 0.53% Less 0.18% Stylus 0.18% Sass 0.19%

ng-packagr's Introduction

ng-packagr

Compile and package Angular libraries in Angular Package Format (APF)

npm npm License CircleCI

GitHub stars npm Downloads Renovate enabled

Installation

npm install -D ng-packagr

Usage Example

Let's walk through a getting started that'll build an Angular library from TypeScript sources and create a distribution-ready npm package: create a package.json file, add the custom ngPackage property, and eventually run ng-packagr -p package.json – Here we go:

{
  "$schema": "./node_modules/ng-packagr/package.schema.json",
  "name": "@my/foo",
  "version": "1.0.0",
  "ngPackage": {
    "lib": {
      "entryFile": "public_api.ts"
    }
  }
}

Note 1: Paths in the ngPackage section are resolved relative to the location of the package.json file. In the above example, public_api.ts is the entry file to the library's sources and must be placed next to package.json (a sibling in the same folder).

Note 2: referencing the $schema enables JSON editing support (auto-completion for configuration) in IDEs like VSCode.

You can easily run ng-packagr through a npm/yarn script:

{
  "scripts": {
    "build": "ng-packagr -p package.json"
  }
}

Now, execute the build with the following command:

$ yarn build

The build output is written to the dist folder, containing all those binaries to meet the Angular Package Format specification. You'll now be able to go ahead and npm publish dist your Angular library to the npm registry.

Do you like to publish more libraries? Is your code living in a monorepo? Create one package.json per npm package, run ng-packagr for each!

Features

  • 🎁 Implements Angular Package Format
    • 🏁 Bundles your library in FESM2020
    • πŸŽ’ npm package can be consumed by Angular CLI, Webpack, or SystemJS
    • πŸ’ƒ Creates type definitions (.d.ts)
    • πŸ† Auto-discovers and bundles secondary entry points such as @my/foo, @my/foo/testing, @my/foo/bar
  • πŸ”Ž Creates scoped and non-scoped packages for publishing to npm registry
  • πŸ„ Inlines Templates and Stylesheets
  • ✨ CSS Features
    • 🐫 Runs SCSS preprocessor, supporting the relative ~ import syntax and custom include paths
    • 🐍 Runs Stylus preprocessor, resolves relative paths relative to ng-package.json
    • πŸ’ Adds vendor-specific prefixes w/ autoprefixer and browserslist β€” just tell your desired .browserslistrc
    • 🐯 Embed assets data w/ postcss-url

How to…

Knowledge

Angular Package Format documentation

Packaging Angular Libraries - Jason Aden at Angular Mountain View Meetup (Jan 2018, 45min talk)

Create and publish Angular libs like a Pro - Juri Strumpflohner at NG-BE (Dec 2017, 30min talk)

Juri Strumpflohner - Create and publish Angular libs like a Pro

Packaging Angular - Jason Aden at ng-conf 2017 (28min talk)

Packaging Angular - Jason Aden

Create and publish Angular libs like a Pro - Juri Strumpflohner at ngVikings, this time demoing building Angular libraries with ng-packagr, with NX as well as Bazel (March 2018, 30min talk)

Juri Strumpflohner - Create & Publish Angular Libs like a PRO at ngVikings

Contributing to ng-packagr

General contribution guidelines

If you like to submit a pull request, you'll find it helpful to take a look at the initial design document where it all started.

To orchestrate the different tools, ng-packagr features a custom transformation pipeline. The transformation pipeline is built on top of RxJS and Angular Dependency Injection concepts.

ng-packagr's People

Contributors

alan-agius4 avatar renovate-bot avatar dherges avatar renovate[bot] avatar schnwalter avatar davidparks8 avatar greenkeeper[bot] avatar joostk avatar sibiraj-s avatar dependabot[bot] avatar macjohnny avatar devversion avatar nlm-pro avatar davidenke avatar nontangent avatar tretne avatar ocombe avatar mwootendev avatar mattlewis92 avatar jordan-hall avatar filipesilva avatar devsull avatar avatsaev avatar ahmedgomaa90 avatar aitboudad avatar travisbuddy avatar thelgevold avatar commanderroot avatar terencehonles avatar tallyb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.