2021-07-12 10:54:24 +00:00
|
|
|
import { normalize } from 'upath'
|
|
|
|
|
2021-07-26 14:04:35 +00:00
|
|
|
export function resolveModule (id: string, paths?: string) {
|
2021-07-12 10:54:24 +00:00
|
|
|
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-07-12 10:54:24 +00:00
|
|
|
}))
|
2021-04-15 19:17:44 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 14:04:35 +00:00
|
|
|
export function requireModule (id: string, paths?: string) {
|
2021-04-15 19:17:44 +00:00
|
|
|
return require(resolveModule(id, paths))
|
|
|
|
}
|