title: How to append a file to a bundle in Webpack, or inject required code?
body: <p>I'm trying to build a plugin that <strong>injects a module/file into the client bundle.</strong></p>
  
  <p>An entry config might look like:</p>
  
  <pre><code>entry: {
    'main': [
      'some-stuff'
    ],
  }
  </code></pre>
  
  <p>And I want to use my plugin like:</p>
  
  <pre><code>function SomePlugin(options) {
      this.entryToAppendTo = options.entryToAppendTo
  }
  
  ...
  
  plugins: [
    new SomePlugin({ entryToAppendTo: 'main' })
  ]
  </code></pre>
  
  <p>In my plugin I want to require that file as if it were done in Webpack itself, something like:</p>
  
  <pre><code>SomePlugin.prototype.apply = function(compiler) {
  
      compiler.plugin( 'emit', function( compilation, callback ) {
  
          var additionalModule = 'my-module?some-stuff=' + Date.now();
          // how to add this to the specified entry?
  
      })
  
  });
  </code></pre>
  
  <p>Note that I'm passing a dynamic query string, which is why i'm aiming to do this in a plugin.</p>
  
  <p>I want to append a file to the bundle, or somehow inject it into the client bundle. I've tried adding it to <code>compilation.assets</code> <a href="https://gist.github.com/thatismatt/519d11b2c902791bb74b#file-blah-plugin-js-L26-L33" rel="nofollow noreferrer">as shown here</a> but it doesn't go into the actual bundle. I've also tried adding a child compiler <a href="https://stackoverflow.com/a/30344170/743464">as demonstrated in this question</a> but same problem.</p>