You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run this and then bolt. It'll do what you expect, but be warned: It will modify your package.json files.
import{getPackages}from'@manypkg/get-packages'import{writeFile}from'fs/promises'importpathfrom'path'// remove-dev-deps.js - Removes dev dependencies from a bolt monorepoconst{
packages,rootPackage: {packageJson: rootPackageJson}}=awaitgetPackages(process.cwd())// Get all dependencies used by sub-packages.constusedPackages=newSet(packages.reduce((acc,{packageJson: {dependencies ={}}})=>[
...acc,
...Object.keys(dependencies)],[]).sort())// Remove packages from the root package.json that aren't any sub-packages' dependenciesrootPackageJson.dependencies=Object.fromEntries(Object.entries(rootPackageJson.dependencies).filter(([name])=>usedPackages.has(name)))awaitwriteFile('package.json',JSON.stringify(rootPackageJson,null,2)+'\n')// Remove devDependencies from all sub-packages' package.jsonawaitPromise.all(packages.map(({
relativeDir,packageJson: {
devDependencies,
...packageJson}})=>writeFile(path.join(relativeDir,'package.json'),JSON.stringify(packageJson,null,2)+'\n')))
Activity
steve-taylor commentedon Oct 23, 2023
Run this and then
bolt. It'll do what you expect, but be warned: It will modify your package.json files.