title: Require third party RequireJS modules with Webpack
body: <p>I'm working on an application that needs to pull in the <a href="https://github.com/readium/readium-js" rel="nofollow">ReadiumJS</a> library, which uses AMD modules. The app itself is written in es6 w/ webpack and babel. I've gotten the vendor bundle working correctly, and it's pulling in the built Readium file, but when I try to require any of the modules Webpack says it can't resolve them. Anyone ever do this before with Webpack and RequireJS? Here's some info that may help - not sure what else to include as this is my first time really using Webpack..</p>
  
  <p><strong>Folder Structure</strong></p>
  
  <pre><code>/readium-src
    /readium-js
      / *** all readium-specific files and build output (have to pull down repo and build locally)
  /node_modules
  /src
    /app.js -&gt; main entry for my app
  </code></pre>
  
  <p>/webpack.config.babel.js</p>
  
  <p><strong>webpack.config.js entries</strong></p>
  
  <pre><code>entry: {
      vendorJs: [
          'jquery',
          'angular',
          '../readium-src/readium-js/build-output/_single-bundle/readium-js_all.js',
          'bootstrap/js/alert.js' //bootstrap js example
      ],
      appJs: './app.js'
  }
  </code></pre>
  
  <p><strong>Trying to require it in app.js</strong></p>
  
  <pre><code>var readiumSharedGlobals = require('readium_shared_js/globals');
  </code></pre>
  
  <p>I never really got into using RequireJS, so really struggling to understand how to consume that type of module along side other types of modules with webpack. Any help greatly appreciated :)</p>
  
  <p><strong>Update</strong></p>
  
  <p>If I change my app.js to use this instead:</p>
  
  <pre><code>window.rqReadium = require('../readium-src/readium-js/build-output/_single-bundle/readium-js_all.js');
  </code></pre>
  
  <p>Then it appears to try to load all the modules, but I get a strange error:</p>
  
  <pre><code>Uncaught Error: No IPv6
  </code></pre>
  
  <p>At this point, I'm unsure of</p>
  
  <ol>
  <li>Should I have to require the entire path like that?</li>
  <li>Is this error something from webpack, requirejs, or Readium? Tried debugging, but couldn't find anything useful...</li>
  </ol>
  
  <p><strong>UPDATE 8/12/2016</strong></p>
  
  <p>I think this is related to an issue with a library that Readium is depending on: <a href="https://github.com/medialize/URI.js/issues/118" rel="nofollow">https://github.com/medialize/URI.js/issues/118</a></p>
  
  <p>However, I'm still not clear on how to correctly import AMD modules with webpack. Here's what I mean:</p>
  
  <p>Let's say I have an amd module defined in <em>moneyService.amd.js</em> like this:</p>
  
  <pre><code>define('myMoneyService', ['jquery'], function($) {
      //contrived simple example...
      return function getDollaz() { console.log('$$$'); }
  });
  </code></pre>
  
  <p>Then, in a sibling file, <em>app.js</em>, I want to pull in that file.</p>
  
  <pre><code>//this works
  var getDollaz = require('./moneyService.amd.js');
  
  //this works
  require(['./moneyService.amd.js'], function(getDollaz) { getDollaz(); }
  
  //this does not
  require(['myMoneyService' /*require by its ID vs file name*/], function(getDollaz) {
      getDollaz(); 
  }
  </code></pre>
  
  <p>So, if we cannot require named modules, how would we work with a third party lib's dist file that has all the modules bundled into a single file?</p>