import, require and include hate for JS

Preamble: next time I will read words like "easy" or "simple" in a Javascript package manager presentation page, I will look for the maintainer's home address and will dump a full load of shit in front of his door.

Recently, I started to adopt Laravel Mix to build assets included in my works. Given that collecting a bunch of JS files into a folder and handling them with Minify is way easier, after a few weeks I still insist in this onanist exercise.

Today I've learned a fundamental lesson, to be shared here for later reference. I had to import TempusDominus datepicker library: I've npm'd it, import'd in my app.js file, npm run dev'd all together, and it insisted about missing Moment.js library. I've import'd and require'd it in all ways, but none of them worked.

In the end, I ended up modifying my webpack.mix.js file (mostly stackoverflowed, of course) like this:

    jquery: ['$', 'window.jQuery', 'jQuery'],
    'popper.js/dist/umd/popper.js': ['Popper'],
    'moment/moment.js': ['moment'],           // THIS LINE ADDED
], 'public/js/app.js')
.sass('resources/assets/sass/app.scss', 'public/css/app.css');

I've no idea of what it means, but it works.