sindresorhus / open

Open stuff like URLs, files, executables. Cross-platform.
MIT License
3.14k stars 213 forks source link

esm support #302

Closed peterpeterparker closed 1 year ago

peterpeterparker commented 1 year ago

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?

sindresorhus commented 1 year ago

Done: https://github.com/sindresorhus/open/releases/tag/v9.0.0

peterpeterparker commented 1 year ago

Awesome, works like a charm. Thanks!