This might be really obvious but i've not come across the problem yet and i'm not sure what to search to fix it. I am using webpack and gulp, and i've ran into a bit of a problem when it comes to including external js plugins.
Using this one as an example JQuery Vegas.
I want to use the package via npm, but the issue is that the plugin itself doesn't export as a module to just require it and use it. The only way of including it is importing the whole file and just including it in my javascript file, essentially like copying and pasting the plugin code inside my js
file.
import "vegas";
The code is included in my js file, I can see its there when I inspect the compiled file in my developer tools. The issue comes with webpack requiring functions to be declared on the window
(Basic webpack not working for button click function - Uncaught Reference error: undefined)
As the function inside the npm package is not declared on the window
object, I always get function is undefined
. What is the best way to include npm code (that is not exported as a module) into my file that is compiled using webpack?