export async function makeDependentsMap({cwd, root}) {
const config = await getWebpackConfig({cwd, root})
const stats = await promisify(webpack)(config)
//if (e) throw e
if (stats.hasErrors()) {
stats.toJson().errors.map(e => {
console.log(e)
console.log('------------------------------------------------------------------------------')
})
//return
throw 'Webpack failed.'
}
const json = stats.toJson({modules: true})
const dependents = {}
const dependencies = {}
json.modules.map(mod => {
//console.log(mod)
dependents[mod.name] = dependents[mod.name] || []
//const deps = mod.reasons.map(r => r.module)
const deps = mod.reasons
dependents[mod.name].push(...deps)
mod.reasons.map(reason => {
dependencies[reason.module] = dependencies[reason.module] || []
dependencies[reason.module].push({mod, reason})
})
})
return {dependents, dependencies}
}
function findAndModifyRequires(code, userRequest, newImportPath) {
return j(code)
.find(j.CallExpression, {callee: {name: 'require'}})
.forEach(path => {
const name = path.value.arguments[0].value
if (name === userRequest) {
path.value.arguments[0].value = removeFileExt(newImportPath)
}
})
.toSource({quote: 'single'})
}
function findAndModifyImports(code, userRequest, newImportPath) {
return j(code)
.find(j.ImportDeclaration)
.forEach(path => {
const name = path.value.source.value
if (name === userRequest) {
path.value.source.value = removeFileExt(newImportPath)
}
})
.toSource({quote: 'single'})
}
pnpm i —force-but-dont-modify-my-shrinkwrap
.
node_modules
dir, but i have changed branch and want to run pnpm i
to use the new shrinkwrap
/soap/0.17.0:
dependencies:
compress: 0.99.0
debug: 0.7.4
ejs: 2.3.4
lodash: 3.10.1
node-uuid: 1.4.8
optional: 0.1.3
request: 2.81.0
sax: 1.2.2
selectn: 0.9.6
strip-bom: 0.3.1
ursa: 0.9.4
xml-crypto: 0.8.5
resolution: 1fccd7e19031a143ee53dec09afe89ba379e051e
/soap/0.17.0:
dependencies:
compress: 0.99.0
debug: 0.7.4
ejs: 2.3.4
lodash: 3.10.1
node-uuid: 1.4.8
optional: v0.1.3
request: 2.81.0
sax: 1.2.2
selectn: 0.9.6
strip-bom: 0.3.1
ursa: 0.9.4
xml-crypto: 0.8.5
resolution: 1fccd7e19031a143ee53dec09afe89ba379e051e
rm shrinkwrap.yaml
rm -rf node_modules
pnpm i
rm -rf node_modules
pnpm i
shrinkwrap.yaml has changed
react-highcharts
and the optional
module
WARN Cannot find resolution of /highcharts-release/v4.2.7 in shrinkwrap file
WARN Cannot find resolution of /highmaps-release/v1.1.10 in shrinkwrap file
WARN Cannot find resolution of /highstock-release/v2.1.10 in shrinkwrap file
WARN Cannot find resolution of /optional/v0.1.3 in shrinkwrap file
A leading "=" or "v" character is stripped off and ignored.