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

load-esm

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

load-esm - npm Package Compare versions

Comparing version

to
1.0.0

2

index.cjs.js
module.exports = {
loadModule: (module) => import(module)
loadEsm: (module) => import(module)
};

@@ -1,1 +0,1 @@

export function loadModule<T = any>(name: string): Promise<T>;
export function loadEsm<T = any>(name: string): Promise<T>;
{
"name": "load-esm",
"version": "0.1.1",
"version": "1.0.0",
"main": "index.cjs",

@@ -38,3 +38,8 @@ "types": "index.d.ts",

"dynamic import",
"dynamic load"
"dynamic load",
"JavaScript modules",
"module interoperability",
"mixed-module environment",
"ERR_PACKAGE_PATH_NOT_EXPORTED",
"No \"exports\" main defined in"
],

@@ -41,0 +46,0 @@ "engines": {

@@ -7,2 +7,7 @@ [![NPM version](https://img.shields.io/npm/v/load-esm.svg)](https://npmjs.org/package/load-esm)

This resolves the error:
```
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in...
```
## Installation

@@ -24,3 +29,3 @@ ```bash

```ts
import {loadModule} from 'load-esm';
import {loadEsm} from 'load-esm';

@@ -31,3 +36,3 @@ /**

(async () => {
const esmModule = await loadModule('esm-module');
const esmModule = await loadEsm('esm-module');
})();

@@ -40,3 +45,3 @@ ```

import * as path from 'path';
import {loadModule} from 'load-esm';
import {loadEsm} from 'load-esm';

@@ -49,3 +54,3 @@ /**

// Dynamically import the ESM module
const { fileTypeFromFile } = await loadModule('file-type');
const { fileTypeFromFile } = await loadEsm('file-type');

@@ -64,3 +69,3 @@ // Use the imported function

```ts
loadModule<T = any>(name: string): Promise<T>
loadEsm<T = any>(name: string): Promise<T>
```

@@ -77,6 +82,6 @@ Dynamically imports an ESM module.

```ts
import { loadModule } from 'load-esm';
import { loadEsm } from 'load-esm';
(async () => {
const module = await loadModule('some-esm-module');
const module = await loadEsm('some-esm-module');
console.log(module);

@@ -83,0 +88,0 @@ })();

Sorry, the diff of this file is not supported yet