Fireship · @fireship

Big JavaScript Projects - Code Sharing

Uploaded September 6, 2018 · Length 8:01

Big JavaScript Projects - Code Sharing

Summary

Sharing code between large JavaScript projects using Firebase and NPM, including creating a shared library and setting up multiple hosting targets.

  • javascript code sharing
  • firebase hosting
  • npm packages
  • shared libraries
  • mono repos
  • multi repos
  • javascript project structure

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    [Music]

  2. 0:06

    code reusability is one of the most

  3. 0:08

    important concepts in all of software

  4. 0:10

    development but what often happens is

  5. 0:12

    you write some code in one app and then

  6. 0:13

    you want to reuse it in a different app

  7. 0:15

    down the road maybe you're back at cloud

  8. 0:17

    functions or a different front-end app

  9. 0:18

    but it's not very easy to reuse that

  10. 0:21

    code because it's tightly coupled to one

  11. 0:22

    specific app in today's video we'll look

  12. 0:24

    at code sharing strategies specifically

  13. 0:27

    for large JavaScript projects if you're

  14. 0:29

    new the channel like and subscribe and

  15. 0:31

    grab the full source code from angular

  16. 0:33

    firebase.com and i'm also giving away

  17. 0:35

    some free swag with this video all you

  18. 0:37

    have to do is leave a comment below and

  19. 0:38

    I'll randomly pick a winner by this

  20. 0:40

    weekend let's imagine that we have three

  21. 0:42

    different apps we have a customer facing

  22. 0:44

    angular app we used view to build an

  23. 0:46

    admin app and then we have a cloud

  24. 0:47

    functions back-end with note j s our

  25. 0:50

    goal with this video is to orchestrate

  26. 0:52

    all these projects with firebase and

  27. 0:54

    then also share common business logic

  28. 0:56

    and typescript interfaces between them

  29. 0:58

    so I just have an empty directory opened

  30. 1:01

    up here in vs code and the first thing

  31. 1:02

    I'll do is generate our angular

  32. 1:04

    front-end by running the ng new command

  33. 1:06

    this just generates a basic angular app

  34. 1:08

    but the important thing to keep in mind

  35. 1:10

    here is that this project has its own

  36. 1:12

    package.json and it also has its own

  37. 1:14

    dedicated git repository now to add some

  38. 1:17

    complexity I'll also generate a view app

  39. 1:20

    with the view CLI and just like angular

  40. 1:22

    it has its own package JSON and its own

  41. 1:24

    git repo then we'll give our app a

  42. 1:26

    back-end by initializing firebase and

  43. 1:28

    I'm going to select functions and

  44. 1:30

    hosting as the firebase features the

  45. 1:33

    functions directory is also a node.js

  46. 1:34

    project so it has its own package JSON

  47. 1:37

    and then it doesn't have a git

  48. 1:38

    repository by default but you can

  49. 1:39

    initialize one in there as well so now

  50. 1:42

    we have firebase initialized in this

  51. 1:44

    parent directory and we can orchestrate

  52. 1:45

    the deployments for our front-end apps

  53. 1:47

    and our functions I have an entire video

  54. 1:50

    on multi site hosting so make sure to

  55. 1:51

    check that out but what we can do in

  56. 1:53

    this firebase JSON file is set up

  57. 1:55

    multiple hosting targets so we can

  58. 1:57

    deploy our angular app to one URL and

  59. 1:59

    our view app to a different URL but have