chore: upgrade moduleResolution to Node16 (#9269)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { resolveExports } from "./resolve-exports"
|
||||
|
||||
/**
|
||||
* Utility that should be used instead of either await import() or require()
|
||||
* to avoid bundling issues. That way we have a single place
|
||||
* where we manage the strategy to dynamically import a module.
|
||||
*
|
||||
* This issue arise from migration to Node16 or NodeNext module resolution as well
|
||||
* as ts-node not being maintained anymore and throwing deprecation warnings.
|
||||
* all over the place.
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
export async function dynamicImport(path: string): Promise<any> {
|
||||
const module = require(path)
|
||||
return resolveExports(module)
|
||||
}
|
||||
@@ -72,3 +72,5 @@ export * from "./trim-zeros"
|
||||
export * from "./upper-case-first"
|
||||
export * from "./validate-handle"
|
||||
export * from "./wrap-handler"
|
||||
export * from "./resolve-exports"
|
||||
export * from "./dynamic-import"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export function resolveExports(moduleExports) {
|
||||
if ("default" in moduleExports && "default" in moduleExports.default) {
|
||||
return resolveExports(moduleExports.default)
|
||||
}
|
||||
return moduleExports
|
||||
}
|
||||
Reference in New Issue
Block a user