Skip to content

Instantly share code, notes, and snippets.

@loganfsmyth
loganfsmyth / .babelrc
Created December 1, 2017 23:16
Short description of Babel's config merge for `.env`
{
sourceMaps: false,
comments: false,
plugins: [
["plg-one", {}],
["plg-two", {opt: false}],
],
env: {
development: {
sourceMaps: true,
@loganfsmyth
loganfsmyth / README.md
Last active November 15, 2017 06:29
babel plugin invalidation example

For explanation, essentially we'd generate a cache UUID based on cacheKey of your entire Babel config data and on all the plugin's cacheKeys, along with other stuff like the plugin options. Then we can take that cache key and fetch the cached data from wherever.

Each function in the cached block will be wrapped with logic to record the inputs and outputs, and the data will be stored in the output cacheable data. After a transform, we'd write Babel's normal output object, plus the data from the calls to the cached functions, and write it to some cache storage backend based on the final overall cacheKey.

When loading data from cache, we'll load the config and build the key as usually, and then before transforming anything, we try to load from the cache based on the config's key. Once the data is loaded from the cache, Babel itself will replay each call to a cached function, based on whatever the previous cached result had done. If they return matching values, we'll consider it a cache hit.

This s

const query = `SELECT \`id\` FROM foo;`;
@loganfsmyth
loganfsmyth / use-strict-loader.js
Created January 20, 2015 02:12
Webpack 'use-strict' loader
var OriginalSource = require('webpack/lib/OriginalSource');
module.exports = function(source, map){
var identifier = this._module.identifier();
this.cacheable();
var origMap = this.sourceMap ? new OriginalSource(source, identifier, map) : null;
var strictPrefix = '"use strict";\n';
@loganfsmyth
loganfsmyth / BackboneEventsExample.js
Last active December 17, 2015 15:18
Some basic examples of using jQuery vs using Backbone.Native.
events: {
'click .child': 'clickChildEvent'
},
// With jQuery
clickChildEvent: function(event){
$(event.currentTarget).toggleClass('clicked');
},
// With Backbone.Native
@loganfsmyth
loganfsmyth / about.md
Created August 19, 2011 12:34 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer