title: Use function Javascript on TWIG page using WebPack Encore and Symfony 4
body: <p>i'm using Symfony 4.2 and i use last WebPack Encore.</p>
  
  <p>I have issu because i need to use function from my javascript on my twig template, but this never work.</p>
  
  <p>I always have same problem: </p>
  
  <blockquote>
    <p>Uncaught ReferenceError: consoleText is not defined at (index):17</p>
  </blockquote>
  
  <p><strong>assets/js/app.js:</strong></p>
  
  <pre><code>require('../css/app.css');
  const $ = require('jquery');
  global.$ = global.jQuery = $;
  </code></pre>
  
  <p><strong>assets/js/myFunctions.js</strong></p>
  
  <pre><code>const consoleText = function (log = "Auncun log") {
  console.log(log);
  };
  
  module.exports = {
      consoleText: consoleText
  };
  </code></pre>
  
  <p><strong>webpack.config.js</strong></p>
  
  <pre><code>var Encore = require('@symfony/webpack-encore');
  
  Encore
      .setOutputPath('public/build/')
      .setPublicPath('/build')
      .addEntry('app', './assets/js/app.js')
      .enableSingleRuntimeChunk()
      .cleanupOutputBeforeBuild()
      .enableBuildNotifications()
      .enableSourceMaps(!Encore.isProduction())
      .autoProvidejQuery()
  ;
  
  module.exports = Encore.getWebpackConfig();
  </code></pre>
  
  <p>I need to get access to my function consoleText() outside my file.</p>
  
  <p>If i want to get access on javascript file, this work. Exemple: In my app.js i can add: </p>
  
  <pre><code>let myTest = require('./myFunctions');
  myTest.consoleText('Blablabla');
  </code></pre>
  
  <p>this work fine after compilation.</p>
  
  <p><strong>BUT i need to get access this function on my twig template (home.html.twig)</strong></p>
  
  <p>In my base.html.twig i called my script file with:</p>
  
  <pre><code>{% block javascripts %}
      {{ encore_entry_script_tags('app') }}
  
  
      // NEED HERE USE MY FUNCTION LIKE:
      {{ encore_entry_script_tags('myFunctions') }}
      &lt;script&gt;
          consoleText("This don't work");
      &lt;/script&gt;
  {% endblock %}
  </code></pre>
  
  <p>my consoleTest() function don't work and i don't understand why. I try to use Module.export, and tried to use lot of thinks but i don't know why i can't call my function on my twig template, so i need your help.</p>
  
  <p>Thank you</p>