chore: upgrade moduleResolution to Node16 (#9269)

This commit is contained in:
Harminder Virk
2024-09-24 17:19:20 +05:30
committed by GitHub
parent d721282600
commit 9e711720dd
216 changed files with 981 additions and 2439 deletions
@@ -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)
}
+2
View File
@@ -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
}