const fs = require('fs')const { nodeFileTrace } = require('@vercel/nft')/*** Exports a function to write a json that computes dependencies required by given paths* @param paths List of paths for which dependencies need to be computed* @param filename Name of the file to write json to* @returnsvoid*/asyncfunctioncomputeDependencies(paths: string[] = [], name: string = 'deps') {// the whole app inside index.js,// include other paths that are// not bundled with your app buildsconst files = paths// Compute file traceconst { fileList } = awaitnodeFileTrace(files)// Store set of packageslet packages = {} fileList.forEach((i) => {if (i.includes('node_modules/')) {let temp = i.replace('node_modules/', '') temp = temp.substring(0, temp.indexOf('/')) packages[`node_modules/${temp}`] = true } else { packages[i] = true } })// Sort the set of packages by name (for easier difference comparison with git) packages = Object.keys(packages) .sort() .reduce((obj, key) => { obj[key] = packages[key]return obj }, {})// Dump the list of the computed packages for further references while deploying the app fs.writeFileSync(`./${name}.json`, JSON.stringify(packages, null, 2), 'utf-8')}