chore(medusa-core-utils): Migrate to TS (#2670)
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user