title: Import select2 with parcel.js
body: <p>Pardon my lack of knowledge as I'm very new to web development.</p>
  <p>I'm trying to bundle up all 3rd party packages, which includes <code>select2</code> among others.
  The bundle works for the other packages like jquery, bootstrap, popper etc, but <code>select2</code> is not initialized or something. Perhaps some loading order issue?</p>
  <p>Calling <code>$('select').select2()</code> results in uncaught type error.
  Loading it separately via cdn or manual download works, so it seems parcel is not doing something right?</p>
  <p>This is pretty much a very &quot;boilerplatey&quot; setup, so it's easy to replicate, but this is what I'm currently trying it on:</p>
  <pre><code>File structure:
  - node_modules
  - index.html
  - .sassrc       # sass configuration
  - assets/       # front end assets root
    - scss/       # Place for all styles
      - site.scss
    - js/         # Place for all scripts
      - site.js
    - bundle.js   # Entry point for output bundle
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>// bundle.js
  import './scss/site.scss';
  import $ from 'jquery';
  window.$ = window.jQuery = $;
  import 'bootstrap';
  import 'select2';
  </code></pre>
  <pre class="lang-css prettyprint-override"><code>/* site.css */
  @import &quot;bootstrap/scss/bootstrap&quot;;
  @import &quot;select2/dist/css/select2&quot;;
  @import &quot;@ttskch/select2-bootstrap4-theme/dist/select2-bootstrap4&quot;;
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;!-- index.html --&gt;
  &lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;title&gt;Document&lt;/title&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;wwwroot/dist/bundle.css&quot;&gt;
    &lt;script src=&quot;wwwroot/dist/bundle.js&quot;&gt;&lt;/script&gt;
  &lt;/head&gt;
  </code></pre>
  <p>And lastly</p>
  <pre><code>// package.js to show dependencies and the build script
  {
    &quot;name&quot;: &quot;SideNav&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;main.js&quot;,
    &quot;scripts&quot;: {
      &quot;build&quot;: &quot;parcel build assets/bundle.js --out-dir wwwroot/dist/&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;@ttskch/select2-bootstrap4-theme&quot;: &quot;^1.3.5&quot;,
      &quot;bootstrap&quot;: &quot;^4.6.0&quot;,
      &quot;jquery&quot;: &quot;^3.5.1&quot;,
      &quot;popper.js&quot;: &quot;^1.16.1&quot;,
      &quot;select2&quot;: &quot;^4.0.13&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;parcel-bundler&quot;: &quot;^1.12.4&quot;,
      &quot;sass&quot;: &quot;^1.32.5&quot;
    }
  }
  </code></pre>
  <p>Thanks in advance to everyone helping out.</p>