Build And Publish A React Component Library

Поділитися
Вставка
  • Опубліковано 26 січ 2025

КОМЕНТАРІ • 175

  • @husfus
    @husfus 4 роки тому +40

    I have been developing components with Storybook at our company for over a year now and we're thinking to OS some of our components as a library. This tutorial just came at the right time. Also, I should mention, you are a gifted teacher. Thanks.

  • @adampiper6388
    @adampiper6388 3 роки тому +19

    I found this super useful! I couldn't find anything that puts it simply and in a short timeframe like you've done. Helped me get started, thank you

  • @andrewiglinski148
    @andrewiglinski148 11 місяців тому +1

    Dude... new sub for sure. I'm a pretty experienced developer but I've never published a full library, and it's fucking daunting. You helped a ton.

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

    I don't believe there was one wasted sentence in this video. I loved it. As crisp as it gets.

  • @pryansh_
    @pryansh_ 11 місяців тому +1

    your video on this is by far the best on UA-cam. Thanks ! It was really too helpful.

    • @NetraPatwari
      @NetraPatwari 10 місяців тому +1

      heyy.. did it work. actually i m stuck because now latest version of story book ask did your project use vite or webpack.. if i follow same instructions of this video. What did u choose
      Your reply will be helpful

    • @pryansh_
      @pryansh_ 10 місяців тому

      @@NetraPatwari yes I came across this. Vite has its own builder and so you will be choosing vite (assuming you are using vite as in this video) not the webpack builder.
      If you encounter any issue you may ask.

    • @NetraPatwari
      @NetraPatwari 10 місяців тому

      @@pryansh_ which one did u use

    • @pryansh_
      @pryansh_ 10 місяців тому

      @@NetraPatwari vite

    • @sr11facts37
      @sr11facts37 2 місяці тому

      @@NetraPatwari hi did you find the solution for it

  • @chovbee
    @chovbee Рік тому +3

    This was an absolute treat to watch. Very quick and yet very clear and informative. Thanks so much for this video! I’m excited to check out more

  • @0oamayapazo0
    @0oamayapazo0 Рік тому

    ok, you're my best friend now. I mean it. THANK YOU. This tutorial is *chef kiss*

  • @sujoyghosh7152
    @sujoyghosh7152 Рік тому +1

    this is probably the most detailed tutorial on the topic. thanks a lot for the video

  • @coding_university_
    @coding_university_ Рік тому +1

    Dude, I like the way your brain work. You know how NOT to leave any detail... This video and the tutorial is synonymous to an efficiently built C++ program. Thanks man!

  • @ShafeequeOM-cx7sn
    @ShafeequeOM-cx7sn 2 роки тому

    Thank you so much for creating the UA-cam video that helped me create my npm package (react-global-loader). Your clear explanations and step-by-step instructions made the process easy to understand and follow. I especially appreciated the tips and troubleshooting advice you provided. Thanks to your help, I was able to successfully publish my package and it's now being used by other developers. Thanks again for taking the time to create such a helpful resource.

  • @scottwager8106
    @scottwager8106 3 роки тому +6

    A tutorial on rollup would be amazing, this tutorial was great!

  • @subhamdivakar
    @subhamdivakar 6 місяців тому

    i got stuck and this video explained all in a go, amazing vid, thanks man

  • @吳亨利-w6k
    @吳亨利-w6k 3 роки тому +1

    wow, this is pretty clear for a newbie to start building a react component library, thanks for your sharing!

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

    REAL STEP BY STEP, thanks for your fantastic explanation.

  • @AjitSingh-ow8qt
    @AjitSingh-ow8qt 2 роки тому +10

    I tried it really helpful. Just one place I was stuck though - I tried creating a jsx component which was failing as rollup was not able to resolve it. for that I had to add `resolve({ extensions: ['.js', '.jsx'] })` instead of resolve().

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

    Great Video, the best even I have found workaround on the youtube. Congrats!!

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

    this is exactly what I am looking for... I am going to apply TypeScript in the future.!

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

    Short, Clear, Useful. Thanks

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

    Superb man... This video has really made my life easy.

  • @Adnan-di8uw
    @Adnan-di8uw Рік тому +1

    Thanks a lot! This really helped 😊

  • @ty-sir6564
    @ty-sir6564 2 роки тому

    This was helpful beyond belief

  • @LauraDiaz-sg7xu
    @LauraDiaz-sg7xu 2 роки тому

    Thank you for this video!! Please make a Rollup tutorial ♥ thanks for sharing and being so kind!

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

    Excellent tutorial. Never seen storybook before but really like it.

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

    Very nice and focused. Boosted my insights.

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

    Really really thank you so much. You saved me a lot.

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

    Thank you so much!! Wonderful Tutorial! It still works in 2022!! :)

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

    published my first package! thanks man 🙌

  • @chmod-tf7ei
    @chmod-tf7ei Рік тому

    dude you helped me a lot, thanks

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

    thank you man, really nice tutorial, very very useful

  • @mk-gandhii
    @mk-gandhii 2 роки тому

    Thank you! 😊 You are an excellent teacher!

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

    Great explanation

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

    Thanks a lot.. exactly what i was looking for. 👏

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

    Thank you so much. This is so useful video for me.

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

    I would defiantly like to see both a rollup and storybook video from you dude? great video, saved me tons of time. I would like to see how to do this in Typescript as well Do you have a video showing this process with GitHub package manager?

  • @antonyraj.c7950
    @antonyraj.c7950 3 роки тому

    You are the man..! Subscribed.

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

    Interesting. Never seen a video about component libraries before.

  • @ankitjaiswal5068
    @ankitjaiswal5068 5 місяців тому

    I've created a CSS file and imported it into my component. The CSS styles are applied correctly when I preview the component in Storybook. However, when I integrate the component into my main application, the component's functionality works as expected, but the CSS classes from the imported file do not merge with the existing styles. Can anyone help me on this.

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

    Incredible!! thank you so mcuh

  • @CarlosGonzalez-sz6yn
    @CarlosGonzalez-sz6yn 3 роки тому

    Very nice tutorial! thank you!

  • @maximilianosalvatti7073
    @maximilianosalvatti7073 11 місяців тому

    Thank you for sharing your knowledge.
    When I try to use the component I created in a react project, I get the error message:
    Invalid hook call. Hooks can only be called inside the body of a function component.
    How do I resolve it? Thanks

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

    Wow this is so much clearer than any other guide. Thanks so much!!

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

    This is a goat tutorial

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

    And what about the use of the example library

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

    hi, i've tried your tutorial until i publish it on npm, but when i tried to use the package there is an error "ReferenceError: React is not defined", how do i solve this? thankss

  • @thomasdasilva-n9v
    @thomasdasilva-n9v Рік тому

    Hello i follow this tuto but how use it ? In my react component what is the import for use this package ?

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

    How would you add ts on this so it can be used on a react-ts app? Does anyone knows any documentation to do this?

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

    This was very helpful.

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

    What is the advantage or disadvantage of using lerna to create a component library? 🤔

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

    First of all, i will tell about case without storybook but it may help globally for all. In resolve function you need add object with properites extension with '.js' '.jsx'. Second of all if you have many components and not one you need to import them and not export and only then export as object.

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

    very useful and straight forward

  • @shanmuktej
    @shanmuktej 10 місяців тому

    Hey! I've been surfing the web on how to publish my whole framework instead of just a few files as a package to import.
    To be specific
    * take a new project
    * npm init playwright
    A set of questions will be asked and boom, basic code will be on your machine.
    I need to build something like that, please help me!

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

    Getting this error:
    Something with peerDependencies??
    Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
    You might have mismatching versions of React and the renderer (such as React DOM)

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

    You said with storybook you dont have to build your application using the library whenever there is a change in the library, HOW?

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

    Awesome tutorial!!!!!

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

    What makes sure that the storybook portion of the project doesn't get included in the build?

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

    What about using it locally with npm link? Is there a way to do that?

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

    minize if for the final app not for library... there is the bad effect when the final app try to minimize content that is already minimize

  • @sailendrachettri8521
    @sailendrachettri8521 Місяць тому

    storiesOf is no longer supported in v8 of sb :(

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

    can anyone answer me how to use this npm package because I try but it give the error please help me

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

    Hi bro, if Button component is built base on something UI framework (as MUI) and after we have published library, question is: Do the user need install MUI to use this library?

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

    If you're getting the error "postcss plugin XXX requires postcss 8" install postcss using "npm i postcss".
    Not sure if it wasn't in the video, or if I missed it.

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

    you saved my day dude

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

    You're really great! thank you in advance!!!

  • @tomfancode
    @tomfancode 11 місяців тому

    Can we have a typescript version

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

    whats the font and theme used?

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

    Wanted to use this as main but storybook is having issues with postcss. Have to move on from this video. But thanks for such awesome video. P.S. my hate JS is increasing day by day now!

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

    Really helpful

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

    Also tutorials on rollup, webpack (basically how these bundlers work under the hood) will be great

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

    while i do npm run build-lib , it is throwing me error like module 'node:process' cannot find . can you help

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

    would you say we could achieve this without rollup?

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

    Please do some content on rollupJs and storybook too. Love your content

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

    Hi Sir,
    I am building a library that is stored in a git repository. I am trying access the library in a different repo. I have created a simple React Hooks Button. I am getting Invalid hooks call error. Can you please help into this?

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

    That was awesome! Thank you for your professional attitude. Maybe you can talk a little shower if that is possible.

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

    Hey, thanks for this fantastic guide. I'm a beginner, how can I also generate a minified CSS in the same "build-lib" script?

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

    So, I'm getting this error when I run npm run build-lib "Error: Cannot find module 'node:process'"

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

      Same here, have you find any possible solution? Thanks!!

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

      @ no dude

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

    how do i using this package after publish it ?

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

    Hello how to use this package?? can you expain it

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

    Superb❤

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

    Great tutorial! question do you have any other videos showing how to build a component library with multiple components? Would you build a storybook for each component in a separate project or can you build a bunch of them in this one project?

    • @divyanshmishra7085
      @divyanshmishra7085 Рік тому +1

      @shaunpx1
      Hey, did you get any update in this regard ?
      I wanted to do the same thing and wanted to know about any resources for the same.

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

    To publish the library , Is is mandatory to have account with npm ? Can I publish without npm account? like only with gitlab account will I able to publish? ( I am new here so apology for silly question)

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

    You create both cjs and es formats, How do you control which format gets imported by default in react.js ? ( without the user targeting that specific format ) example: import abc from 'randomLibName' . another example : import abc from 'randomLibName/bundle.es.

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

    🤣🤣This super useful. As a beginner, I hope can get a github source code to learn

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

      Oh sorry I found that npm i the package can see the source code

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

    how to ue react router dom i cant access this files to host

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

    Awesome Thanks 👍

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

    So when we build a component lib, should we put everything in peer dependencies? like if we use lodash or classnames? and yes it would be perfect if you can post a rollup tutorial

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

    Its great, can u tell in short hw to develop our own UI lib like material UI.

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

    Good work!

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

    Thank You 🙏

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

    Awesome content. I have a request. I assume create react app internally have similar things (they use webpack and babel too). Can you make a video on demystifying react-scripts and how they build the react app?

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

    Rollup is not converting my arrow functions so can't use my react package, how to solve this?

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

      That is the job of Babel. Are you using a Babel plugin?

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

    What is your vs code theme?

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

    Hello PORTExe, Amazing Tutorial! Although there's a slight problem. While importing the component, it seems that the es module does not contain the import React from 'react' statement. Hence the result of importing that component return "React" is undefined. The only way I can make it work at the moment is that manually adding import React in the es module. Then only it seems to work. Can you please suggest a workaround or some plugin because manually adding is not efficient. Thanks

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

      Perhaps it may be worth confirming that you are using React 17 in your app as the JSX transformation method has changed to be implicitly supported by React without the need to declare the import of React.

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

      😂 I also have this problem,have you solved it ?

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

      @@leejay6632 Yes the solution is mentioned in the comments here

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

      @@salik619 Thanks, but I found that add "external: ['react']" to rollup.config.js also worked

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

    npx sb init not working any solution for me?

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

      Do u find solution?

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

      Try cache clean up
      npm cache clean --force

  • @NetraPatwari
    @NetraPatwari 10 місяців тому

    THANK YOU

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

    I came into an issue, it turns out that the set up in the tutorial does not support export default statement from the custom component.
    For instance, if I have export default MyComponent = .....
    after the rollup.js compiled the files, it turns out MyComponent is not included in the compiled files.
    However, if I rewrite it as the tutorial, like, export const MyComponent = function () {},
    then rollup.js compiled MyComponent successfully.
    Then reason I would like to do so, it is I would like to import MyComponent as import MyComponent from "path", instead of import { MyComponent } from "path".
    Does anyone know how to do so? I am still googling it. Thanks.

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

      Did you find your answer? I have the same issue!

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

      @@nextlevelups It is tedious, I was working on a big UI repo. I remembered I looked into the file structure of the Material-UI, now call MUI.
      It turns out that component has its own index.js file, which handle the default export, and there is a root index.js file for the project to handle all the name export.
      Then I went back to the rollup.js file to make this structure happen during the lib is built.
      Hope that help a bit.

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

    Thank you so much

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

    what will happen if my requirements component was receiving a state from parent component or was using context API for a state how will it receive that state in npm package
    My goal is to create a npm package for a entire react app meaning installing that package would allow users to use my react app completely I don't want to use I frame to provide source to my hosted react app instead have that app as a npm package.

    • @Harsh-zv4gn
      @Harsh-zv4gn 2 роки тому

      have you created an npm package of your react app, because the same task is given to me in my company, if you have done this please guide me on how to do it

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

    Hey PORTEXE, Please pin this. I have found the bug due to which people cannot properly use the library. It is the missing import React from 'react' statements in your component files. Since there are no import statements the final dist file does not contain React hence the error React is undefined. The problem goes away when you use react imports.

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

      You saved! I was racking my brain over this

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

      Hello Salik, I tried to add react import to the component but the problem persists, how did you solve it ? Maybe I got my imports wrong...

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

      @@CharlyBeam adding import React from "react" in every component file had solved the problem for me

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

      @@salik619 Thanks I finally figured it out

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

    It's like you read my mind

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

    The tutorial is very useful, but you should mention something that you didn't said, in this case, that when you do build and you have file with extensions jsx you get an error. I found after much time that you must change your file jsx to js.

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

      How to resolve this without chaning the file extension to .js?

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

      @@Wakkyguy I resolve it by removing ./