@@ -332,6 +332,35 @@ modules it can be used to load ES modules.
332332The ` import.meta ` meta property is an ` Object ` that contains the following
333333properties.
334334
335+ ### ` import.meta.dirname `
336+
337+ <!-- YAML
338+ added: REPLACEME
339+ -->
340+
341+ > Stability: 1.2 - Release candidate
342+
343+ * {string} The directory name of the current module. This is the same as the
344+ [ ` path.dirname() ` ] [ ] of the [ ` import.meta.filename ` ] [ ] .
345+
346+ > ** Caveat** : only present on ` file: ` modules.
347+
348+ ### ` import.meta.filename `
349+
350+ <!-- YAML
351+ added: REPLACEME
352+ -->
353+
354+ > Stability: 1.2 - Release candidate
355+
356+ * {string} The full absolute path and filename of the current module, with
357+ * symlinks resolved.
358+ * This is the same as the [ ` url.fileURLToPath() ` ] [ ] of the
359+ * [ ` import.meta.url ` ] [ ] .
360+
361+ > ** Caveat** only local modules support this property. Modules not using the
362+ > ` file: ` protocol will not provide it.
363+
335364### ` import.meta.url `
336365
337366* {string} The absolute ` file: ` URL of the module.
@@ -526,7 +555,7 @@ If needed, a `require` function can be constructed within an ES module using
526555These CommonJS variables are not available in ES modules.
527556
528557`__filename` and `__dirname` use cases can be replicated via
529- [`import.meta.url `][].
558+ [`import.meta.filename`][] and [`import.meta.dirname `][].
530559
531560#### No Addon Loading
532561
@@ -1107,13 +1136,17 @@ resolution for ESM specifiers is [commonjs-extension-resolution-loader][].
11071136[` data: ` URLs]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
11081137[` export ` ]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
11091138[` import ()` ]: #import-expressions
1139+ [` import .meta .dirname ` ]: #importmetadirname
1140+ [` import .meta .filename ` ]: #importmetafilename
11101141[` import .meta .resolve ` ]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve
11111142[` import .meta .url ` ]: #importmetaurl
11121143[` import ` ]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
11131144[` module .createRequire ()` ]: module.md#modulecreaterequirefilename
11141145[` module .syncBuiltinESMExports ()` ]: module.md#modulesyncbuiltinesmexports
11151146[` package .json ` ]: packages.md#nodejs-packagejson-field-definitions
1147+ [` path .dirname ()` ]: path.md#pathdirnamepath
11161148[` process .dlopen ` ]: process.md#processdlopenmodule-filename-flags
1149+ [` url .fileURLToPath ()` ]: url.md#urlfileurltopathurl
11171150[cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/1.2.2
11181151[commonjs-extension-resolution-loader]: https://github.com/nodejs/loaders-test/tree/main/commonjs-extension-resolution-loader
11191152[custom https loader]: module.md#import-from-https
0 commit comments