Slide 1

Slide 1 text

Make Snacks YET ANOTHER JAVASCRIPT BUILD SYSTEM

Slide 2

Slide 2 text

OUR APP ▸ Hello World As a Service ▸ .0001k lines of JavaScript ▸ No build system !

Slide 3

Slide 3 text

# Makefile node_modules: package.json npm install touch -m $@

Slide 4

Slide 4 text

$ make node_modules npm install touch -m node_modules

Slide 5

Slide 5 text

. !"" Makefile !"" node_modules <- create or update this #"" package.json <- whenever this changes

Slide 6

Slide 6 text

// src/hello.js module.exports = () => "hello"; // src/world.js module.exports = function() { return "world"; }; // src/index.js import hello from "./hello"; import world from "./world"; console.log(hello() + " " + world());

Slide 7

Slide 7 text

. !"" Makefile !"" lib <- render ES5 here !"" node_modules !"" package.json #"" src <- from ESwhatever sources here !"" hello.js !"" index.js #"" world.js

Slide 8

Slide 8 text

SRC = $(wildcard src/*.js) LIB = $(SRC:src/%.js=lib/%.js) lib: $(LIB) lib/%.js: src/%.js .babelrc node_modules mkdir -p $(@D) node_modules/.bin/babel $< -o $@

Slide 9

Slide 9 text

$ make lib/hello.js mkdir -p lib node_modules/.bin/babel src/hello.js -o lib/hello.js

Slide 10

Slide 10 text

// src/world.js module.exports = function() { return "world"; }; // lib/world.js "use strict"; module.exports = function () { return "world"; };

Slide 11

Slide 11 text

// src/hello.js module.exports = () => "hello"; // lib/hello.js "use strict"; module.exports = function () { return "hello"; };

Slide 12

Slide 12 text

// src/index.js import hello from "./hello"; import world from "./world"; console.log(hello() + " " + world());

Slide 13

Slide 13 text

// lib/index.js "use strict"; var _hello = require("./hello"); var _hello2 = _interopRequireDefault(_hello); var _world = require("./world"); var _world2 = _interopRequireDefault(_world); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } console.log((0, _hello2.default)() + " " + (0, _world2.default)());

Slide 14

Slide 14 text

. !"" Makefile !"" bundle.js <- make this !"" lib <- by bundling these # !"" hello.js # !"" index.js # $"" world.js !"" node_modules !"" package.json $"" src <- which source from these !"" hello.js !"" index.js $"" world.js

Slide 15

Slide 15 text

bundle.js: $(LIB) node_modules/.bin/browserify lib/index.js > $@

Slide 16

Slide 16 text

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require; if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}}; t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require; for(var o=0;o

Slide 17

Slide 17 text

bundle.js: $(LIB) node_modules/.bin/browserify lib/index.js | ./node_modules/.bin/prepack > $@

Slide 18

Slide 18 text

console.log("hello world");

Slide 19

Slide 19 text

THANK YOU I'M SO SORRY