Skip to content

Instantly share code, notes, and snippets.

@DanielHoffmann
Created January 13, 2022 17:29
Show Gist options
  • Save DanielHoffmann/e9737f46cc7421ac5c227d583cd59f1f to your computer and use it in GitHub Desktop.
Save DanielHoffmann/e9737f46cc7421ac5c227d583cd59f1f to your computer and use it in GitHub Desktop.
// used so eslint-plugin-import can properly resolve dependencies using yarn2
let pnp
try {
pnp = require(`./.pnp.cjs`)
} catch (error) {
// not a problem
}
const NOTFOUND = { found: false }
module.exports = {
interfaceVersion: 2,
resolve: (source, file) => {
if (!pnp) {
throw new Error(`This resolver is meant to be used with pnp, but no pnp file was found`)
}
try {
return { found: true, path: pnp.resolveRequest(source, file) }
} catch (error) {
return NOTFOUND
}
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment