Skip to content

Instantly share code, notes, and snippets.

Guy Bedford guybedford

Block or report user

Report or block guybedford

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
guybedford /
Last active Jun 18, 2019
ES Module WASI Integration Concerns
guybedford / dirserver.js
Last active Sep 26, 2018
Directory serving
View dirserver.js
* Adapted from node-ecstatic by Joshua Holbrook:
const fs = require('graceful-fs');
const path = require('path');
const he = require('he');
const perms = ['---', '--x', '-w-', '-wx', 'r--', 'r-x', 'rw-', 'rwx'];
View SystemJS Config Conflict Detection.js
// meta, packages deep
function getSharedProperties(configA, configB) {
var bKeys = Object.keys(configB);
return Object.keys(configA).filter(function(p) {
return bKeys.indexOf(p) != -1;
function detectMetaConflict(metaA, metaB) {
guybedford / gist:a1155602a0ff41b22359
Last active Aug 29, 2015
Interpreting CommonJS modules in ES6 environments
View gist:a1155602a0ff41b22359

Question - should import {fs} from 'fs' be supported for CommonJS module loading from ES6?

If it is to be supported, we would effectively define the fs module object in the ES6 registry to look something like the following:

var fs = require('fs');
var _fs = {};
Object.keys(fs).forEach((p) => _fs[p] = fs[p]);
_fs.default = fs;
guybedford / build-exclusions.js
Created Jul 11, 2014
System build exclusions
View build-exclusions.js
var firstTree, secondTree;
builder.trace('app/first', config)
.then(function(trace) {
firstTree = trace.tree;
return builder.trace('app/second');
.then(function(trace) {
secondTree = trace.tree;
return builder.subtractTrees(firstTree, secondTree);
View extension-register.js
// our side table
// registry = { deps, declare ; normalizedDeps, depMap ; execute, exports }
// Lifecycle:
// 1. before instantiate, just deps, declare
// 2. after instantiate, normalizedDeps and depMap
// 3. after linking, execute, exports
// 4. after partial tree execution just exports
// 5. after full tree execution, removed from registry
var registry = {};
guybedford /
Last active Nov 21, 2017
ES6 Module Spec Proposal - Deferred Execution and Instantiate Normalization

Key Issues

1. No Deferred Execution for Dynamic Modules

It can be quite confusing to new users that:

<module name="test">
  define(function() {


  1. Support source maps
  2. Plugin-based compilation
  3. Perform compilation in memory, not file system.

Key Innovation: Use source map information to determine which changed files result in which files having to be rebuilt.

Source Maps and this innovation concept is why I'm even considering polluting this noisy space even further!

guybedford / system-steal-plugin.js
Last active Jan 1, 2016
Steal Modularity Example for SystemJS
View system-steal-plugin.js
// add the steal format as the first priority check
// create the steal format detection
var stealRegEx = /(?:^\s*|[}{\(\);,\n\?\&]\s*)steal\s*\(\s*((?:"[^"]+"\s*,|'[^']+'\s*,\s*)*)/;
System.format.steal = {
detect: function(source, load) {
var match = source.match(stealRegEx);
if (match)
return match[1] ? eval(match[1].substr(0, match[1].lastIndexOf(','))) : [];
guybedford / server.js
Last active Dec 26, 2015
SPDY asset server API
View server.js
var spdy = require('spdy'); // node-spdy
var spdyAssetServer = require('spdy-asset-server'); // the proposed spdy-asset-server library
// given a url, provide the asset response stream
// custom serving function allows dynamic + static assets
var assetServer = new spdyAssetServer(function(url, stream) {
if (url == 'style/style.css')
else if (url == 'style/style.less')
You can’t perform that action at this time.