- create a compiler
- apply options / configuration
- apply plugins listed in options
- add all other plugins based on options / configuration
- example plugin: commonjsplugin
- define dependency module factories
- define dependency templates
- plugin parser to create commonjs dependencies
- run the compiler
- create module factories
View in-order-unique-union.js
const a = ['a', 'b', 'c', 'd', 'e']; | |
const b = ['b', 'f', 'a', 'g', 'e']; | |
const table = {}; | |
const d = []; | |
var isEqual = (a, b) => { | |
if (a.length === b.length) { | |
let isEqual = true; | |
for (let i = 0; isEqual && i < a.length; ++i) { | |
isEqual = a[i] === b[i]; |
View ranimated-element.js
<RAnimated name={name} | |
elements={{root: 'root'}} | |
// Build a animation state from the element | |
update={update.object({ | |
x: element => element.getBoundingClientRect().left, | |
y: element => element.getBoundingClientRect().top, | |
width: element => element.getBoundingClientRect().width, | |
height: element => element.getBoundingClientRect().height, | |
opacity: () => 1, | |
})} |
View inline-css-html-webpack-plugin.js
const Entities = require('html-entities').AllHtmlEntities; | |
const htmlEntities = new Entities(); | |
class InlineCssHtmlWebpackPlugin { | |
apply(compiler) { | |
compiler.plugin('compilation', compilation => { | |
compilation.plugin('html-webpack-plugin-before-html-processing', (htmlPluginData, callback) => { | |
for (let filename of htmlPluginData.assets.css) { | |
const cssSrc = compilation.assets[filename]; |
View diff.js
// Create a difference of entries in an object when that object | |
// does not equal the new value shallowly. | |
// | |
// Example: | |
// a0 = {a: {b: {c: 3}, d: 4}}; a1 = {a: {b: a0.a.b, d: 5}}; | |
// diff(a0, a1) = {a: {d: 5}}; | |
const diff = (a, b) => { | |
let o; | |
if (a !== b) { |
View tessel-spi-neopixels.js
// Import the interface to Tessel hardware | |
var tessel = require('tessel'); | |
var port = tessel.port.A; | |
var spi = new port.SPI({ | |
clockSpeed: 3.2*1000*1000, // 3.2MHz | |
cpol: 0, // Polarity - optional | |
cpha: 0, // Clock phase - optional | |
chipSelect: port.pin[7] // Chip select - optional |
View tessel-api-mockup.rs
// | |
// Examples | |
// | |
mod examples { | |
fn main() { | |
// Different ways to get a single pwm pin. | |
// | |
// These earlier ones are a bit wasteful as they also create the leds |
View 00.script-async-attr-support-plugin.js
function ScriptAsyncAttrSupportPlugin() {} | |
module.exports = ScriptAsyncAttrSupportPlugin; | |
ScriptAsyncAttrSupportPlugin.prototype.apply = function(compiler) { | |
compiler.plugin('this-compilation', function(compilation) { | |
compilation.mainTemplate.plugin('bootstrap', function(source) { | |
return this.asString([ | |
source, | |
'', |
View depth-first-post-plugin.js
function DepthFirstPostPlugin() {} | |
module.exports = DepthFirstPostPlugin; | |
DepthFirstPostPlugin.prototype.apply = function(compiler) { | |
compiler.plugin('compilation', function(compilation) { | |
compilation.plugin('optimize-chunk-order', function(chunks) { | |
var checked = {}; | |
function walk(chunk) { | |
var nextIndex = 0; |
View build-step-time-webpack-plugin.js
// Drop this in as the first plugin in a webpack config | |
{ | |
apply: function(compiler) { | |
var start; | |
compiler.plugin(['watch-run', 'run'], function(compiler, cb) { | |
start = Date.now(); | |
cb(); | |
}); | |
compiler.plugin('make', function(compilation, cb) { | |
console.log('pre-make', Date.now() - start); |
View webpack-bullets.md