You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
425 B

const cwd = process.cwd()
const resolve = require('resolve')
// attempts to first require a dep using projects cwd (when vue-loader is linked)
// then try a normal require.
module.exports = function tryRequire (dep) {
let fromCwd
try {
fromCwd = resolve.sync(dep, { basedir: cwd })
} catch (e) {}
if (fromCwd) {
return require(fromCwd)
} else {
try {
return require(dep)
} catch (e) {}
}
}