{"_id":"next-build-id","_rev":"10-b2a0407e76e641527f248f2dc4f4a841","name":"next-build-id","description":"Use a consistent, git-based build id for your Next.js app","dist-tags":{"latest":"3.0.0","rc":"3.0.0-rc1"},"versions":{"1.0.0":{"name":"next-build-id","version":"1.0.0","description":"Override `next build` output to use a consistent build id","main":"index.js","bin":{"next-build-id":"cli.js"},"files":["cli.js","index.js"],"scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","build-stats","BUILD_ID","fix","hack","cli"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{"sywac":"^1.2.0"},"devDependencies":{"coveralls":"^3.0.0","rimraf":"^2.6.2","standard":"^10.0.3","standard-version":"^4.2.0","tap":"^11.0.0"},"gitHead":"b10a86725f9d37ee64827e006523f649b0bcd70b","_id":"next-build-id@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.2","_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"dist":{"integrity":"sha512-6woGb4w/Wyu7/bT71j7uILOngUhREkhNm7NLmqC4MsTqpaMZjl2hP0re0fMBxl7/c0xhnOec/6ZEjg13Y6yBMw==","shasum":"e6054598ace0eb70a2d6f465d7e9995b63f58a09","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG+jXa+H0oAIYwTMRhDoSkp48RvXpAm+vNjVytSH/HaNAiEA7hz2M5pqaqPYrtEUWqnAboiWVsITna3IB6+IY6Hb6sk="}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id-1.0.0.tgz_1513183306293_0.8455742304213345"},"directories":{}},"1.1.0":{"name":"next-build-id","version":"1.1.0","description":"Override `next build` output to use a consistent build id","main":"index.js","bin":{"next-build-id":"cli.js"},"files":["cli.js","index.js"],"scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","build-stats","BUILD_ID","fix","hack","cli"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{"sywac":"^1.2.0"},"devDependencies":{"coveralls":"^3.0.0","rimraf":"^2.6.2","standard":"^11.0.1","standard-version":"^4.3.0","tap":"^11.1.3"},"gitHead":"ba101491f0cfd93de757943b9d81d8a5ce90f371","_id":"next-build-id@1.1.0","_npmVersion":"5.8.0","_nodeVersion":"9.9.0","_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"dist":{"integrity":"sha512-6IEz7srw+3n2Lhujp6wUcQR0oJiNtAKma/Cs9F8hhofwLm3txPZysMQrqUUjoygmKIJV3zeumIDEz3+Gfy/f4g==","shasum":"467dc0482702e1b435d269fd9a42737517f07536","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-1.1.0.tgz","fileCount":6,"unpackedSize":11095,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCzjIEQJKIE47T/d/1TPP8A32a4JJXkQVLVqcXDPpxQxgIhAJ3ZNB7Y4y+WPL9mJ0jk16MrFcPK+yC9AR2GqvS9JPIp"}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_1.1.0_1523159633360_0.1975718239778157"},"_hasShrinkwrap":false},"1.2.0":{"name":"next-build-id","version":"1.2.0","description":"Override `next build` output to use a consistent build id","main":"index.js","bin":{"next-build-id":"cli.js"},"files":["cli.js","index.js"],"scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","build-stats","BUILD_ID","fix","hack","cli"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{"sywac":"^1.2.0"},"devDependencies":{"coveralls":"^3.0.1","rimraf":"^2.6.2","standard":"^11.0.1","standard-version":"^4.4.0","tap":"^12.0.1"},"gitHead":"a127d9b09cb7569cda248fe8341b4dffbd51cbd6","_id":"next-build-id@1.2.0","_npmVersion":"6.0.1","_nodeVersion":"8.11.2","_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"dist":{"integrity":"sha512-DbcmM/bxHMVeSE0csHR2lr8HBmG5rZNxZaTBVe8T2zzms6VgkNPwZbz56qq//OEoXcGS4aiwbu2MQ12O0MzHgA==","shasum":"62fab3d6c66c3ed3ce0a586bca5c2de63eebe6d1","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-1.2.0.tgz","fileCount":6,"unpackedSize":12054,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbBtLHCRA9TVsSAnZWagAAaLkP/3xJazffGXColUv4OLtk\nHLrpWAcaJUNrj7PvsJWdsa8ixQOzWAsE82Tg/SY/AmtnyMs+B+mGOaC6BFJt\nU7s/Rdl/htzlmiGkMou3LmzLtgr56vkXcNRvyYKC4BSCxjR3Af09NhiUoJcG\n/BGdTQeks+SofgbiuBwY3qSOPZPRN0R94cLYVR43qBKKSmepuTLmLVThBgDY\nmx2vpFSbCeqlECYByHbvtkKE8PjOby9ydzol2kQ7rZtf2NQwMH7cBeqPd6HI\nWVATyDdhzxP/Htyn8CZ2T4o5v+bIg2O9kLCV44abUiD620suNXzAwHkqMvoL\nG8Oxm7vVsQGRKKEHFBHXbvc/SMmm2b2id4xevGRX71kqg0Y89JrJFcaTv6zd\nlwfo61MUwbA/Fdz/7LdrlHwRtNfH+clHqphuOrxap/bMAiuP4J4au2K2S3O7\nINT09+11RJXrfcIRjm4fMSIMLeZJZ2JeD2CmW7nH1vIvgsoMF/c436mrKf0A\nXlX2s4K0K+rI+ceavA0006yIZISJ28t03Fg1GBoeQ3CvfaEw67onvHZ16NT6\nj0vtFnmVQWMgpOo2My+O/p3EU/i1Tbo2GHjq6RvMHAjdLKvF0hj4qqrs2Wud\nyB7+6tXlbB9pB4jCkkm6UUDEQ8M9esJoltkEmNSh1fOPPwBbx5iLEQ2lltC7\n7vuu\r\n=wVhH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIGSYHKF+JebLWPNMMnyAizayzoUggRfVpaNA0Etc4ZQIhAMSRGduDbGky+t1k2cDmb7F4q1o1ZOSsmUMhVUHOO1YF"}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_1.2.0_1527173830681_0.8549029385127291"},"_hasShrinkwrap":false},"2.0.0-rc1":{"name":"next-build-id","version":"2.0.0-rc1","description":"Override `next build` output to use a consistent build id","main":"index.js","bin":{"next-build-id":"cli.js"},"files":["cli.js","index.js"],"scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","build-stats","BUILD_ID","fix","hack","cli"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{"sywac":"^1.2.0"},"devDependencies":{"coveralls":"^3.0.1","rimraf":"^2.6.2","standard":"^11.0.1","standard-version":"^4.4.0","tap":"^12.0.1"},"readme":"# next-build-id\n\n> Override `next build` output to use a consistent build id\n\n[![Build Status](https://travis-ci.org/nexdrew/next-build-id.svg?branch=master)](https://travis-ci.org/nexdrew/next-build-id)\n[![Coverage Status](https://coveralls.io/repos/github/nexdrew/next-build-id/badge.svg?branch=master)](https://coveralls.io/github/nexdrew/next-build-id?branch=master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n\nSimple CLI and module that lets you define your own build id when using Next.js.\n\n## New in version 2!\n\nWhen using Next.js 6+ (which introduced the [generateBuildId](https://github.com/zeit/next.js#configuring-the-build-id) config prop), you can use `next-build-id` as a module within your next.config.js logic to set the BUILD_ID to the most recent git commit hash. This approach means you don't need to use the `next-build-id` CLI - just use `next build` as normal and you'll get the build id you want!\n\n```js\n// next.config.js\nconst nextBuildId = require('next-build-id')\nmodule.exports = {\n  generateBuildId: async () => {\n    const fromGit = await nextBuildId({ dir: __dirname })\n    return fromGit.id\n  }\n}\n```\n\n## Intro\n\nThis tool is necessary if you're running multiple instances of your Next.js app on different servers sitting behind a load balancer without session affinity. Otherwise, if your Next.js builds end up with different build ids, a client loading content from different servers can result in [this Next.js error](https://github.com/zeit/next.js/blob/52ccc14059673508803f96ef1c74eecdf27fe096/server/index.js#L444), which causes the app to blow up for that client.\n\nThis module updates/overrides the following:\n\n- uuid defined in `.next/BUILD_ID`\n- hashes for all chunks defined in `.next/build-stats.json` (Next.js 4 or below)\n\nBy default, this CLI/module will overwrite those values with the hash of the latest git commit (`git rev-parse HEAD`), but it will also allow you to define your own id.\n\nIf you have `distDir` defined in a `next.config.js` file, it will be respected. Otherwise, this module assumes the Next.js build output is in a relative `.next` directory.\n\n## Install\n\n```console\n$ npm i --save next-build-id\n```\n\n## CLI Usage\n\nModify your build script to run `next-build-id` after `next build` (only needed for production builds).\n\nFor instance, if you have an npm run script in package.json that looks like this:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build\"\n  }\n}\n```\n\nYou can change it to this:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build && next-build-id\"\n  }\n}\n```\n\nThe above example will use the hash of the latest git commit as the build id. If you'd like to define your own build id, pass it to the CLI using the `--id` flag:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build && next-build-id --id $MY_CUSTOM_ID\"\n  }\n}\n```\n\nIf you are building a directory other than the project root, you can pass that as an argument, just like you do with `next build`:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build client && next-build-id client\"\n  }\n}\n```\n\n## Module Usage\n\nThis module exports a single function that accepts an options object and returns a `Promise`.\n\nThe options supported are:\n\n- `dir` (string): the directory built by `next build`\n- `write` (boolean): whether to overwrite the BUILD_ID in the dist dir (not needed when using `generateBuildId` in next.config.js)\n- `id` (string): define a custom id instead of deferring to `git rev-parse HEAD`\n\nThe returned `Promise` resolves to a result object containing:\n\n- `inputDir` (string): the resolved path of the Next.js app\n- `outputDir` (string): the resolved path of the `next build` output\n- `id` (string): the build id used\n- `files` (array of strings): resolved paths of each file updated with the build id\n\nExample:\n\n```js\nconst nextBuildId = require('next-build-id')\n\nconst opts = {}\n// opts.dir = '/path/to/input/dir'\n// opts.write = true\n// opts.id = 'my_custom_id'\n\nnextBuildId(opts).then(result => {\n  console.log('success!')\n  console.log('input dir:', result.inputDir)\n  console.log('output dir:', result.outputDir)\n  console.log('build id:', result.id)\n  console.log('updated files:', result.files)\n}).catch(err => {\n  console.error('you broke it', err)\n})\n```\n\n## Reference\n\n- [zeit/next.js#786](https://github.com/zeit/next.js/issues/786)\n- [zeit/next.js#2978 (comment)](https://github.com/zeit/next.js/issues/2978#issuecomment-334849384)\n- [zeit/next.js#3299 (comment)](https://github.com/zeit/next.js/issues/3299#issuecomment-344973091)\n- [\"Handle BUILD_ID Mismatch Error\" on Next.js wiki](https://github.com/zeit/next.js/wiki/Handle-BUILD_ID-Mismatch-Error)\n\n## License\n\nISC © Andrew Goode\n","readmeFilename":"README.md","gitHead":"502bccc5567713a6a137bc9abdb9d256217f868e","_id":"next-build-id@2.0.0-rc1","_npmVersion":"6.0.1","_nodeVersion":"8.11.2","_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"dist":{"integrity":"sha512-vegiqofGFH/ruHqdJAHpbe8kkvsp4rpibe9nybjqwtUyxMGzNW+GUdbD0QYenuw/P+hhdczPGbyFDqlsloM+Qw==","shasum":"7917bfecab4057e65f9f1047d4ce98fcfa179b70","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-2.0.0-rc1.tgz","fileCount":6,"unpackedSize":13024,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbB/I/CRA9TVsSAnZWagAACUkP+gMAKSoVG6mg3uXyPnZA\niMyfZT5VotMnethyVaHMITjQcqu+nsYscC32bTwHtSjF+IjXkmE7vAFDIVc5\nFfYND5WjfbmTRVyxshvHmJQeEJLb+ml0cntQq3FtumbUquKPsLH+8oIQEFHl\njArlGfDEpa468I3ydx9wmz7agfOKS81ACu5eoxxeGwkNPm37afjhyIxfsSZ/\nMaNSUevGskk09lH0mPlb3Mrb6tgmj/cQg7KBOSvfvzQyhmij8KP7bSS4imDn\nGoeIzW/dr3qJ3PQAckwz43kltL063VkDTVj5az8LtdUbi+RHcgNR+2g2H4Hp\nsahw+JKHTldrT7FNRn/xve0p+nR71Rfyd96m8ehOOk4YrTeFYELNnvJTXpNu\n3x++86wFv3Qe/DB7imZJ8yEPrgY5bjBm6DQVmYG6c0FoomwjQZPClfYzgEq+\nZ2RQ5YYt3Bm+cgR17OS/3bWXLCGY5NiflkdD8S/S2bwH0uyc7DoJlIL59jJp\nhg/mv3TnwYUSlZxXeB2fLkhBtPBkaRx83aIFMokcRR4cdDW3JimsOb21Wnz1\nA6FsDaUujiFWqCmV6gc7cXr/uLGRLLv4GxwHtt8e2JGAVgpUIKsHUcP7QnEX\nUCJwx6lfiq1R9K7yE8kLYULHUKT/uCmmMsvJ3Qvr/8kmg8ynj+afYOcAQ2yV\nTRhQ\r\n=7K2v\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFkuEbAYYtJx4LkBJ8zMEWx1qmn4Wz/quPdM6KvJuQZBAiEAz8iIgfBZRIYtRTgmvrmK+I5xfKEad+pZOGBcUcKkVYY="}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_2.0.0-rc1_1527247423042_0.846269935227776"},"_hasShrinkwrap":false},"2.0.0":{"name":"next-build-id","version":"2.0.0","description":"Override `next build` output to use a consistent build id","main":"index.js","bin":{"next-build-id":"cli.js"},"files":["cli.js","index.js"],"scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","build-stats","BUILD_ID","fix","hack","cli"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{"sywac":"^1.2.0"},"devDependencies":{"coveralls":"^3.0.1","rimraf":"^2.6.2","standard":"^11.0.1","standard-version":"^4.4.0","tap":"^12.0.1"},"gitHead":"715e15ff1464c206f926d5ba0603096803bd6cc7","_id":"next-build-id@2.0.0","_npmVersion":"6.0.1","_nodeVersion":"8.11.2","_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"dist":{"integrity":"sha512-zZQqTYPEPZ7MHk4bULqP6Iua7xg6NHO4K0XFbFOolxS4hXca8U0w8vbRH8IWuFwrh0/nEAzTY/A/jw8UVGD2wg==","shasum":"de10ce9b905b53bb345c250267a5152ca500d228","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-2.0.0.tgz","fileCount":6,"unpackedSize":13635,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbB/WrCRA9TVsSAnZWagAA3r4P/A9NvxuGm+HCc6qRVmHc\nqeqT/THG/jFCZ5J6IwXmCvCfIx79yFVvS2ReQc4Ob91POa1d20ryF+dljsDH\nTUdBTACWKTWZPsyjRX+teE3EOEW4OIeLKOnmlAUFLvFd+TqTfPP3maoNAx9u\n5Eh1nOAWVeIC4CrQhcGIR0JarYLJctQEsUTP8LpWqcB2Z0aELAIcx/bymdqH\nGS1xj7EM1FAD4qz7BLdhgK3u6ORKw6bGTk++UQ0paEcdV4FTS3VF5HjyK7kM\n2AGdL4Bxnp4OYj9hjrBwkAKr9U/nWfvHoP6pctJ/2x+MrF2hdKZOcryFi5Dt\nkkJotLW9JjGVPH5cq9mMhU8MIxdvuI+IOGBa6OczvXP/MR2Rn67ylrpoGtds\nllOSJfdiKLfd9vH/48IkioWLb7A/vEATA9XV0ECJwT+2UmiBtgRNgUOU86kq\n1mPn4K1aAn7C273+AqtQe0yIY4lGpNQxx3PClr2DqNzIhKQ2AZk6a9yZqCsD\nSQf0UEpM2CmWNtDbhP1ndUQY6Fm6fehixR/q3BwTXT0AULpIaYw/Yq1qUE1Z\nwxyR30KKlJCwwmPy5c3mPkMrWI03fhVO62SaN9c/Rlt68/EC7L74g+pSWvIx\ngThwLMlFL3v/ijo8KtnR2Eza9SOzAS5kWTaQOz9TJuk5UtV6huCpWfTSMvuo\n7E78\r\n=iEGM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEeMfP1meqM4X/+zNO6hV/iJtPyCmcQDcKb722iJrljbAiAei+1y25FBS5czkz+GFwZDqTn2uaEYcWK2IEFWm3MUsA=="}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_2.0.0_1527248298968_0.3798149664729724"},"_hasShrinkwrap":false},"2.0.1-rc1":{"name":"next-build-id","version":"2.0.1-rc1","description":"Override `next build` output to use a consistent build id","main":"index.js","bin":{"next-build-id":"cli.js"},"files":["cli.js","index.js"],"scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","build-stats","BUILD_ID","fix","hack","cli"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{"sywac":"^1.2.0"},"devDependencies":{"coveralls":"^3.0.1","rimraf":"^2.6.2","standard":"^11.0.1","standard-version":"^4.4.0","tap":"^12.0.1"},"readme":"# next-build-id\n\n> Override `next build` output to use a consistent build id\n\n[![Build Status](https://travis-ci.org/nexdrew/next-build-id.svg?branch=master)](https://travis-ci.org/nexdrew/next-build-id)\n[![Coverage Status](https://coveralls.io/repos/github/nexdrew/next-build-id/badge.svg?branch=master)](https://coveralls.io/github/nexdrew/next-build-id?branch=master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n\nSimple CLI and module that lets you define your own build id when using Next.js.\n\n## New in version 2!\n\nWhen using Next.js 6+ (which introduced the [generateBuildId](https://github.com/zeit/next.js#configuring-the-build-id) config prop), you can use `next-build-id` as a module within your next.config.js logic to set the BUILD_ID to the most recent git commit hash. This approach means you don't need to use the `next-build-id` CLI - just use `next build` as normal and you'll get the build id you want!\n\n```js\n// next.config.js\nconst nextBuildId = require('next-build-id')\nmodule.exports = {\n  generateBuildId: async () => {\n    const fromGit = await nextBuildId({ dir: __dirname })\n    return fromGit.id\n  }\n}\n```\n\n## Intro\n\nThis tool is necessary if you're running multiple instances of your Next.js app on different servers sitting behind a load balancer without session affinity. Otherwise, if your Next.js builds end up with different build ids, a client loading content from different servers can result in [this Next.js error](https://github.com/zeit/next.js/blob/52ccc14059673508803f96ef1c74eecdf27fe096/server/index.js#L444), which causes the app to blow up for that client.\n\nThis module updates/overrides the following:\n\n- uuid defined in `.next/BUILD_ID`\n- hashes for all chunks defined in `.next/build-stats.json` (Next.js 4 or below)\n\nBy default, this CLI/module will overwrite those values with the hash of the latest git commit (`git rev-parse HEAD`), but it will also allow you to define your own id.\n\nIf you have `distDir` defined in a `next.config.js` file, it will be respected. Otherwise, this module assumes the Next.js build output is in a relative `.next` directory.\n\n## Install\n\n```console\n$ npm i --save next-build-id\n```\n\n## CLI Usage\n\nModify your build script to run `next-build-id` after `next build` (only needed for production builds).\n\nFor instance, if you have an npm run script in package.json that looks like this:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build\"\n  }\n}\n```\n\nYou can change it to this:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build && next-build-id\"\n  }\n}\n```\n\nThe above example will use the hash of the latest git commit as the build id. If you'd like to define your own build id, pass it to the CLI using the `--id` flag:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build && next-build-id --id $MY_CUSTOM_ID\"\n  }\n}\n```\n\nIf you are building a directory other than the project root, you can pass that as an argument, just like you do with `next build`:\n\n```json\n{\n  \"scripts\": {\n    \"build\": \"next build client && next-build-id client\"\n  }\n}\n```\n\n## Module Usage\n\nThis module exports a single function that accepts an options object and returns a `Promise`.\n\nThe options supported are:\n\n- `dir` (string): the directory built by `next build`\n- `write` (boolean): whether to overwrite the BUILD_ID in the dist dir (not needed when using `generateBuildId` in next.config.js)\n- `id` (string): define a custom id instead of deferring to `git rev-parse HEAD`\n\nThe returned `Promise` resolves to a result object containing:\n\n- `inputDir` (string): the resolved path of the Next.js app\n- `outputDir` (string): the resolved path of the `next build` output\n- `id` (string): the build id used\n- `files` (array of strings): resolved paths of each file updated with the build id\n\nExample:\n\n```js\nconst nextBuildId = require('next-build-id')\n\nconst opts = {}\n// opts.dir = '/path/to/input/dir'\n// opts.write = true\n// opts.id = 'my_custom_id'\n\nnextBuildId(opts).then(result => {\n  console.log('success!')\n  console.log('input dir:', result.inputDir)\n  console.log('output dir:', result.outputDir)\n  console.log('build id:', result.id)\n  console.log('updated files:', result.files)\n}).catch(err => {\n  console.error('you broke it', err)\n})\n```\n\n## Reference\n\n- [zeit/next.js#786](https://github.com/zeit/next.js/issues/786)\n- [zeit/next.js#2978 (comment)](https://github.com/zeit/next.js/issues/2978#issuecomment-334849384)\n- [zeit/next.js#3299 (comment)](https://github.com/zeit/next.js/issues/3299#issuecomment-344973091)\n- [\"Handle BUILD_ID Mismatch Error\" on Next.js wiki](https://github.com/zeit/next.js/wiki/Handle-BUILD_ID-Mismatch-Error)\n\n## License\n\nISC © Andrew Goode\n","readmeFilename":"README.md","gitHead":"bcc374be89500e6fbaec25a30fa2bf24b15d14de","_id":"next-build-id@2.0.1-rc1","_npmVersion":"6.0.1","_nodeVersion":"8.11.2","_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"dist":{"integrity":"sha512-ymI2sicQvBgOPsinGCMeINQusAdhPlDok2NxZSBcMQGCOoTRESxACYMt9JtELWvRXY985K4IUabL3viZznt/ug==","shasum":"7490cd0f1cef234a94014e82f07c5844e40dae89","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-2.0.1-rc1.tgz","fileCount":6,"unpackedSize":14155,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbCGxECRA9TVsSAnZWagAAt2wP/3pJMGq1DZmVpG+/24yW\n7MSGqpi/4B/DjP/KwIDA3WSjgpkeCjaFdJhL/b/Zly/C4c4+2/rG4aFTW2T3\n9V2Hbh8mL9E4u6DTr8VOwZCGW8JHVN/8Dhh2jFOe3lN7fqedFUqqjNaipZ/2\nZD5WSvO+XTmQJk2HtleL1dqHT7wLGwLG6KsE12IAWjlKOq3RnufHJdwHMiUJ\ndGt/QMZ1tO3fWR5/JJi7jK9m3vq7ryDn5+t6KunljbPv+/wjn15YKJLsH2jl\nQB5AE0qyNo1zdaiXJhLmvMjZ8SEVKQi3F10upiHJHQ892aPA32wbMmvpe5WA\nGqZU0UiX5kvSH0FtBGv0PZeojiAl2x1YU3YVWkCm2NDMUnCguqnILKDFBxIR\nAV3CuRvJojH8B9TGebLKNumVoeZGbF9LEizMgCsY0IZRLkMx4j6SKvICYHWO\nNCt+KT7e92tTbYmwXxjId8YoyeEmHsQy0k5LvssKViK4Gkl9zvSjnZZvuOpV\nEueDIkjW9ZrTSko5UCzCLnsVshx5NfJPzmnrFLHNNq1Gjk3g+sTTvHvYdlSS\ns6LonSG2XW+MmdXSL3xoBLp3O0jVULdU5PLL06TqqOGUnQEOazN1FdFFLzQw\nMI3rbt7HkvIBjbffTFceTaeJH1BFjpnpIiXsa1m/JKQyRYGUaVJrXqMvmCw3\nWnR0\r\n=l/N+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyIkz8Y1T1cauq8iMDCRqe7wrl+uqCOv0ClQTqDqFXkQIhAL6uvC2Klq7GkNuNqGD8pg5C7D2QyRSncHGOd+J5fxtd"}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_2.0.1-rc1_1527278659756_0.3718898313611838"},"_hasShrinkwrap":false},"2.0.1":{"name":"next-build-id","version":"2.0.1","description":"Override `next build` output to use a consistent build id","main":"index.js","bin":{"next-build-id":"cli.js"},"files":["cli.js","index.js"],"scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","build-stats","BUILD_ID","fix","hack","cli"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{"sywac":"^1.2.0"},"devDependencies":{"coveralls":"^3.0.1","rimraf":"^2.6.2","standard":"^11.0.1","standard-version":"^4.4.0","tap":"^12.0.1"},"gitHead":"7895ac83e09b6f815ad58ffcefa696cab0f82ce3","_id":"next-build-id@2.0.1","_npmVersion":"6.0.1","_nodeVersion":"8.11.2","_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"dist":{"integrity":"sha512-7zbhx7kdOyKHWUEYSEUGb/l6Y+LeJ2dLhTJjY2n1Z09DrgyZwJLspo4xdZFPBz7SyyPvT/8O/cRHn1MuKF9D4Q==","shasum":"a45f6360e1275f0583b03219f627f79baba7e5bf","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-2.0.1.tgz","fileCount":6,"unpackedSize":14453,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbCG7vCRA9TVsSAnZWagAAThMP/jCHVQpeFUO4Zqfco5VZ\n19LKgLEY3IEcMYy+AGvrsxoM29TIAGD2IeuZr/k+JE12tF7zOpOSq/SpnBLK\nzA/41uY9pIykkE/cnuw+VYfs9RZmhSyrKMeKFF8BFowDuMjDZB5IMoQklK92\nzRqcasKABKwb3NgGdr6VrGPtkfWlGjV5u8trr1kJsuo+uhMhHMuPtLLC4tL8\nqlMUyXUqhohWUhJ3hz7RDoLpJERvdnPPFhTOjTm+3UkC2luL64WYrhP9vHzT\nWXRVM9y4+VRxGyQGHtha48xAK++4hF9IjGbs2ukvLf+ZS0wHYWWd75ZQhKn0\ndjYmtCN33crFUivPxkpdrL0a46oUaCoGfsqSv5ltupuW4cQl/ciVmRj5D6e7\n+p33XGV/pYnaV1o28qV+FeUkgQW513HaewSCDwSWAOPhuvLQvfSAXGmBJdYy\njXjvbyFuYM2MlnM+ieJpZzjDF8roPUaSvqlyymr+tUqe0hjOaJzIdF8mzXu8\nf5kBdnE1kip/EUofbICp2+9+wdO68VqGuI62bePFXi/p2ych3Oioiy/G1XZ7\nKMETyE6WM5cWNuGSNV0rwqUoMKp9Xpy8BBSECYqxN8yg5vvjv2J1qEimn7X7\nkjq6fqbuEhmHczpGYS+UBjt2G47VBvHtDd1fjcDVhn4IXvTjdJbkpke2O2hT\nheea\r\n=+FXW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDUPq4Zl/Vvw1ppLs5KjA9Hk7kgOqeq0rVWFnm3uy5P/wIhAIpoZigVhSVS8jkkmcKGIfIlAZikPmvAG9SE0BoDkSFV"}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_2.0.1_1527279342239_0.5457685398545311"},"_hasShrinkwrap":false},"3.0.0-rc1":{"name":"next-build-id","version":"3.0.0-rc1","description":"Use a consistent, git-based build id for your Next.js app","main":"index.js","scripts":{"pretest":"standard","test":"tap --cov test/test*.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=8"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","BUILD_ID","git","head","describe","tags"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{},"devDependencies":{"coveralls":"^3.0.1","rimraf":"^2.6.2","standard":"^12.0.0","standard-version":"^6.0.1","tap":"^12.0.1"},"readme":"# next-build-id\n\n> Use a consistent, git-based build id for your Next.js app\n\n[![Build Status](https://travis-ci.org/nexdrew/next-build-id.svg?branch=master)](https://travis-ci.org/nexdrew/next-build-id)\n[![Coverage Status](https://coveralls.io/repos/github/nexdrew/next-build-id/badge.svg?branch=master)](https://coveralls.io/github/nexdrew/next-build-id?branch=master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![Greenkeeper badge](https://badges.greenkeeper.io/nexdrew/next-build-id.svg)](https://greenkeeper.io/)\n\nSmall package to generate a consistent, git-based build id for your Next.js app when running `next build` on each server in a multi-server deployment.\n\nThis module exports a function that you can use as your [generateBuildId](https://github.com/zeit/next.js#configuring-the-build-id) config option in next.config.js.\n\nBy default, it will use the latest git commit hash from the local git repository (equivalent of `git rev-parse HEAD`):\n\n```js\n// next.config.js\nconst nextBuildId = require('next-build-id')\nmodule.exports = {\n  generateBuildId: () => nextBuildId({ dir: __dirname })\n}\n// => 'f9fc968afa249d162c924a8d5b4ce6562c164c2e'\n```\n\nIf you'd rather use a build id relative to the most recent tag in your git repo, pass `describe: true` as an option and the output of `git describe --tags` will be used instead:\n\n```js\n// next.config.js\nconst nextBuildId = require('next-build-id')\nmodule.exports = {\n  generateBuildId: () => nextBuildId({ dir: __dirname, describe: true })\n}\n// => 'v1.0.0' (no changes since v1.0.0 tag)\n// => 'v1.0.0-19-ga8f7eee' (19 changes since v1.0.0 tag)\n```\n\nThis module also exposes a synchronous version for custom needs, e.g. passing the build id directly to a Sentry configuration. Just call `nextBuildId.sync({ dir: __dirname })` instead.\n\n## Why?\n\nIf you're running multiple instances of your app sitting behind a load balancer without session affinity (and you're building your app directly on each production server instead of pre-packaging it), a tool like this is necessary to avoid Next.js errors like [\"invalid build file hash\"](https://github.com/zeit/next.js/blob/52ccc14059673508803f96ef1c74eecdf27fe096/server/index.js#L444), which happens when the same client (browser code) talks to multiple server backends (Node server) that have different build ids.\n\nThe build id used by your app is stored on the file system in a `BUILD_ID` text file in your build directory, which is `.next` by default.\n\n## Install\n\n```console\n$ npm i next-build-id\n```\n\n## API\n\nThis module exports two functions, one that is asynchronous (`nextBuildId()` primary export) and one that is synchronous (`nextBuildId.sync()`). Both functions accept a single options object, supporting the same options listed below. Both functions return (or resolve to) a string, representing the git-based build id.\n\nThe options supported are:\n\n- `dir` (string, default `process.cwd()`): a directory within the local git repository\n\n    Using `__dirname` from your next.config.js module is generally safe. The default value is assumed to be the directory from which you are running the `next build` command, but this may not be correct based on how you build your Next.js app.\n\n- `describe` (boolean, default `false`): use git tag description instead of latest commit sha\n\n    Specify this a `true` to use `git describe --tags` instead of `git rev-parse HEAD` for generating the build id. If there are no tags in your local git repository, the latest commit sha will be used instead, unless you also specify `fallbackToSha: false`.\n\n- `fallbackToSha` (boolean, default `true`): fallback to latest commit sha when `describe: true` and no tags exist\n\n    Only applies when using `describe: true`. If you want to be strict about requiring the use (and presence) of tags, then disable this with `fallbackToSha: false`, in which case an error will be thrown if no tags exist.\n\nNote that this module really provides a generic way to get an id or status string for any local git repository, meaning it is not directly tied to Next.js in any way - it just depends on how you use it.\n\n## Reference\n\n- [zeit/next.js#786](https://github.com/zeit/next.js/issues/786)\n- [zeit/next.js#2978 (comment)](https://github.com/zeit/next.js/issues/2978#issuecomment-334849384)\n- [zeit/next.js#3299 (comment)](https://github.com/zeit/next.js/issues/3299#issuecomment-344973091)\n- [\"Handle BUILD_ID Mismatch Error\" on Next.js wiki](https://github.com/zeit/next.js/wiki/Handle-BUILD_ID-Mismatch-Error)\n\n## License\n\nISC © Andrew Goode\n","readmeFilename":"README.md","gitHead":"935cd3f6ff53e4dac7f036d3ca2517e07269bf45","_id":"next-build-id@3.0.0-rc1","_nodeVersion":"12.3.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-kBOQMQUPoS6yFbkLoDiLHr8CH7+DKCAt17l46v3qw4ppUJ4vrL3+aTog3rKztOIBJWFkpK5s7X9vSzZJkQelAA==","shasum":"929b54880d5ddc5b909f6e1bbce31a16a8afb539","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-3.0.0-rc1.tgz","fileCount":5,"unpackedSize":13708,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc7VGsCRA9TVsSAnZWagAAz9oP/1kFqsmq2Lfa8Xr+Ey6Z\nvl0seXKK1o3Nsne/+xgKdIleTkpg2n+aFrJOz9xDwTqwQ+rpBgkZ/4TEHqW2\nA08QFcbYB5lRX5CN2fkGvHaPk33pZf6l1920u0cU1puVesZIFHVIZaWr2Hv3\nWpnBQjwCLT/i1Y98R17RBzckGPjc4CMLPXDqHCiJt0eoRKApCjwjG7RCg9Qo\npCeCS74MUXA4h5j/vCPVH8vZgcEImzFpF/xPUqJcsoOW9g9bORIr1xkbQPDc\nGcSD9wMmjIE9/AYaBQPEykvy8mDpl7vLm8gL6a9pmSupgTB3btBfXxYeESKG\niu7/hGIxd0ICKq/L+TPeZmYasi03nAA79ziQUy8WQ2Bp/YV+LUp/0A2crxIi\nx4btrNZMyRPdvydP7V1PdQBLApWCeP9e/i53hOKi3xeJZI8HLbjKJG/AUExl\n9tsitEPjlqPSH3Saw1KE8HWYthGBrpcAJ5EARqf0pSlyvb4CNMN4Em73PvVp\n+MJXQtBG1CAvvrsiZbkxz7IyuFYVb0I4RPRnfq9nhJBbfHCAi8UiDJwI1Kxd\nAQNQGvwUcJDruF9320AzG/UB8JerS1dHuYYMIRNr2IvfgOsACUVOKo39ENnZ\nA8i0YyvuY39zAemSX+9WQod4zqsi9KUDXvenc50thwMr3eSnBOEpp9WpMFxI\nAZBs\r\n=uvwU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeixn2+5jYARJd6waXEkHJZQFf8DDqM4XDIqzuSme9cwIgGl6RPmoWFrachrJjWbzQeOJffjeakiGuFIlCnlk3qwk="}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_3.0.0-rc1_1559056812068_0.715458649161641"},"_hasShrinkwrap":false},"3.0.0":{"name":"next-build-id","version":"3.0.0","description":"Use a consistent, git-based build id for your Next.js app","main":"index.js","scripts":{"pretest":"standard","test":"tap --cov --timeout=240 test/test-next6.js test/test-next7.js test/test-next8.js test/test-next9.js","coverage":"nyc report --reporter=text-lcov | coveralls","release":"standard-version"},"engines":{"node":">=8"},"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"keywords":["next","next.js","build","id","BUILD_ID","git","head","describe","tags"],"author":{"name":"nexdrew"},"license":"ISC","bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"homepage":"https://github.com/nexdrew/next-build-id#readme","dependencies":{},"devDependencies":{"coveralls":"^3.0.6","rimraf":"^3.0.0","standard":"^13.1.0","standard-version":"^7.0.0","sywac":"^1.2.2","tap":"^14.6.1"},"gitHead":"3b48f403519eb3b02928df3d89663692cc3fbeaa","_id":"next-build-id@3.0.0","_nodeVersion":"12.8.1","_npmVersion":"6.10.3","dist":{"integrity":"sha512-B3JCsL/9Z/wkmo3EySukQHCgx89Aw0i4LPi2MEhCboQBJ6wpkYTIu1z6hOYKuw/S1Wy8ZRqCEq0dVY/ST6jGqg==","shasum":"bfb7a1e2df03882688758f0a4a67e6e837043f42","tarball":"https://registry.npmjs.org/next-build-id/-/next-build-id-3.0.0.tgz","fileCount":5,"unpackedSize":14448,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdVrN/CRA9TVsSAnZWagAAEeYP/3haqbCHPhfmjrYNKkLx\nfPdQjn8xVn8Hfx6C0ZOfIxBb6I02E5ZhMU6RZ+OnurEULgIK+l+Nz4dErhAV\nYJHULkZRPwwxoU9XqaRTDXW5UFzdgZLlrAgtPGiq9qP/VTy/9acz5hoxQdE1\nGCY+h1SzRgFVSElUAEOPwytg33ESH6iQjFmfHPyAFIY9M0/0MgCOcI7xLm0c\nyjO18m5TvAKCT2VBP3lD6G6YN7KLUkAcd+eP2/xXT4ESSPS035Im4QDl+OdR\nXABRpkpcUXCaKiojuD0GHYCN+WmgVFWBgGBySvc1gxdgUcwCuRcivJa1ZtqV\nt/oF7HuYcWxpBuHlg8Iu2lkK0uNZqTesUi1HYQi1bzGSYyNJn2cwwRt50u1h\nox157zO9LyNpBjz18fs0ioO5LHi7VdMEwL9Lz/Y9q6frI9rn2qIOCKGdBYUo\nuX5/qC7bDz8seGXfWD0aS3UTup090lZoNvGfoKifNHtpib36y5hDliK78fXI\nTvkA/0m8YUpQ1I9gf3FWIK1r7sI0fxp6wlEyya5goDeOGqf2c0YKdeou09Rv\nEZw2aMawUoYZHjuzfV2QWcveRKhF+w6qOXG6GUY7QpPWP+9Fqh6SqvwgP1aP\nh+upah6yL0BQ5ryxPqSt81Bo4c5k/tqDdtxytv7vBJeZCqkS1rfKH8zUdqeP\n0/O3\r\n=aHJm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC98MaNMnCAeFbSF4DfAfxeUp5zstnBc6vu2b8bfWM5TwIgZ74y/U2ivHwhaJNWCqLf5KYgCxv+hCUBD4oGarRRbUw="}]},"maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"_npmUser":{"name":"nexdrew","email":"andrewbgoode@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/next-build-id_3.0.0_1565963134689_0.7739713504144097"},"_hasShrinkwrap":false}},"readme":"# next-build-id\n\n> Use a consistent, git-based build id for your Next.js app\n\n[![Build Status](https://travis-ci.org/nexdrew/next-build-id.svg?branch=master)](https://travis-ci.org/nexdrew/next-build-id)\n[![Coverage Status](https://coveralls.io/repos/github/nexdrew/next-build-id/badge.svg?branch=master)](https://coveralls.io/github/nexdrew/next-build-id?branch=master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![Greenkeeper badge](https://badges.greenkeeper.io/nexdrew/next-build-id.svg)](https://greenkeeper.io/)\n\nSmall package to generate a consistent, git-based build id for your Next.js app when running `next build` on each server in a multi-server deployment.\n\nThis module exports a function that you can use as your [generateBuildId](https://github.com/zeit/next.js#configuring-the-build-id) config option in next.config.js.\n\nBy default, it will use the latest git commit hash from the local git repository (equivalent of `git rev-parse HEAD`):\n\n```js\n// next.config.js\nconst nextBuildId = require('next-build-id')\nmodule.exports = {\n  generateBuildId: () => nextBuildId({ dir: __dirname })\n}\n// => 'f9fc968afa249d162c924a8d5b4ce6562c164c2e'\n```\n\nIf you'd rather use a build id relative to the most recent tag in your git repo, pass `describe: true` as an option and the output of `git describe --tags` will be used instead:\n\n```js\n// next.config.js\nconst nextBuildId = require('next-build-id')\nmodule.exports = {\n  generateBuildId: () => nextBuildId({ dir: __dirname, describe: true })\n}\n// => 'v1.0.0' (no changes since v1.0.0 tag)\n// => 'v1.0.0-19-ga8f7eee' (19 changes since v1.0.0 tag)\n```\n\nThis module also exposes a synchronous version for custom needs, e.g. passing the build id directly to a Sentry configuration. Just call `nextBuildId.sync({ dir: __dirname })` instead.\n\n## Why?\n\nIf you're running multiple instances of your app sitting behind a load balancer without session affinity (and you're building your app directly on each production server instead of pre-packaging it), a tool like this is necessary to avoid Next.js errors like [\"invalid build file hash\"](https://github.com/zeit/next.js/blob/52ccc14059673508803f96ef1c74eecdf27fe096/server/index.js#L444), which happens when the same client (browser code) talks to multiple server backends (Node server) that have different build ids.\n\nThe build id used by your app is stored on the file system in a `BUILD_ID` text file in your build directory, which is `.next` by default.\n\n## Install\n\n```console\n$ npm i next-build-id\n```\n\n## API\n\nThis module exports two functions, one that is asynchronous (`nextBuildId()` primary export) and one that is synchronous (`nextBuildId.sync()`). Both functions accept a single options object, supporting the same options listed below. Both functions return (or resolve to) a string, representing the git-based build id.\n\nThe options supported are:\n\n- `dir` (string, default `process.cwd()`): a directory within the local git repository\n\n    Using `__dirname` from your next.config.js module is generally safe. The default value is assumed to be the directory from which you are running the `next build` command, but this may not be correct based on how you build your Next.js app.\n\n- `describe` (boolean, default `false`): use git tag description instead of latest commit sha\n\n    Specify this as `true` to use `git describe --tags` instead of `git rev-parse HEAD` for generating the build id. If there are no tags in your local git repository, the latest commit sha will be used instead, unless you also specify `fallbackToSha: false`.\n\n- `fallbackToSha` (boolean, default `true`): fallback to latest commit sha when `describe: true` and no tags exist\n\n    Only applies when using `describe: true`. If you want to be strict about requiring the use (and presence) of tags, then disable this with `fallbackToSha: false`, in which case an error will be thrown if no tags exist.\n\nNote that this module really provides a generic way to get an id or status string for any local git repository, meaning it is not directly tied to Next.js in any way - it just depends on how you use it.\n\n## Reference\n\n- [zeit/next.js#786](https://github.com/zeit/next.js/issues/786)\n- [zeit/next.js#2978 (comment)](https://github.com/zeit/next.js/issues/2978#issuecomment-334849384)\n- [zeit/next.js#3299 (comment)](https://github.com/zeit/next.js/issues/3299#issuecomment-344973091)\n- [\"Handle BUILD_ID Mismatch Error\" on Next.js wiki](https://github.com/zeit/next.js/wiki/Handle-BUILD_ID-Mismatch-Error)\n\n## License\n\nISC © Andrew Goode\n","maintainers":[{"name":"nexdrew","email":"andrewbgoode@gmail.com"}],"time":{"modified":"2022-05-10T14:41:36.473Z","created":"2017-12-13T16:41:47.225Z","1.0.0":"2017-12-13T16:41:47.225Z","1.1.0":"2018-04-08T03:53:53.491Z","1.2.0":"2018-05-24T14:57:10.771Z","2.0.0-rc1":"2018-05-25T11:23:43.122Z","2.0.0":"2018-05-25T11:38:19.081Z","2.0.1-rc1":"2018-05-25T20:04:19.970Z","2.0.1":"2018-05-25T20:15:42.304Z","3.0.0-rc1":"2019-05-28T15:20:12.235Z","3.0.0":"2019-08-16T13:45:34.785Z"},"homepage":"https://github.com/nexdrew/next-build-id#readme","keywords":["next","next.js","build","id","BUILD_ID","git","head","describe","tags"],"repository":{"type":"git","url":"git+https://github.com/nexdrew/next-build-id.git"},"author":{"name":"nexdrew"},"bugs":{"url":"https://github.com/nexdrew/next-build-id/issues"},"license":"ISC","readmeFilename":"README.md"}