title: Cannot Require Popper with Webpack
body: <p>I'm attempting to move my javascript files to Webpack. I'm not very familiar with Webpack so I am not sure that I have coded any of this correctly. I am trying to load jquery-ui, popper, and bootstrap 4. However, I am getting an error when requiring <code>Popper</code>. Please note that I am using the Wepacker gem for Ruby on Rails.</p>
  
  <p>I have included the following code in my environment.js file to include jQuery automatically in each file. </p>
  
  <pre><code>const { environment } = require('@rails/webpacker')
  
  const webpack = require('webpack')
  environment.plugins.append('Provide', new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery'
  }))
  
  module.exports = environment
  </code></pre>
  
  <p>This part works. So, from there I ran <code>yarn add jquery-ui</code>.</p>
  
  <p>Then in my /pack/application.js file I included <code>require('jquery-ui')</code>. </p>
  
  <p>From my js file the following code prints to my console:</p>
  
  <pre><code>$(document).ready(function(){
      if (jQuery.ui) {
        console.log("loaded");
      }
  });
  </code></pre>
  
  <p>After this I tried installing and requiring <code>popper</code> with <code>yarn add popper</code>. </p>
  
  <p>Then calling popper from inside my <code>document.ready</code> function I get an error:</p>
  
  <pre><code>$(document).ready(function(){
  
      console.log(window.Popper)
  
  });
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
  SyntaxError: /home/ubuntu/environment/node_modules/path-platform/path.js: 'return' outside of function (32:2)
  
    30 | if (_path.posix) {
    31 |   module.exports = _path;
    32 |   return;
       |   ^
    33 | }
    34 | 
    35 | // resolves . and .. elements in a path array with directory names there
      at Parser.raise (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:6420)
      at Parser.parseReturnStatement 
  (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10370)
      at Parser.parseStatementContent 
  (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10057)
      at Parser.parseStatement (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10009)
      at Parser.parseBlockOrModuleBlockBody 
  (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10585)
      at Parser.parseBlockBody (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10572)
      at Parser.parseBlock (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10556)
      at Parser.parseStatementContent 
      (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10085)
      at Parser.parseStatement (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10009)
      at Parser.parseIfStatement 
      (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10363)
      at Parser.parseStatementContent 
      (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10054)
      at Parser.parseStatement (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10009)
      at Parser.parseBlockOrModuleBlockBody 
      (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10585)
  at Parser.parseBlockBody (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:10572)
  at Parser.parseTopLevel (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:9940)
  at Parser.parse (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:11447)
  at parse (home/ubuntu/environment/node_modules/@babel/parser/lib/index.js:11483)
  at parser (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/normalize-file.js:168)
  at normalizeFile (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/normalize-file.js:102)
  at runSync (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/index.js:44)
  at runAsync (home/ubuntu/environment/node_modules/@babel/core/lib/transformation/index.js:35)
  at process.nextTick (home/ubuntu/environment/node_modules/@babel/core/lib/transform.js:34)
  at process._tickCallback (internal/process/next_tick.js:61)
  at Object../node_modules/path-platform/path.js (index.js:82)
  at __webpack_require__ (bootstrap:19)
  at Object.&lt;anonymous&gt; (index.js:1)
  at Object../node_modules/parents/index.js (index.js:39)
  at __webpack_require__ (bootstrap:19)
  at Object.&lt;anonymous&gt; (index.js:19)
  at Object../node_modules/module-deps/index.js (index.js:623)
  at __webpack_require__ (bootstrap:19)
  at Object.&lt;anonymous&gt; (index.js:3)
  at Object../node_modules/browserify/index.js (index.js:846)
  </code></pre>
  
  <p>Here is my pack/application.js file</p>
  
  <pre><code>require("@rails/ujs").start()
  require("@rails/activestorage").start()
  
  require('jquery-ui')
  require('popper')
  </code></pre>