- 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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, | |
})} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
'', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |