Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { resolve } = require('path')
const {
isMonorepo,
isPkgAvailable,
monorepoPkgs,
tryRequirePkg,
} = require('@pkgr/utils')
if (isMonorepo) {
exports.allowModules = monorepoPkgs.reduce((acc, pkg) => {
const pkgJson = tryRequirePkg(resolve(pkg, 'package.json'))
if (!pkgJson) {
return acc
}
const { name, peerDependencies = {}, dependencies = {} } = pkgJson
return acc.concat(
name,
Object.keys(peerDependencies),
Object.keys(dependencies),
)
}, [])
}
exports.isWebpackAvailable = isPkgAvailable('webpack')
// https://webpack.js.org/api/module-variables/#__resourcequery-webpack-specific