sindresorhus/open

esm support

Closed this issue · 2 comments

Hi,

I have trouble to using open in my Node esm library because it relies on __dirname.

// Path to included `xdg-open`.
const localXdgOpenPath = path.join(__dirname, 'xdg-open');

At runtime I get following issue:

ReferenceError: __dirname is not defined in ES module scope

Is there a way to polyfill it to support both cjs and esm?

Awesome, works like a charm. Thanks!