Nuxt/packages/cli/src/utils/cjs.ts

19 lines
398 B
TypeScript
Raw Normal View History

import { normalize } from 'upath'
2021-04-15 19:17:44 +00:00
export function resolveModule (id, paths?) {
return normalize(require.resolve(id, {
2021-04-15 19:17:44 +00:00
paths: [].concat(
// @ts-ignore
global.__NUXT_PREPATHS__,
paths,
process.cwd(),
// @ts-ignore
global.__NUXT_PATHS__
).filter(Boolean)
}))
2021-04-15 19:17:44 +00:00
}
export function requireModule (id, paths?) {
return require(resolveModule(id, paths))
}