title: How do you require local Javascript files with Rails 6 / webpacker?
body: <p>So this seems like a simple question but I can't manage to find any links about it.</p>
  <p>I am using coffee-rails and have a file <code>app/javascript/packs/post_form.js.coffee</code>. I am including it in my HTML page via <code>javascript_pack_tag 'post_form'</code>.</p>
  <p>The question is, how do I load a dependent JS file from here? I tried putting inside <code>post_form.js.coffee</code>:</p>
  <pre><code>HelperFunctions = require(&quot;lib/helper_functions&quot;)
  </code></pre>
  <p>And then in <code>app/javascript/lib/helper_functions.js.coffee</code>:</p>
  <pre><code>module.exports = {
    UsefulMethod: -&gt; console.log(&quot;I'm helpful!&quot;)
  }
  </code></pre>
  <p>I'm getting</p>
  <p><strong>&gt; Cannot find module 'lib/helper_functions'</strong></p>
  <p>My <code>config/webpack/environments.js</code> file is as follows:</p>
  <pre><code>const { environment } = require('@rails/webpacker')
  const coffee =  require('./loaders/coffee')
  
  const webpack = require('webpack')
  environment.plugins.prepend('Provide', new webpack.ProvidePlugin({
    $: 'jquery/src/jquery',
    jQuery: 'jquery/src/jquery',
    jquery: 'jquery',
    'window.jQuery': 'jquery',
    Popper: ['popper.js', 'default']
  }))
  
  
  environment.loaders.prepend('coffee', coffee)
  module.exports = environment
  </code></pre>