Add `import.meta.dirname` / `import.meta.filename` (available since node `20.11.0`)
We can see more about when
import.metawas introduced here:
- https://github.com/nodejs/node/issues/47756
- https://github.com/nodejs/node/pull/48740
- Skimming through this PR, it seems
import.meta.dirname/similar support was introduced in node20.11.0We can confirm that in the
nodedocs, seeing that onlyimport.meta.url/import.meta.resolveare available in node19.x:
- https://nodejs.org/docs/latest-v19.x/api/esm.html#importmeta
But from node
20.x+,import.meta.dirname/import.meta.filenameare also available:
- https://nodejs.org/docs/latest-v20.x/api/esm.html#importmeta
Originally posted by @0xdevalias in https://github.com/jehna/humanify/issues/343#issuecomment-2684169063
See also:
- https://caniuse.com/?search=import.meta
- https://github.com/mdn/content/issues/38335
- https://github.com/mdn/browser-compat-data/issues/26066
- https://github.com/williamkapke/node-compat-table/issues/7
- https://github.com/compat-table/compat-table/issues/316
- https://github.com/compat-table/compat-table/issues/1053
- https://github.com/compat-table/compat-table/issues/1034
- https://github.com/compat-table/compat-table/issues/1580
Tangentially related:
BCD has compat info for most if not all of the features you describe. See the compat tables on these pages:
- developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
- developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
- developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta
- developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
- developer.mozilla.org/en-US/docs/Web/API/Worker/Worker
We are working on a mechanism to better group features in collaboration with the web-platform-dx/feature-set project. Hopefully, there will be a group for all things modules soon.
Originally posted by @Elchi3 in https://github.com/mdn/browser-compat-data/issues/4819#issuecomment-1672805525