Create Your First Angular Library - Nir Kaufman

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • This talk will guide you through the process of creating an Angular library from scratch using the Angular CLI. You will learn how to set up a project correctly, how to configure your library, and how to generate a sample project to test it.

КОМЕНТАРІ • 75

  • @ciprianionutiacob7883
    @ciprianionutiacob7883 4 роки тому +63

    I think it's worth mentioning that you can do ng build magic-lib --watch=true and that will watch for changes in lib and automatically update the application.

    • @tawandakanyangarara9248
      @tawandakanyangarara9248 4 роки тому +4

      Dude you are a champion ✊🏿

    • @boris_js
      @boris_js 4 роки тому +2

      I did the same for a remote app in my machine through npm link. This command works whenever i make changes in my lib, it reloads my remote app but does not reflect the latest lib changes. I have to ng serve everytime on the remote app to reflect the changes. Any suggestion on this

    • @user779hjg45
      @user779hjg45 3 роки тому

      Thank you!

    • @quilagameplay3161
      @quilagameplay3161 2 роки тому

      very usefull indeed

    • @elazarzadiki3059
      @elazarzadiki3059 2 роки тому +2

      use npm link on both your dist/your-library folder and your root folder, then ng build your-library --watch and ng serve, changes will be updated automatically.

  • @programmercouple
    @programmercouple 3 роки тому +3

    Till date, I use this video every time I want to create a new Angular Library

  • @paolatellez293
    @paolatellez293 4 роки тому +5

    Explanation is to the point, very clear and helpful. Thank you Nir Kaufman.

  • @EliRabinovitz
    @EliRabinovitz 4 роки тому +3

    First time I've seen someone program like me. Define names once, copy paste after. Thanks for a great tutorial

  • @MikeBritton
    @MikeBritton 3 роки тому +1

    This is the best Angular Library Development video out there right now (03/10/2021). Nice work

  • @abhimalvekr127
    @abhimalvekr127 3 роки тому

    After watching this super explanation, I am a fan of Nir Kaufman!

  • @SahanSerasinghe
    @SahanSerasinghe 4 роки тому +3

    Thanks Nir. Awesome presentation!!! This is exactly what I was looking for

  • @rembautimes8808
    @rembautimes8808 2 роки тому

    Great talk Nir. Was watching your video while waiting for some noodle 🍜 to be delivered.

  • @jasonwilliams_escapeimagery
    @jasonwilliams_escapeimagery 4 роки тому +1

    An excellent talk. Very informative.

  • @mohammedaminaimeur6892
    @mohammedaminaimeur6892 3 роки тому +3

    Amazing video, so clear and straight forward, I would've loved to see the rest of it though :(

    • @franco1g
      @franco1g 2 роки тому

      Ditto. I'd like to see the install and consumption

  • @sakethpavan4901
    @sakethpavan4901 2 роки тому

    Great explanation!

  • @ip2pi
    @ip2pi 4 роки тому +2

    Great tutorial, nicely explained (+ learned some new capabilities in angular :) ) Toda !!

  • @antoniofcable
    @antoniofcable 4 роки тому +1

    Very nice explanation. Congratulations. Very useful for me. This is what I was looking for.

  • @doron99
    @doron99 2 роки тому

    אלוף! תענוג כמה ידע, תודה רבה!

  • @adeptairsoft6460
    @adeptairsoft6460 3 роки тому +1

    Great tutorial! Thank you 👍

  • @aram5642
    @aram5642 3 роки тому +3

    Would be cool to watch a video on setting entire CI github pipeline too :) BTW. if we cared about the `nk-` prefix for the library, by the same token we should also use `nk-mark` class instead, to try to avoid naming clashes.

  • @SelimAbidin
    @SelimAbidin 4 роки тому +1

    For those who have some problems. Make sure that you use NPM or Yarn. Not both together. If you are going to use another package manager, first remove package lock file.

  • @dachd
    @dachd 5 років тому +5

    I like this man!

  • @lupinasp
    @lupinasp 3 роки тому +2

    Thanks Nir, great presentation!
    I've got an error in ViewEncapsulation part. If someone needs here's how to fix it (Angular 8):
    Change:
    import { ViewEncapsulation } from '@angular/compiler/src/core';
    To:
    import { Component, OnInit, ViewChild, ElementRef, ViewEncapsulation } from '@angular/core';

  • @ashishnamdeo6879
    @ashishnamdeo6879 4 роки тому +1

    Really nice explanation.....

  • @MattDuarte11
    @MattDuarte11 4 роки тому +1

    This is dope!

  • @mdrizwanansari
    @mdrizwanansari 3 роки тому +1

    felt like 'Cisco Ramon' is teaching me

  • @pranavbhatia6637
    @pranavbhatia6637 4 роки тому

    Really helpful video. Thanks!

  • @prem101434
    @prem101434 2 роки тому +1

    We can use storybook to check the library right?.

  • @swatijoshi7614
    @swatijoshi7614 4 роки тому

    Hi Team, Great tutorial, nicely explained concepts and reasons :) Thank you.
    Do we have a further part after this video this seems some more part is missing?

  • @BeautyHolicFamily8652
    @BeautyHolicFamily8652 Рік тому

    Nice channel

  • @sasagasparovic9351
    @sasagasparovic9351 3 роки тому

    I want more tutorials from that guy :D

  • @brabenetz
    @brabenetz 4 роки тому +1

    First at all: Thanks for the video! It helped me a lot!
    But at 13:30 "Import library as regular module" I see two problems:
    - Running the testbed app will change the content in the dist-folder (Maybe a newer problem which only exists since angular 9 with Ivy )
    - Auto-Restart during development is also not available
    So I prefer the less realistic version to integrate the library directly from the src folder.
    What you think?

    • @yasenbonev7879
      @yasenbonev7879 3 роки тому

      I don't remember where exactly I saw it, maybe the documentation, but if you're importing the source code of a library you're in for a hell of a ride, there is a reason why libraries are packaged with ng-packagr and applications are not. These difference will kill your brain cells.

    • @brabenetz
      @brabenetz 3 роки тому

      @@yasenbonev7879 At least one concrete point to your paragraph would be nice :) What is you source? what are the reason you speaking of? What you mean with "hell of a ride" or "will kill your brain cells". Your comment is really very blurry :)

  • @kwentinn
    @kwentinn 4 роки тому +1

    great ! thanks mate !

  • @robertbryan6485
    @robertbryan6485 4 роки тому +1

    Someone mind explaining why the library's component needed to have the view encapsulation set to none? Setting a component's view encapsulation to none here seems like a code smell to me.

  • @rajathvenkatesh3253
    @rajathvenkatesh3253 2 роки тому

    I am looking to share services and make them as singletons to be used between my shell and micro front ends in angular.
    I use angular architects module federation!
    I have multi repo MFEs so NX share libraries would not be a good option.
    Any advise?

  • @arinmovsesian
    @arinmovsesian 4 роки тому +2

    i cant create multiple library :(
    get this error (does not support the 'build' target)

    • @nirkaufman101
      @nirkaufman101 4 роки тому +1

      Drop me an email. show me some code :) I'll try to help

  • @manjaykumar-jb7yp
    @manjaykumar-jb7yp Рік тому

    How to use Primeng as a dependency in custom angular library which is on angular version 15?

  • @msasoftware
    @msasoftware 4 роки тому +1

    I was presented with an error message when compiling the library and resolved it at this point with the following:
    export class MagicStringComponent implements OnInit {
    @ViewChild ('content', {static: true}) content: ElementRef
    Angular "@ angular / cli": "~ 9.1.0",

    • @ManojKumar-rc5ze
      @ManojKumar-rc5ze 4 роки тому

      Awesome ... Thanks for sharing this information

  • @zorglob007
    @zorglob007 5 років тому +1

    Nice video but i tried to make an angular library as a design system library and when i build the library, i don't have css or assets files include. Have you got any idea how to resolve this problem ?

    • @nirkaufman101
      @nirkaufman101 4 роки тому +1

      Shoot me an email: nirkaufman@gmai.com

  • @kampkrieger
    @kampkrieger 4 роки тому

    did it as you did, but it can't find the lib (magic-string). no clue what to do... What changed?

  • @akshaychavan6158
    @akshaychavan6158 4 роки тому +2

    Nice explanation,
    How to use that package in another application?

    • @nirkaufman101
      @nirkaufman101 4 роки тому +1

      Just npm install like any other package :)

    • @jose-chin
      @jose-chin 4 роки тому +1

      @@nirkaufman101 but that is after publish to npmjs.org right?

    • @nirkaufman101
      @nirkaufman101 4 роки тому +2

      @@jose-chin no need to publish to npm at all. All local. Use npm link

  • @angulardeveloper331
    @angulardeveloper331 4 роки тому

    This is great! Very useful. Thanks man. Question: Let say in this new library I'd like to subscribe/emit new data to a behavior subject from app.service.ts, how do I do that? I tried it out by using:
    @Inject('AppService') private appService: any within the library, (because in AppService, it's injected to the root as @Injectable({providedIn: 'root'});, and I did put {provide: AppService, useValue: AppService } in AppModule), but I received an undefined error: Cannot read property 'subscribe' of undefined. Is there something I missed in dependency injection? I'll keep looking for an answer and come back here to post the solution if I found it. Thanks.

  • @unnhao
    @unnhao 4 роки тому +1

    24:32 I want to know about this extra configuration, but I can't find which meetup talk this. :(

    • @NicoDeathend
      @NicoDeathend 4 роки тому

      I take a look quickly over this video ua-cam.com/video/kxlDFWcwZc4/v-deo.html I think it may be, checkout minute 15:48

  • @LongTran-nm3ne
    @LongTran-nm3ne 4 місяці тому

    Hi sir. What to do next with .tgz file??

  • @subba18
    @subba18 4 роки тому

    Can I build a prod app with many libraries like this for dynamic loading.. Will it work for say 50-70 libraries?

  • @daniela.parionac
    @daniela.parionac 3 роки тому

    How to update an Angular library project? if I use ng update @angular/core@12 @angular/cli@12 --force, this command is updating my Angular main project but not the library project. Which is sub part of the main project, I want update library project, help me please

  • @arpitmalaiya2825
    @arpitmalaiya2825 3 роки тому

    While using icons in the library , i was unable to get them in the app in which i was using library. Can anyone help me with it?

  • @amitapatiyal3228
    @amitapatiyal3228 3 роки тому

    Is there any way to add external script in library. The way we have in application

    • @sachinpatil2253
      @sachinpatil2253 3 роки тому

      Have you find any solution to add external script.

  • @MrRorypam
    @MrRorypam 4 роки тому

    This is Great tutorial.
    But i feel that i am facing the issue in angular9. that is after importing and adding MagicStringModule inside the imports like below
    imports: [
    BrowserModule,
    MagicStringModule
    ],
    I am finding below exception
    Inspection info: Reports any symbols that are declared, imported or exported by an Angular module that are not modules, components, directives or pipes or can’t be used in the context of the property.
    Please help in i this regards.

    • @MrRorypam
      @MrRorypam 4 роки тому

      @Nir please reply on this

  • @ksaweryglab
    @ksaweryglab 4 роки тому

    Thanks Nir for this very insightful video, BUT when I run yarn serve demo-app, then apply changes to the library, and then expect these changes to be visible in the app - I get the compiler errors telling me that the compiler cannot find library module - probably because when you ng build library - it will first remove the contents of the lib in dsit folder, triggerring the error, and then build it but at this stage the compiler that runs on the application is stuck on the error.
    So in my case I have to:
    - apply changes to library component
    - run ng build library - to populate the dist folder
    - stop and restart the ng serve demo-app --> something you don't have to do in your presentation
    So my question is - anyone else has similar problems to mine?
    I double checked and I import the library in app.module.ts in the same way Nir does.

    • @ksaweryglab
      @ksaweryglab 4 роки тому

      Ok, I have a workaround - actually working even better.
      I run two commands:
      ng build libraryName --watch=true
      ng serve demoAppName --port=4300
      First command rebuilds the library into dist folder every time you change the component.
      Second command runs the demo app in default watch mode and refreshes (without errors) when the library is rebuilt.
      This setup is fucking awesome if I may say so myself.
      Thanks to @CiprianIonutIacob below for hinting that you can run ng build lib --watch=true. Thanks man!

  • @GalloFranco
    @GalloFranco 4 роки тому

    Someone find the complete talk?

  • @crazy_coder
    @crazy_coder 4 роки тому

    Can i use third party library in my angular library?

  • @prvinsharma
    @prvinsharma 2 роки тому

    It's a bad practice using ViewEncapsulation.None. It causes css class pollution. Worse the libs/components doing it actually adds to the global css namespace as and when visited. This can lead to tricky bugs.
    On similar grounds, hate the way CSS needs to be overridden for material libs in global styles.scss file.

  • @B20C0
    @B20C0 3 роки тому

    cool?