Slide 1

Slide 1 text

ForwardJS  5     Building  Isomorphic  Widget  Pla;orm     with  React  and  Webpack   presented  by  Roy  Yu  

Slide 2

Slide 2 text

The  Goal       Explaining  how  to  build  widgets  with  React  that   can  have  SEO  value  and  discuss     architecture  decisions    

Slide 3

Slide 3 text

Warning     This  slide  contains  a  lot  of  graphics.     Viewer  discreIon  advised.    

Slide 4

Slide 4 text

What  we  will  cover  today   Retro  is  a  combinaIon   of  tools,  including   webpack,  it  is  an   internal  framework  we   created  for  our  team.  

Slide 5

Slide 5 text

High-­‐level  Architecture    

Slide 6

Slide 6 text

High-­‐level  Build  and  Delivery  

Slide 7

Slide 7 text

Why  React  ?   •  Performance   •  DeclaraIve   •  Low  Learning  Barrier  (  unIl  you  work  on  more  advance  stuff  )   •  Great  community  support  and  ecosystem   •  Components  are  composable     Isn’t  it  widget  also  meant  reusable  component  ?    React  is   naIvely  a  good  match  of  what  we  need.    

Slide 8

Slide 8 text

Why  Webpack  ?   •  Powerful  build  tool,  module  bundler  and   workflow  enhancer   •  Lots  of  community  support  (  unIl  you  work  on  more  advance   stuff  )   •  Lots  of  assets  transformaIon  loaders  and   opImizaIon  plugins.     We  get  many  features  we  need  out  of  the  box  and  what  we  need  to  do     is  to  feed  webpack  an  configuraIon  file.    The  configuraIon  model  is   somewhere  between  Grunt  and  Gulp.    But,  IMHO,  it  is  way  more   powerful  than  Grunt  and  Gulp  J    

Slide 9

Slide 9 text

Basic  Code  OrganizaIon     Base  Feature     Define  a  normal  high  order  container  and  dump  components     Index.jsx  is  our  high  order  container  which  contains  flux  data  layer     ContestAuthComponents.jsx  is  what  the  industry  call  dump   component,  it  is  a  pure  view  that  take  props  only.        

Slide 10

Slide 10 text

Widget  Design     Approach  #1   A\er  we  have  the  module  or  the  component,  we  now  can  wrap  the   component  individually  with  a  widget    wrapper.    And  client  can  pass   in  config  to  bootstrap  the  widget.        

Slide 11

Slide 11 text

Widget  Design     Approach  #1  (  con>nue  )     But  for  client  that  doesn’t  know  how  to  use  javascript,  you  may  want   to  do  the  following  …    And  ask  them  to  put  a  “#app-­‐container”  into   their  page  J            

Slide 12

Slide 12 text

Widget  Design     Approach  #2       Instead  of  having  individual  wrapper  for  individual  components,  we   can  design  our  widget  as  a  set  of  library.                

Slide 13

Slide 13 text

Widget  Design     Approach  #2  (  con>nue  )     Beaer  yet,  you  can  take  advantage  of  lazy  loading  and  also  import   EventEmiaer  to  manage  the  life  cycle  of  your  widgets.                

Slide 14

Slide 14 text

High-­‐level  Architecture     (  Client  Side  )     Now  we  have  develop  some  widget  source  code  with  React.    And  …     •  We  need  to  transform  source  code,  opImize  it   •  Create  ArIfacts  and  meta  data   •  Deploy  client  assets  to  CDN   But  stay  tune,  we  are  not  done  yet,  the  following  pipeline  is  for  client  side  ONLY.    

Slide 15

Slide 15 text

High-­‐level  Delivery  mechanism   There  are  many  ways  to  package  and  deliver  the   widgets  to  third  party,  what  we  have  tried  :-­‐     •  S3  /  CDN   •  Web  Component  /  Open  Component   •  Public  /  Private  Registry   •  Docker  Container  as  Resources  /  API  proxy   •  Iframe   •  …  blah  …  etc  

Slide 16

Slide 16 text

High-­‐level  Architecture   (  Server  Side  )    

Slide 17

Slide 17 text

High-­‐level  Request   So  at  the  end,  the  template   service  could  be  expose  as  an   API  for  different  language  to   query.     A\er  they  (  like  PHP  /  ruby  )  get   the  response,  they  can  put  the   content  into  their  view.      

Slide 18

Slide 18 text

High-­‐level  Build  and  Delivery  

Slide 19

Slide 19 text

Demo   We  are  going  to  demo  a  client  side  widget   applicaIon  with  React  and  Webpack.       One  important  thing  to  note  in  this  demo  is  the  “meta”  data  file   that’s  generated.         And  later  we  will  go  to  Serve  side    

Slide 20

Slide 20 text

Demo   We  are  going  to  demo  of  Server  side  isomorphic   React  applicaIon.     •  We  will  show  case  Template  Service  as   –  Page  experience   –  API  experience    

Slide 21

Slide 21 text

Demo   We  are  going  to  demo  packaging  our  widget  in  a   format  easy  for  customer  to  consume     Web  Components  /  Open  Components  

Slide 22

Slide 22 text

Major  Technology  of  our  project  

Slide 23

Slide 23 text

haps://www.linkedin.com/in/iroy2000