title: Bootstrap datepicker with Encore and Symfony4
body: <p>I think this is a easy one.</p>
  
  <p>I have a Symfony 4 application, with Webpack/Encore.</p>
  
  <p>I have installed bootstrap 4 and everything works fine; I am trying to install bootstrap-datepicker.</p>
  
  <p>So, I have created a file called <code>datepicker.js</code>, here is the content:</p>
  
  <pre><code>// js
  require('bootstrap-datepicker');
  require('../../../node_modules/bootstrap-datepicker/dist/locales/bootstrap-datepicker.it.min');
  
  // css
  require('../../../node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.css');
  
  'use strict';
  
  $(document).ready(function() {
      $('.datepicker').datepicker({
  
      });
  });
  </code></pre>
  
  <p>JQuery and Bootstrap is provided by another file, called <code>vendors.js</code>:</p>
  
  <pre><code>// js
  require('jquery');
  require('bootstrap');
  
  // scss
  require('../scss/vendors.scss');
  </code></pre>
  
  <p><code>vendors.js</code> is a shared entry. Here is the portion of my <code>webpack.config.js</code> file:</p>
  
  <pre><code>Encore
      ...
  
      // shared entries
      .createSharedEntry('vendors', [
          './assets/js/vendors.js'
      ])
  
      ...
  </code></pre>
  
  <p>On the page on I want to use datepicker I have the classic error:</p>
  
  <pre><code>jquery.js:3869 Uncaught TypeError: $(...).datepicker is not a function
  </code></pre>
  
  <p>Why am I wrong?</p>