r.js optimizer skips define(factory(root)) rewriting. Changing this to define([], factory(root)) fixes it