umeta

A micro helper for `import.meta` data

Usage no npm install needed!

<script type="module">
  import umeta from 'https://cdn.skypack.dev/umeta';
</script>

README

ยตmeta

Build Status Coverage Status

A micro helper for import.meta data.

import umeta from 'umeta';

const {dirName, fileName, require} = umeta(import.meta);

The dirName and fileName respectively represent __dirname and __filename, while the require utility helps importing conditionally, or on demand, CommonJS friendly modules.

How to transform import.meta for CommonJS ?

There are at least two options:

  • ascjs, based on @babel/parser
  • ucjs, based on @babel/core and with minimal dependencies (compatible with dynamic import(...) too)