All Projects → ng-packagr → Nx Packaged

ng-packagr / Nx Packaged

Licence: mit
Angular libraries with ng-packagr embedded in Nx Workspace.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Nx Packaged

notus-angular
Notus Angular: Free Tailwind CSS UI Kit and Admin
Stars: ✭ 148 (+80.49%)
Mutual labels:  angular-cli, angular-components
ng-mono-repo-starter
Angular Mono Repo Starter
Stars: ✭ 79 (-3.66%)
Mutual labels:  monorepo, angular-components
Angular4-seed
Angular 4 Seed for Angular Forms
Stars: ✭ 37 (-54.88%)
Mutual labels:  angular-cli, angular-components
Nativescript Schematics
nativescript, mobile, schematics, angular
Stars: ✭ 176 (+114.63%)
Mutual labels:  monorepo, angular-cli
Nebular
💥 Customizable Angular UI Library based on Eva Design System 🌚✨Dark Mode
Stars: ✭ 7,368 (+8885.37%)
Mutual labels:  angular-components, angular-cli
Ng Packagr
Compile and package Angular libraries in Angular Package Format (APF)
Stars: ✭ 1,730 (+2009.76%)
Mutual labels:  component-library, angular-cli
awesome-angular
💖 A list of awesome Angular (2️⃣➕) resources
Stars: ✭ 61 (-25.61%)
Mutual labels:  angular-cli, angular-components
Barista
Barista - the Dynatrace design system. Tailored to scale.
Stars: ✭ 107 (+30.49%)
Mutual labels:  component-library, angular-components
Clarity
Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.
Stars: ✭ 6,398 (+7702.44%)
Mutual labels:  component-library, angular-components
Angular Interview Questions
Most extensive Angular interview questions based on your level.
Stars: ✭ 354 (+331.71%)
Mutual labels:  angular-components, angular-cli
angular-advanced-course
Angular Advanced Library Laboratory Course - Build Your Own Library
Stars: ✭ 82 (+0%)
Mutual labels:  angular-cli, angular-components
Angularconcepts
Key Angular Concepts using Latest Angular version 5
Stars: ✭ 31 (-62.2%)
Mutual labels:  angular-components, angular-cli
react-component-library-lerna
Build your own React component library managed with lerna, presented with storybook and published in private npm registry.
Stars: ✭ 55 (-32.93%)
Mutual labels:  monorepo, component-library
Angular6 Monorepo Experiment
A monorepo experiment using Angular-CLI and Lerna
Stars: ✭ 15 (-81.71%)
Mutual labels:  monorepo, angular-cli
Angular Interview Questions
A list of helpful Angular interview questions you can use to interview potential candidates, test yourself or completely ignore.
Stars: ✭ 967 (+1079.27%)
Mutual labels:  angular-components, angular-cli
Spring Boot Angular4 Authentication
spring-boot and angular 4 basic authentication with spring security
Stars: ✭ 74 (-9.76%)
Mutual labels:  angular-cli
Aspnetcorespa
Asp.Net 5.0 & Angular 11 SPA Fullstack application with plenty of examples. Live demo:
Stars: ✭ 1,211 (+1376.83%)
Mutual labels:  angular-cli
Superset Ui Plugins
A collection of official Superset UI plugins
Stars: ✭ 73 (-10.98%)
Mutual labels:  monorepo
Angular Cli Webpack
Webpack configuration modifier for @angular/cli
Stars: ✭ 72 (-12.2%)
Mutual labels:  angular-cli
Ft Origami
The Old Origami Website, do not use
Stars: ✭ 80 (-2.44%)
Mutual labels:  component-library

NxPackaged

Demonstrates ng-packagr alongside Nx Workspace.

Develop your libraries and applications in a monorepo. Build distribution-ready binaries in Angular Package Format.

Packaging Angular Libraries

Renovate enabled CircleCI

Transcript

