Skip to content

Instantly share code, notes, and snippets.

@matthewrobb
Created August 26, 2014 15:47
Show Gist options
  • Save matthewrobb/28ee13f11433131a28dc to your computer and use it in GitHub Desktop.
Save matthewrobb/28ee13f11433131a28dc to your computer and use it in GitHub Desktop.
module.setters = {};
var __es6__import__ = function(name, setter) {
require(name);
var resolvedPath = require.resolve(name);
require.cache[resolvedPath].dependants.push(module);
module.setters[resolvedPath] = setter;
};
module.dependants = [];
var __es6__export__ = (function() {
var values = Object.create(null), proxy = module.exports = Object.create(null);
return function(identifier, value) {
values[identifier] = value;
module.dependants.forEach(function(mod) {
mod.setters[module.filename](values);
});
if (!Object.getOwnPropertyDescriptor(proxy, identifier)) {
Object.defineProperty(proxy, identifier, {
enumerable: true,
get: function() {
return values[identifier];
}
});
}
return value;
}
})();
// export var bar;
var bar = __es6__export__("bar");
// bar = 99;
bar = __es6__export__("bar", 99);
module.setters = {};
var __es6__import__ = function(name, setter) {
require(name);
var resolvedPath = require.resolve(name);
require.cache[resolvedPath].dependants.push(module);
module.setters[resolvedPath] = setter;
};
module.dependants = [];
var __es6__export__ = (function() {
var values = Object.create(null), proxy = module.exports = Object.create(null);
return function(identifier, value) {
values[identifier] = value;
module.dependants.forEach(function(mod) {
mod.setters[module.filename](values);
});
if (!Object.getOwnPropertyDescriptor(proxy, identifier)) {
Object.defineProperty(proxy, identifier, {
enumerable: true,
get: function() {
return values[identifier];
}
});
}
return value;
}
})();
// import { bar } from "./bar";
var bar;
__es6__import__("./bar", function(m) {
bar = m.bar;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment