Comparing version
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 @@ [](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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5220
8.61%0
-100%100
5.26%