This project was generated with Angular CLI version 1.5.0 using Nrwl Nx.

The following transcript documents reproducible steps to set up this project.

Create Nx Worksapce

First, create an Nx Workspace. This repository was created with the sandbox install script:

$ curl -fsSL https://raw.githubusercontent.com/nrwl/nx/master/packages/install/install-next.sh | bash -s nx-packaged

Alternatively, you could convert an existing Angular CLI project to Nx Workspace. Please see the Nx documentation how to do that.

Create an app

For show-casing and documenting your library, create an Angular app in the Nx Workspace.

$ ng generate app one-app

Create a library

Now, let's create one library for reusable business code and a second library for reusable Angular building blocks:

$ ng generate lib one-lib --nomodule
$ ng generate lib two-lib --ngmodule

Develop libraries

Let's generate a component in the Angular library:

$ ng generate component myButton --app=two-lib

We also need to export the component through an Angular module in two-lib.module.ts:

import { MyButtonComponent } from './my-button/my-button.component';

@NgModule({
  imports: [CommonModule],
  declarations: [MyButtonComponent],
  exports: [MyButtonComponent]
})
export class TwoLibModule {}

And let's also implement some very veeee-ry smart business code in one-lib.ts:

export class OneLib {

  public foo(): string {
    return "bar";
  }
}

Develop the app

Now, import the libraries with @nx-packaged/one-lib and @nx-packaged/two-lib in our application.

Add the TwoLibModule to app.module.ts:

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { TwoLibModule } from '@nx-packaged/two-lib';

@NgModule({
  imports: [ /* ... */ TwoLibModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}

Use the OneLib class in app.component.ts:

import { Component, OnInit } from '@angular/core';
import { OneLib } from '@nx-packaged/one-lib';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  business: OneLib = new OneLib();
}

Wire up all the parts in app.component.html:

<h2>Develop Angular libraries with ng-packagr in a monorepo</h2>

<p>Here is a reusable button component, implemented in a library:</p>
<app-my-button></app-my-button>

<p>Here is reusable business code from a library:</p>
<pre><code>{{ business.foo() }}</code></pre>

Serve the app

Run the app with the standard Angular CLI command:

$ ng serve

Open your browser at http://localhost:4200 and you will see "my-button works!" and "bar" printed on the screen.

Compile the libraries to Angular Package Format

Add ng-packagr to development dependencies:

$ yarn add --dev ng-packagr

For each library, add a package.json in the library folders. Here is the example for the first library:

{
  "$schema": "../../node_modules/ng-packagr/package.schema.json",
  "name": "@nx-packaged/one-lib",
  "version": "1.0.0",
  "ngPackage": {
    "lib": {
      "entryFile": "index.ts"
    },
    "dest": "@nx-packaged/one-lib"
  }
}

Add a build script to the package.json in the repository root folder:

  "scripts": {
    "build:libs": "ng-packagr -p libs/one-lib/package.json"
  }

Now, build the library to its binary representation with the following command:

$ yarn build:libs

The binaries are written to @nx-packaged/one-lib in the repository root folder!

Optional: add a 'productive' app configuration

Add a configuration for Angular CLI to build the app from Angular Package Format bundles in the @nx-packaged folder. The Nx Workspace configuration (by default) builds the app from TypeScript sources in libs/*.

This is a great way to verify that the application works with the distribution-ready binaries:

$ ng build --app one-app-from-packages --prod

However, it also forces you to re-build the library every time you change the sources! During development you can now use ng serve for hot-reloading. On a CI server and in build scripts, you can use the above ng build command to verify the binaries in Angular Package Format!

Relevant configuration in .angular-cli.json:

    {
      "name": "one-app-from-packages",
      "root": "apps/one-app/src",
      "outDir": "dist/apps/one-app",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "../../../test.js",
      "tsconfig": "../../../tsconfig.packages.json",
      "testTsconfig": "../../../tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
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].