How to stop babel from transpiling 'this' to 'undefined' (and inserting "use strict")
<p><strong>EDIT</strong>: This is <strong>not about fat arrows</strong>. It's also not about passing <em>this</em> to an <strong>IIFE</strong>. It's a transpiler-related question.</p>

<p>So I've created a simple pub-sub for a little app I'm working on. I wrote it in ES6 to use spread/rest and save some headaches. I set it up with npm and gulp to transpile it but it's driving me crazy.</p>

<p>I made it a browser library but realized it could be used anywhere so I decided to make it Commonjs and AMD compatible.</p>

<p>Here's a trimmed down version of my code:</p>

<pre><code>(function(root, factory) {
 if(typeof define === 'function' &amp;&amp; define.amd) {
    define([], function() {
        return (root.simplePubSub = factory())
    });
  } else if(typeof module === 'object' &amp;&amp; module.exports) {
    module.exports = (root.simplePubSub = factory())
  } else {
    root.simplePubSub = root.SPS = factory()
  }
}(this, function() {
 // return SimplePubSub
});
</code></pre>

<p>But no matter what I try (such as making <em>this</em> a variable and passing it) it sets it to <em>undefined</em>.</p>

<pre><code>}(undefined, function() {
</code></pre>

<p>It probably has something to do with Babel not knowing what <em>this</em> will be and transpiling it away but is there any other approach I can take?</p>

<p><strong>UPDATE</strong>: Passing <code>}((window || module || {}), function() {</code> instead of <em>this</em> seems to work. I'm not sure this is the best approach though.</p>