Skip to content

Tree shaking causes error with Vite #511

@JonathanMSifleet

Description

@JonathanMSifleet

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions