chore(medusa-core-utils): Migrate to TS (#2670)

This commit is contained in:
Adrien de Peretti
2022-12-05 10:21:04 +01:00
committed by GitHub
parent 1dc816039c
commit 1b21af87ab
23 changed files with 254 additions and 233 deletions
@@ -0,0 +1,18 @@
import Module from "module"
import path from "path"
const fallback = (filename: string) => {
const mod = new Module(filename)
mod.filename = filename
mod.paths = (Module as any)._nodeModulePaths(path.dirname(filename))
;(mod as any)._compile(`module.exports = require;`, filename)
return mod.exports
}
// Polyfill Node's `Module.createRequireFromPath` if not present (added in Node v10.12.0)
const createRequireFromPath =
Module.createRequire || Module.createRequireFromPath || fallback
export default createRequireFromPath