I’m working onto a project in vue 2 and now we need to upgrade it to version 3. In this project we use an indispensable internal library, which was built by some people that left the company. And my problem is that i found a script that looks like this:
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.NProgress = factory();
}
})(this, function() { …
I found out that this is the syntax for an UMD module. This file I include in my index.html file. If i use console.log on the factory parameter, it outputs the function above. But if i use console.log on the root parameter it outputs undefined. In the old project with vue 2, it displays something. Why is this happening and how can i fix it? I also have multiple files that look like this and the problem is universal.
I also found out on the internet that i should use async or defer when i include the script but it didn't work. I'm also not that familiar with vite, I'm still researching.