Distributing UI Libraries: in a post Web-Component world

68
Distributing UI Libraries in a post-Web-Component world Rachael L Moore Sr UI Engineer OpenTable morewry OpenTable Tech Talks Current Web Development at OpenTable Tues Feb 2, 2016

Transcript of Distributing UI Libraries: in a post Web-Component world

Page 2: Distributing UI Libraries: in a post Web-Component world

Application Built With UI Components

Page 3: Distributing UI Libraries: in a post Web-Component world

Application Built With UI Components

Page 4: Distributing UI Libraries: in a post Web-Component world

Application Built With UI Components

Page 5: Distributing UI Libraries: in a post Web-Component world

Application Built With UI Components

Page 6: Distributing UI Libraries: in a post Web-Component world

Application Built With UI Components

Page 7: Distributing UI Libraries: in a post Web-Component world

Application Built With UI Components

Page 8: Distributing UI Libraries: in a post Web-Component world

Application

Distributing UI Components to an Application

ApplicationUIComponents

Page 9: Distributing UI Libraries: in a post Web-Component world

Application

Distributing UI Components to an Application

ApplicationUIComponents

Page 10: Distributing UI Libraries: in a post Web-Component world

Application

Distributing UI Components to an Application

ApplicationUIComponents

Page 12: Distributing UI Libraries: in a post Web-Component world

Package Manager Diagram

UserRequest

PackageManager

ComponentPackages

Page 13: Distributing UI Libraries: in a post Web-Component world

Package Manager Diagram

UserRequest

PackageManager

ComponentPackages

Page 14: Distributing UI Libraries: in a post Web-Component world

Package Manager Diagram

UserRequest

PackageManager

ComponentPackages

Page 15: Distributing UI Libraries: in a post Web-Component world

Package Manager Diagram

UserRequest

PackageManager

ComponentPackages

Page 16: Distributing UI Libraries: in a post Web-Component world

Package Manager Diagram

UserRequest

PackageManager

ComponentPackages

Page 17: Distributing UI Libraries: in a post Web-Component world

Package Manager Diagram

UserRequest

PackageManager

ComponentPackages

Page 18: Distributing UI Libraries: in a post Web-Component world

> pkgmgr install a-gui

Package Manager Example

Page 19: Distributing UI Libraries: in a post Web-Component world

> pkgmgr install a-gui

pkgmgr not-cached //ot/a-gui#^0.2.0pkgmgr resolve //ot/a-gui#^0.2.0pkgmgr install a-gui#0.2.1

> pkgmgr install a-gui

Package Manager Example

Page 20: Distributing UI Libraries: in a post Web-Component world

> pkgmgr install a-gui

pkgmgr not-cached //ot/a-gui#^0.2.0pkgmgr resolve //ot/a-gui#^0.2.0pkgmgr install a-gui#0.2.1

pkgmgr not-cached //ot/b-gui#^0.3.0pkgmgr fetch //ot/b-gui#^0.3.0pkgmgr resolve //ot/b-gui#^0.3.0pkgmgr install b-gui#0.3.12

> pkgmgr install a-gui

Package Manager Example

Page 23: Distributing UI Libraries: in a post Web-Component world

Patch Release

Interoperable fixes

Bug fixes

Minor cleanup

Some refactors

<a-gui color="blue"></a-gui>

User's Code

git commit -m "(fix) color not blue in IE10"

Page 24: Distributing UI Libraries: in a post Web-Component world

Minor releases

Backward compatible

New optional functionality

No user changes required

<a-gui color="blue"> </a-gui>

<a-gui color="blue" size="large"> </a-gui>

User's Code

git commit -m "(feat) add size option"

Page 25: Distributing UI Libraries: in a post Web-Component world

<a-gui color="blue"> </a-gui>

<a-gui bg-color="blue"> </a-gui>

Major releases

Breaking changes

Complete rewrite with new public API

Manual changes required by user

User's Code

git commit -m "(api) color -> bg-color"

