title: Rails: Accessing JS module methods from files served by webpacker
body: <h3>Context</h3>
  
  <p>I try to move assets in our application to webpack using Webpacker gem. Application is very big, so I need to do it partially.</p>
  
  <h3>What did so far...</h3>
  
  <p>I successfully managed to call the script using <code>javascript_pack_tag</code></p>
  
  <p>I export a super simple module:</p>
  
  <pre><code># javascript/src/javascript/test.js'
  const Direction = {
    log_to_console: function(){
      console.log('test');
    }
  };
  export default Direction;
  </code></pre>
  
  <p>Then import it in the application entry point</p>
  
  <pre><code># javascript/packs/application.js
  import Test from '../src/javascript/test.js'
  Test.log_to_console();
  </code></pre>
  
  <p>Finally rendering it in the layout:</p>
  
  <pre><code># app/views/application.slim
  = javascript_include_tag 'application'
  </code></pre>
  
  <p>The result is: "Test" string visible in the browser console.</p>
  
  <h3>The problem</h3>
  
  <p>Currently in the whole application we use Modules in views like this:</p>
  
  <pre><code># app/views/assets/javascripts/test.coffee
  log_to_console = -&gt;
    console.log('test');
  @Test = { log_to_console }
  
  # app/views/some/template.slim
  javascript:
    Test.log_to_console()
  </code></pre>
  
  <p>But after moving module to webpack I can't access the <code>Test</code> module anymore.</p>
  
  <p>So my question is: </p>
  
  <p>How to configure <code>webpacker</code> gem OR refactor the code above to make the <code>log_to_console()</code> method available in views/browser inspector? </p>
  
  <p>Ideally it would be if we could also access them in old javascript files compiled by sprockets. </p>