generate-build-id.js 765 B

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.generateBuildId = generateBuildId;
  6. async function generateBuildId(generate, fallback) {
  7. let buildId = await generate();
  8. // If there's no buildId defined we'll fall back
  9. if (buildId === null) {
  10. // We also create a new buildId if it contains the word `ad` to avoid false
  11. // positives with ad blockers
  12. while(!buildId || /ad/i.test(buildId)){
  13. buildId = fallback();
  14. }
  15. }
  16. if (typeof buildId !== "string") {
  17. throw new Error("generateBuildId did not return a string. https://nextjs.org/docs/messages/generatebuildid-not-a-string");
  18. }
  19. return buildId.trim();
  20. }
  21. //# sourceMappingURL=generate-build-id.js.map