philnash

joined 1 year ago
 

cross-posted from: https://programming.dev/post/11927506

Many times when I’ve tried to write some code in Node.js using ES modules I’ve found myself reaching for __dirname and then looking up how to replace it. Now Node.js, Deno and Bun support import.meta.dirname. Check out the article for more detail.

 

Many times when I’ve tried to write some code in Node.js using ES modules I’ve found myself reaching for __dirname and then looking up how to replace it. Now Node.js, Deno and Bun support import.meta.dirname. Check out the article for more detail.

[–] philnash@programming.dev 2 points 1 year ago

That’s brilliant!

[–] philnash@programming.dev 5 points 1 year ago (2 children)

JavaScript's regex engine isn't the only one to have these problems. There certainly are other implementations, like Re2 and Rust's implementation, that don't have this issue. But they also lack some of the features of the JS implementation too.

[–] philnash@programming.dev 6 points 1 year ago

While this article is about JavaScript specifically, these issues certainly exist in other regex engines too.

[–] philnash@programming.dev 4 points 1 year ago

Ah, I didn’t realise there was a regex channel here. Thanks!

 

This is a follow up to my previous article on how to get more TypeScript benefits in your JavaScript. This goes into how to add types using JSDoc or TypeScript declaration files.

view more: next ›