🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

add-esmodule

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

add-esmodule

Add __esModule property to native ES module objects

1.0.0
latest
Source
npm
Version published
Weekly downloads
6
200%
Maintainers
1
Weekly downloads
 
Created
Source

add-esmodule

Add __esModule property to native ES module objects

Motivation

Much of the javascript ecosystem relies of ES modules having an __esModule property. However, native ES modules do not have that property. This project is a workaround for that problem.

Installation

npm install --save add-esmodule

# alternative
yarn add add-esmodule

Usage

import foo from "foo";
import { cloneWithEsModuleProperty } from "add-esmodule";

const fooCompat = cloneWithEsModuleProperty(foo);

foo.__esModule; // undefined
fooCompat.__esModule; // true

Browser compatibility

add-esmodule works in IE 11+

Implementation notes

  • Live Bindings for modules are supported (via object getters on the cloned object)
  • The cloned module object is frozen
  • Symbols, including toString, are properly cloned

Keywords

__esModule

FAQs

Package last updated on 13 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts