title: Is it possible to import JS function into a js.erb file?
body: <p>Is it possible to import a JS function to be used in a <code>js.erb</code> file?</p>
  
  <p>For example:</p>
  
  <pre><code>// hello_world.js
  const helloWorld = () =&gt; console.log('hello world');
  export default helloWorld;
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>// our_file.js.erb
  import helloWorld from 'path/to/hello_world.js';
  
  helloWorld();
  </code></pre>
  
  <p>I've had a pop at it and can't get it firing, so presume the answer is no - will happily accept a one word answer if this is indeed the case.</p>
  
  <p>If not, how does one go about getting this working? Thanks in advance for all help / constructive criticism / mockery.</p>
  
  <hr>
  
  <p><strong>Edit</strong></p>
  
  <p>I'm not sure the suggested duplicate <em>is</em> a duplicate of this - I'm specifically looking to import a function, not load an entire script into the DOM. Is this possible?</p>