const loaderUtils = require('loader-utils');

module.exports = function(source, map) {
  const options = loaderUtils.parseQuery(this.query);
  const moduleId = options.moduleId;
  this.cacheable();

  const newSource = source + `
import {Origin} from 'aurelia-metadata';
for (var exportName in module.exports) {
  Origin.set(module.exports[exportName], new Origin(${JSON.stringify(moduleId)}, exportName));
}`;

  this.callback(null, newSource, map);

  if (options.debug) {
    console.log('changed source query', options);
  }
}

@@ -237,16 +237,28 @@
  %7BOrigin
+ as __au_o__
 %7D from '
@@ -319,22 +319,24 @@
 ts) %7B%0A  
-Origin
+__au_o__
 .set(mod
@@ -364,22 +364,24 @@
 e%5D, new 
-Origin
+__au_o__
 ($%7BJSON.

switch to a more unique variable name