Page 26: Distributing UI Libraries: in a post Web-Component world

Version Conflict Resolution

Version ranges

Get latest only if compatible with current

Share compatible dependencies

Page 27: Distributing UI Libraries: in a post Web-Component world

Version Locking

"Broken" is not only APIs

Bugs may exist in functionality

Glitches when used together

Page 28: Distributing UI Libraries: in a post Web-Component world

> npm install

# get latest# create lock file

Example Lock FileExample Lock File

Page 29: Distributing UI Libraries: in a post Web-Component world

> npm install

# get latest# create lock file

Example Lock File

{  "name": "A",  "version": "1.1.0",  "dependencies": {    "B": {      "version": "1.0.1",      "from": "B@^1.0.0",      "resolved": "B1.0.1"    },    "C": {      "version": "2.5.3",      "from": "C@^2.4.0",      "resolved": "c2.5.3"    ...

Example Lock File Source

Page 30: Distributing UI Libraries: in a post Web-Component world

> npm install

# get latest# create lock file

> npm install

# skip latest# refer to lock file

> npm install

# get latest# create lock file

Example Lock File

{  "name": "A",  "version": "1.1.0",  "dependencies": {    "B": {      "version": "1.0.1",      "from": "B@^1.0.0",      "resolved": "B1.0.1"    },    "C": {      "version": "2.5.3",      "from": "C@^2.4.0",      "resolved": "c2.5.3"    ...

Example Lock File Source

Page 31: Distributing UI Libraries: in a post Web-Component world

> npm install

# get latest# create lock file

> npm install

# skip latest# refer to lock file

> npm install

# get latest# create lock file

Example Lock FileExample Lock File

Page 32: Distributing UI Libraries: in a post Web-Component world

> npm install

# get latest# create lock file

> npm install

# skip latest# refer to lock file

> npm install

# get latest

> npm install

# get latest# create lock file

> npm install

# skip latest# refer to lock file

> npm install

# get latest# create lock file

Example Lock FileExample Lock File

Page 35: Distributing UI Libraries: in a post Web-Component world

Bootstrap UI Framework

Page 36: Distributing UI Libraries: in a post Web-Component world

Polymer UI Component Library

Page 37: Distributing UI Libraries: in a post Web-Component world

UI Component Definition

style script

text

markupimages

Page 38: Distributing UI Libraries: in a post Web-Component world

UI Component Definition

<a-gui>

Page 39: Distributing UI Libraries: in a post Web-Component world

require(["lodash1"], function(lodash) { // code });

require(["lodash2"], function(lodash) { // code });

<html> <body> <a-gui> </a-gui> </body></html>

HTML - global scoped - JavaScript

Page 40: Distributing UI Libraries: in a post Web-Component world

node_modules

accordion

jquery

modal

jquery

bower_components

jquery

accordion

modal

Bower - flat nested - npm

Page 41: Distributing UI Libraries: in a post Web-Component world

UI ComponentDistribution practices

Page 42: Distributing UI Libraries: in a post Web-Component world

Bower

Flat dependency tree

No version locking

Fewer third party tools?

Page 43: Distributing UI Libraries: in a post Web-Component world

Public Github Repo and Tags

Page 44: Distributing UI Libraries: in a post Web-Component world

Public Github Repo and Tags

Page 45: Distributing UI Libraries: in a post Web-Component world

Private Github Repo

Page 46: Distributing UI Libraries: in a post Web-Component world

"dependencies": { "a-gui":  "git+https://?:[email protected]/?/a-gui.git#^1.0.0"}

token in bower.json URI

Page 47: Distributing UI Libraries: in a post Web-Component world

> git config --global url."https://github".insteadOf git://github

[url "https://github"] insteadOf = git://github

git config / token in .netrcSource

Page 48: Distributing UI Libraries: in a post Web-Component world

> git config --global url."https://github".insteadOf git://github

[url "https://github"] insteadOf = git://github

> touch ~/.netrc && vim ~/.netrc

machine github.com login ? password ?

> git config --global url."https://github".insteadOf git://github

[url "https://github"] insteadOf = git://github

git config / token in .netrcSource

Page 49: Distributing UI Libraries: in a post Web-Component world

Custom registry

Custom file repository

.bowerrc config

Custom resolver

Requires hosting

Private Bower

Page 50: Distributing UI Libraries: in a post Web-Component world

Private Bower Registry

UserInstall

PrivateRegistry

PublicRegistry

Page 51: Distributing UI Libraries: in a post Web-Component world

Private Bower Registry

UserInstall

PrivateRegistry

PublicRegistry

Page 52: Distributing UI Libraries: in a post Web-Component world

Private Bower Registry

UserInstall

PrivateRegistry

PublicRegistry

Page 53: Distributing UI Libraries: in a post Web-Component world

Private Bower Registry

UserInstall

PrivateRegistry

PublicRegistry

Page 54: Distributing UI Libraries: in a post Web-Component world

Private Bower Registry

UserInstall

PrivateRegistry

PublicRegistry

Page 55: Distributing UI Libraries: in a post Web-Component world

{ "registry" : "http://bower.ot.com"}

{ "registry" : "http://artifactory.ot.com", "resolvers": [ "bower-art-resolver" ]}

Private Bower - Hacklone

Private Bower - Artifactory

Page 56: Distributing UI Libraries: in a post Web-Component world

Distributed SourceDeveloper Source

Page 57: Distributing UI Libraries: in a post Web-Component world

{ "name": "a-gui", "dependencies": {  "b-gui": "^0.2.0" }}

{ "name": "b-gui", "dependencies": {  "c-gui": "^0.2.0" }}

/* a-gui dist concats: a-gui b-gui c-gui */

<a-gui> & <b-gui> - bower.json built JS - <a-gui>

Page 58: Distributing UI Libraries: in a post Web-Component world

Distributed SourceDeveloper Source

Page 59: Distributing UI Libraries: in a post Web-Component world

Tasks, Presets, or Recipes

Page 60: Distributing UI Libraries: in a post Web-Component world

{ "name": "risky", "version": "0.0.0", "dependencies": {  "my-comp": "^5.0.0",  "also-this": "^0.3.0" }}

{ "name": "safe", "version": "0.0.0", "dependencies": {  "my-comp": "^4.0.0",  "also-this": "^0.2.0" }}

safe-bundle.js - default versions behind toggle - risky-bundle.js

Page 61: Distributing UI Libraries: in a post Web-Component world

Feature Branches & Pre-Releases

v1.0.0

master

Page 62: Distributing UI Libraries: in a post Web-Component world

feature

Feature Branches & Pre-Releases

v1.0.0

master

Page 63: Distributing UI Libraries: in a post Web-Component world

feature

Feature Branches & Pre-Releases

v1.0.0

master

Page 64: Distributing UI Libraries: in a post Web-Component world

feature

Feature Branches & Pre-Releases

v1.0.1v1.0.0

master

Page 65: Distributing UI Libraries: in a post Web-Component world

feature

Feature Branches & Pre-Releases

v1.0.1v1.0.0

v1.1.0-rc

master

Page 66: Distributing UI Libraries: in a post Web-Component world

feature

Feature Branches & Pre-Releases

v1.0.1v1.0.0

v1.1.0-rc

v1.1.0

master

Page 67: Distributing UI Libraries: in a post Web-Component world

Best Practices

Make independent components

Choose a package manager

Follow a versioning scheme

Avoid disrupting existing uses

Choose a package format

Set up a private registry

Set up a private file repository

Offer optional tasks or recipes

Use feature branches

Make pre-releases

Document!

Page 68: Distributing UI Libraries: in a post Web-Component world

OpenTable is hiring!

We’re hiring!Visit our careers page atopentable.com/careers/

We’re hiring!Visit our careers page atopentable.com/careers/