@@ -332,6 +332,35 @@ modules it can be used to load ES modules.
332
332
The ` import.meta ` meta property is an ` Object ` that contains the following
333
333
properties.
334
334
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
+
335
364
### ` import.meta.url `
336
365
337
366
* {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
526
555
These CommonJS variables are not available in ES modules.
527
556
528
557
`__filename` and `__dirname` use cases can be replicated via
529
- [`import.meta.url `][].
558
+ [`import.meta.filename`][] and [`import.meta.dirname `][].
530
559
531
560
#### No Addon Loading
532
561
@@ -1107,13 +1136,17 @@ resolution for ESM specifiers is [commonjs-extension-resolution-loader][].
1107
1136
[` data: ` URLs]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
1108
1137
[` export ` ]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
1109
1138
[` import ()` ]: #import-expressions
1139
+ [` import .meta .dirname ` ]: #importmetadirname
1140
+ [` import .meta .filename ` ]: #importmetafilename
1110
1141
[` import .meta .resolve ` ]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve
1111
1142
[` import .meta .url ` ]: #importmetaurl
1112
1143
[` import ` ]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
1113
1144
[` module .createRequire ()` ]: module.md#modulecreaterequirefilename
1114
1145
[` module .syncBuiltinESMExports ()` ]: module.md#modulesyncbuiltinesmexports
1115
1146
[` package .json ` ]: packages.md#nodejs-packagejson-field-definitions
1147
+ [` path .dirname ()` ]: path.md#pathdirnamepath
1116
1148
[` process .dlopen ` ]: process.md#processdlopenmodule-filename-flags
1149
+ [` url .fileURLToPath ()` ]: url.md#urlfileurltopathurl
1117
1150
[cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/1.2.2
1118
1151
[commonjs-extension-resolution-loader]: https://github.com/nodejs/loaders-test/tree/main/commonjs-extension-resolution-loader
1119
1152
[custom https loader]: module.md#import-from-https
0 commit comments