UNPKG

@homer0/ts-async-import

Version:

Small utility to dynamically import ESM modules in CJS with TS

10 lines (9 loc) 268 B
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); };