Closed Augensternhx closed 1 year ago
Hey, @Augensternhx , thanks for reaching out. What is the UMD version used for? This package exports both CommonJS and ES module, what is the use case you need here?
https://github.com/omrilotan/isbot/blob/main/package.json#L24-L41
When I use this in my browser
I will get tips like this
Uncaught ReferenceError: module is not defined
It looks like there is a lack of UMD version, here is the introduction about UMD
If you use rollup, this is a simple example
{
input: './demo.js',
output: {
file: './demo.min.js',
format: 'umd',
}
}
if I understand correctly, you want "isbot" to be made available as a global variable once you include this script tag in your page. I'm not the one publishing to jsdeliver network, but you can use this script from their CDN as a module:
<!doctype html>
<html>
<body>
<div></div>
<script type="module">
import isbot from "https://cdn.jsdelivr.net/npm/isbot@3.6.6/index.min.mjs";
const is = isbot(navigator.userAgent);
document.querySelector("div").innerText = `User agent: "${navigator.userAgent}" is ${is ? "" : "not "}a bot`;
</script>
</body>
</html>
https://jsfiddle.net/omrilotan/geud63of/
Is this satisfactory?
type="module"
This only works with modern browsers,This is not an effective solution
I did not create a global variable entry, but I'm open to pull requests if you are very interested. At the moment, I assume most users will bundle the package when building their project, and global variable entries are not usually needed.
Let me know what you think of this resolution: https://github.com/omrilotan/isbot/pull/205
Steps to reproduce
Expected behaviour
Actual behaviour
Additional details