UNPKG
@homer0/ts-async-import
Version:
latest (3.0.9)
3.0.9
3.0.8
3.0.7
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
2.0.0
1.1.13
1.1.12
1.1.11
1.1.10
1.1.9
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
Small utility to dynamically import ESM modules in CJS with TS
homer0/packages
@homer0/ts-async-import
/
src
/
index.js
10 lines
(9 loc)
•
268 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
module
.
exports
.
tsAsyncImport
=
(
name, contextDir
) =>
{
const
importPath = contextDir ?
require
.
resolve
(name, {
paths
: [contextDir], }) : name;
// eslint-disable-next-line node/no-unsupported-features/es-syntax
return
import
(importPath); };