Slide 1

Slide 1 text

WRITING A WEBMODULE JSCONF.AR 2014 @TOOTALLNATE

Slide 2

Slide 2 text

WEBMODULES!

Slide 3

Slide 3 text

Not this one

Slide 4

Slide 4 text

Not the Python library either

Slide 5

Slide 5 text

Definitely not this…

Slide 6

Slide 6 text

WEBMODULES! NPM MODULES DESIGNED FOR WEB BROWSER USAGE

Slide 7

Slide 7 text

HTTPS://GITHUB.COM/WEBMODULES

Slide 8

Slide 8 text

THERE’S SOME GUIDELINES… • Very small, focusing on a single task • Client-side bundling via browserify • Repository name matches npm package name • Add a README.md file • Add unit tests, with “cloud testing” enabled

Slide 9

Slide 9 text

SMALL, FOCUSED • Must export a Function: module.exports • Helps enforce the small and focused philosophy • Example: https://github.com/webmodules/node-contains

Slide 10

Slide 10 text

SMALL, FOCUSED • Cross-browser Polyfills • Remember to say focused though! • Example: https:// github.com/webmodules/ progress-event

Slide 11

Slide 11 text

SMALL, FOCUSED • If a module has an inverse function, implement it as a separate module / repository • Example: https://github.com/webmodules/wrap-range and https://github.com/webmodules/unwrap-range wrapRange(‘b’) → unwrapRange(‘b’) →

Slide 12

Slide 12 text

BROWSERIFY • Assume browserify will be used for client-side bundling • It’s possible that other bundlers like component or require.js might work in some cases, but untested

Slide 13

Slide 13 text

GITHUB == NPM • Make it easy for users to find the repository • Basically leaves us at the 2nd level namespace, since most of the good single-word names are taken in the npm registry at this point

Slide 14

Slide 14 text

ALWAYS ADD README.MD • Installation instructions • Usage example • API docs ( dox(1) ) • Travis-CI and Saucelabs build badges

Slide 15

Slide 15 text

CLOUD TESTING • Zuul • Use it to run Mocha unit tests in the browser • npm test command runs zuul • https://github.com/defunctzombie/zuul

Slide 16

Slide 16 text

CLOUD TESTING • Travis-CI • Use it to run SauceLabs browsers in the cloud • Set up GitHub commit hooks to test every commit • https://github.com/defunctzombie/zuul/wiki/Travis-ci

Slide 17

Slide 17 text

CLOUD TESTING • SauceLabs • Zuul is designed to integrate with Saucelabs • Somewhat annoying… you have to create a new SauceLabs account for every module created

Slide 18

Slide 18 text

CLOUD TESTING • In the end, hopefully you get all green passing tests!

Slide 19

Slide 19 text

¡GRACIAS! https://github.com/webmodules