System webpack-jspm
- 2. TEXT
WHAT?
▸ DevOps & Lean Engineering
▸ Brief on Angular/React/Backbone & Node Workflow
▸ Deep Dive in JavaScript Modules
- 5. NO SCALE
GLOBAL BAD
▸ global variables: they fast…
▸ … but no clue who’s setting them, access control
▸ global state
▸ no control
- 9. NODE
COMMONJS
▸ Encapsulation / Global Safe (unless you r t3h l@m3 and use global)
▸ Module system
▸ Version Safe (via local node_modules)
▸ synchronous
▸ dependent loading
▸ Node (server or build system)
- 14. REQUIRE IN THE BROWSER
BROWSERIFY
▸ "work everywhere"
▸ Node rocks with CommonJS, let’s use it
▸ "universal JavaScript"
▸ i.e. lodash
▸ build system, not runtime
▸ supports bundles (atomify, cssify, tsify)
▸ https://github.com/substack/browserify-handbook
- 17. REQUIRE IN THE BROWSER
BROWSERIFY
▸ static analysis (uses detective)
▸ creates Abstract Syntax Tree (AST)
- 18. REQUIRE IN THE BROWSER
BROWSERIFY
▸ injectable
▸ hot replace
▸ via beefy, wzrd, browserify-middleware, etc.
- 20. REQUIRE IN THE BROWSER
BROWSERIFY
▸ built in classes for Node in the browser
▸ transforms (CoffeeScript, TypeScript, CSS, images, etc)
▸ customizable browser fallback
- 21. NEW JS
ES6
▸ ECMAScript 2015
▸ No one calls it that except for standards people
▸ OOP: Yay, classes!
▸ Functional: Yay, new features!
▸ DevOps: Yay, static dependency tree!
▸ http://exploringjs.com/es6/ch_modules.html
- 25. EXAMPLE
ES6
Scripts Modules
HTML <script> <script type="module">
Top-Level variables are global local to module
Value of this at top level window undefined
Executed sync async
import statement no yes
Promise-based API yes yes
File extension .js .js
- 26. OTHER BENEFITS
ES6
▸ better cyclic dependencies
▸ module renaming on consumer
▸ import { name1 as localName1, name2 } from ‘src/my_lib';
▸ static initializer
▸ import 'src/my_lib';
- 27. LOADER OF EVERYTHING
WEBPACK
▸ better Require.js
▸ more features / API’s than Browserify
▸ built in vs. plugins/3rd party
▸ does that matter…?
▸ … only for ES6
▸ … AND RUNTIME
▸ https://webpack.github.io/
- 31. LOADER OF EVERYTHING
WEBPACK
▸ npm install webpack-dev-server -g
▸ webpack-dev-server —progress —colors
▸ Code Splitting: http://webpack.github.io/docs/code-splitting.html
- 32. LEVEL 1: BOILERPLATE
ES6-MODULE-LOADER
▸ programmatically work with modules
▸ configure module loading
▸ Loader: NOT part of the standard
▸ System: NOT part of the standard
▸ … both are expected to be
▸ https://github.com/ModuleLoader/es6-module-loader
- 36. LEVEL 2: FOR USAGE
SYSTEMJS
▸ Built on ES6-Module-Loader
▸ loads any module format (CommonJS, AMD, ES5, ES6, None)
▸ Supports RequireJS-style maps, paths, shims, etc.
▸ Loader plugin works with CSS, JSON, and Images
▸ Browser + Node
▸ Gallons of plugins like Browserify & Webpack have
- 37. LEVEL 2: FOR USAGE
SYSTEMJS
▸ Zebra Striping
▸ Modules
▸ Standalone
- 40. LEVEL 3: ALL YOU NEED
JSPM
▸ package manager for SystemJS
▸ called ES6 module loader (but you know better)
▸ loads from npm and Github
▸ dev == load, prod == standalone (or load)
▸ CLI for installing; use jspm instead of npm
▸ global registry
▸ http://jspm.io/
- 41. LEVEL 3: ALL YOU NEED
JSPM
▸ npm should work out of the box
▸ NodeJS libs for Browser are same as Browserify
▸ GitHub version is semvar
▸ package.json by default, or overridden by you
▸ flattens dependencies
- 42. LEVEL 3: ALL YOU NEED
JSPM
▸ improves package.js with new tags
- 44. DONE.
CONCLUSIONS
▸ JSPM should be all you need
▸ Will probably be standard
▸ Runtime + Build time
▸ All 3 libraries built-on top of each other
▸ supports 3 languages and all module formats