version.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.eventCliSession = eventCliSession;
  6. var _path = _interopRequireDefault(require("path"));
  7. function _interopRequireDefault(obj) {
  8. return obj && obj.__esModule ? obj : {
  9. default: obj
  10. };
  11. }
  12. const EVENT_VERSION = "NEXT_CLI_SESSION_STARTED";
  13. function hasBabelConfig(dir) {
  14. try {
  15. var ref4, ref1, ref2, ref3;
  16. const noopFile = _path.default.join(dir, "noop.js");
  17. const res = require("next/dist/compiled/babel/core").loadPartialConfig({
  18. cwd: dir,
  19. filename: noopFile,
  20. sourceFileName: noopFile
  21. });
  22. const isForTooling = ((ref4 = res.options) == null ? void 0 : (ref1 = ref4.presets) == null ? void 0 : ref1.every((e)=>{
  23. var ref;
  24. return (e == null ? void 0 : (ref = e.file) == null ? void 0 : ref.request) === "next/babel";
  25. })) && ((ref2 = res.options) == null ? void 0 : (ref3 = ref2.plugins) == null ? void 0 : ref3.length) === 0;
  26. return res.hasFilesystemConfig() && !isForTooling;
  27. } catch {
  28. return false;
  29. }
  30. }
  31. function eventCliSession(dir, nextConfig, event) {
  32. // This should be an invariant, if it fails our build tooling is broken.
  33. if (typeof "12.3.4" !== "string") {
  34. return [];
  35. }
  36. const { images , i18n } = nextConfig || {};
  37. const payload = {
  38. nextVersion: "12.3.4",
  39. nodeVersion: process.version,
  40. cliCommand: event.cliCommand,
  41. isSrcDir: event.isSrcDir,
  42. hasNowJson: event.hasNowJson,
  43. isCustomServer: event.isCustomServer,
  44. hasNextConfig: nextConfig.configOrigin !== "default",
  45. buildTarget: nextConfig.target === "server" ? "default" : nextConfig.target,
  46. hasWebpackConfig: typeof (nextConfig == null ? void 0 : nextConfig.webpack) === "function",
  47. hasBabelConfig: hasBabelConfig(dir),
  48. imageEnabled: !!images,
  49. imageFutureEnabled: !!images,
  50. basePathEnabled: !!(nextConfig == null ? void 0 : nextConfig.basePath),
  51. i18nEnabled: !!i18n,
  52. locales: (i18n == null ? void 0 : i18n.locales) ? i18n.locales.join(",") : null,
  53. localeDomainsCount: (i18n == null ? void 0 : i18n.domains) ? i18n.domains.length : null,
  54. localeDetectionEnabled: !i18n ? null : i18n.localeDetection !== false,
  55. imageDomainsCount: (images == null ? void 0 : images.domains) ? images.domains.length : null,
  56. imageRemotePatternsCount: (images == null ? void 0 : images.remotePatterns) ? images.remotePatterns.length : null,
  57. imageSizes: (images == null ? void 0 : images.imageSizes) ? images.imageSizes.join(",") : null,
  58. imageLoader: images == null ? void 0 : images.loader,
  59. imageFormats: (images == null ? void 0 : images.formats) ? images.formats.join(",") : null,
  60. trailingSlashEnabled: !!(nextConfig == null ? void 0 : nextConfig.trailingSlash),
  61. reactStrictMode: !!(nextConfig == null ? void 0 : nextConfig.reactStrictMode),
  62. webpackVersion: event.webpackVersion || null
  63. };
  64. return [
  65. {
  66. eventName: EVENT_VERSION,
  67. payload
  68. }
  69. ];
  70. }
  71. //# sourceMappingURL=version.js.map