07. import.meta

The proposal introduces the pseudo-property import.meta which holds an object with metadata for the current module. One example of module metadata for Node.js modules is the global variable __dirname which contains the path of the directory in which the current module is stored. import.meta intended to hold some data:

  • import.meta.url - which contains the URL of the current module.

  • import.meta.entryUrl -

  • import.meta.scriptElement - gives modules access to the script element that loaded them.

Note that, by default, module metadata can only be accessed by the module. That is, unless the module passes the metadata object elsewhere, it is local.

Last updated