Skip to content

Instantly share code, notes, and snippets.

@tyscorp
Created April 18, 2016 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyscorp/72d2cb065fdd9079dd1e709e172e4634 to your computer and use it in GitHub Desktop.
Save tyscorp/72d2cb065fdd9079dd1e709e172e4634 to your computer and use it in GitHub Desktop.
React HMR SystemJS experiment
'use strict';
exports.translate = function(load) {
var prependText =
`
var __export = eval('_export');
var hotExport = function(name, exported) {
if (!Object.prototype.hasOwnProperty.call(exported, '__source')) {
Object.defineProperty(exported, '__source', {
enumerable: false,
configurable: true,
value: {
fileName: '${load.name}',
exportName: name
}
});
}
return __export(name, exported);
};
eval('_export = hotExport');
`;
return prependText + load.source;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment