JSPM

module-scope

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q22014F
  • License MIT

📍 '__dirname' and '__filename' in harmony modules

Package Exports

  • module-scope

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (module-scope) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

module-scope

📍 __dirname and __filename in native harmony modules

When running native harmony modules (node --experimental-modules myapp) the classic module scope signature is not available (exports, require, module, __filename, __dirname).

This module helps getting __dirname and __filename values easily by import.meta.url:

import scope from 'module-scope';

const {__dirname, __filename} = scope(import.meta.url);

Or get corresponding names without the underscores

const {dirname, filename} = scope(import.meta.url);