bowser-js / bowser

a browser detector
Other
5.44k stars 484 forks source link

Tree shaking causes error with Vite #511

Open JonathanMSifleet opened 2 years ago

JonathanMSifleet commented 2 years ago

Default example:

import Bowser from "bowser";
...
const browser = Bowser.getParser(window.navigator.userAgent);

console.log(`The current browser name is "${browser.getBrowserName()}"`);
// The current browser name is "Chrome"

With tree-shaking:

import { getParser } from "bowser";

const browser = getParser(window.navigator.userAgent);

console.log(`The current browser name is "${browser.getBrowserName()}"`);

Output: Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/bowser.js?v=8b59587e' does not provide an export named 'getParser'

vite: 2.9.1 bowser: 2.11.0