Skip to content

modules: add import.meta.__dirname and import.meta.__filename

To help ease the transition from existing CommonJS code to ESM, adds convenience properties to import.meta that are explicitly marked "Legacy" in the documentation.

This may or may not be a good idea, but I've run into this enough times that I figured I'd at least see. If folks don't think this is a good idea, then I'm fine with it not landing.

const {
  __filename,
  __dirname,
} = import.meta;

They are only available when file:// modules are used.

Merge request reports

Loading