Skip to content

Commit

Permalink
Fix jzz import in Node when ESm is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Philippe Côté committed Nov 23, 2023
1 parent d63f42e commit 8d36d95
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/WebMidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,12 @@ class WebMidi extends EventEmitter {
try {
window.navigator;
} catch (err) {
global.navigator = await Object.getPrototypeOf(async function() {}).constructor(`
let jzz = await Object.getPrototypeOf(async function() {}).constructor(`
let jzz = await import("jzz");
return jzz.default;
`)();
if (!global.navigator) global.navigator = {}; // for Node.js prior to v21
Object.assign(global.navigator, jzz);
}

// The `performance` module appeared in Node.js v8.5.0 but has started to be automatically
Expand Down

0 comments on commit 8d36d95

Please sign in to comment.