Skip to content
/ esmeta Public

Handy function to handle import.meta

Notifications You must be signed in to change notification settings

ratson/esmeta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esmeta

Handy function to handle import.meta

Installation

npm install esmeta --save

Usage

import esmeta from 'esmeta'

const importMeta = esmeta(import.meta)
/*
{
  url: "file:///a/b/c.mjs"  // same as `import.meta.url`
  dirname: "/a/b"
  filename: "/a/b/c.mjs"
  dirnameJoin(...paths)  // helper function to join path
  isMain()  // return true if match to `process.mainModule`
  resolve()  // return the resolved filename like `require.resolve`
}
*/

Related

  • is-main - Check if current module is main module.