@netlify/plugin-nextjs 4.41.3 → 5.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/README.md +61 -17
  2. package/dist/build/cache.js +15 -0
  3. package/dist/build/content/prerendered.js +16 -0
  4. package/dist/build/content/server.js +18 -0
  5. package/dist/build/content/static.js +20 -0
  6. package/dist/build/functions/edge.js +14 -0
  7. package/dist/build/functions/server.js +16 -0
  8. package/dist/build/plugin-context.js +17 -0
  9. package/dist/esm-chunks/chunk-4AJYXTWN.js +17 -0
  10. package/dist/esm-chunks/chunk-62KDS27E.js +77 -0
  11. package/dist/esm-chunks/chunk-AVWFCGVE.js +5536 -0
  12. package/dist/esm-chunks/chunk-B6QMRLBH.js +255 -0
  13. package/dist/esm-chunks/chunk-G2VRYWGL.js +107 -0
  14. package/dist/esm-chunks/chunk-G3GM7JNF.js +92 -0
  15. package/dist/esm-chunks/chunk-GGHAQM5D.js +28 -0
  16. package/dist/esm-chunks/chunk-HPGTYMVD.js +113 -0
  17. package/dist/esm-chunks/chunk-PEBUKFKH.js +89 -0
  18. package/dist/esm-chunks/chunk-R4NHZWGU.js +32 -0
  19. package/dist/esm-chunks/chunk-RSKIKBZH.js +44 -0
  20. package/dist/esm-chunks/chunk-XD5TSLZO.js +85 -0
  21. package/dist/esm-chunks/chunk-ZBX3SNQG.js +561 -0
  22. package/dist/index.js +66 -0
  23. package/dist/run/config.js +18 -0
  24. package/dist/run/constants.js +15 -0
  25. package/dist/run/handlers/cache.cjs +849 -0
  26. package/dist/run/handlers/server.js +3289 -0
  27. package/dist/run/headers.js +19 -0
  28. package/dist/run/next.cjs +1055 -0
  29. package/dist/run/revalidate.js +13 -0
  30. package/edge-runtime/README.md +29 -0
  31. package/edge-runtime/lib/headers.ts +26 -0
  32. package/edge-runtime/lib/middleware.ts +60 -0
  33. package/edge-runtime/lib/next-request.ts +59 -0
  34. package/edge-runtime/lib/response.ts +145 -0
  35. package/edge-runtime/lib/util.ts +26 -0
  36. package/edge-runtime/middleware.ts +40 -0
  37. package/edge-runtime/shim/index.js +8 -0
  38. package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +1 -1
  39. package/edge-runtime/vendor/import_map.json +13 -0
  40. package/edge-runtime/vendor.ts +18 -0
  41. package/manifest.yml +1 -1
  42. package/package.json +23 -60
  43. package/index.js +0 -1
  44. package/lib/constants.js +0 -56
  45. package/lib/helpers/analysis.js +0 -115
  46. package/lib/helpers/cache.js +0 -46
  47. package/lib/helpers/compiler.js +0 -119
  48. package/lib/helpers/config.js +0 -192
  49. package/lib/helpers/dev.js +0 -20
  50. package/lib/helpers/edge.js +0 -328
  51. package/lib/helpers/files.js +0 -335
  52. package/lib/helpers/flags.js +0 -46
  53. package/lib/helpers/functions.js +0 -437
  54. package/lib/helpers/functionsMetaData.js +0 -46
  55. package/lib/helpers/matchers.js +0 -41
  56. package/lib/helpers/middlewareWatcher.js +0 -12
  57. package/lib/helpers/pack.js +0 -41
  58. package/lib/helpers/redirects.js +0 -246
  59. package/lib/helpers/types.js +0 -2
  60. package/lib/helpers/utils.js +0 -226
  61. package/lib/helpers/verification.js +0 -182
  62. package/lib/index.js +0 -194
  63. package/lib/templates/blobStorage.js +0 -30
  64. package/lib/templates/getApiHandler.js +0 -120
  65. package/lib/templates/getHandler.js +0 -201
  66. package/lib/templates/getPageResolver.js +0 -54
  67. package/lib/templates/handlerUtils.js +0 -268
  68. package/lib/templates/ipx.js +0 -13
  69. package/lib/templates/requireHooks.js +0 -105
  70. package/lib/templates/server.js +0 -159
  71. package/lib/templates/vendor.js +0 -20
  72. package/src/templates/edge/bundle.js +0 -8
  73. package/src/templates/edge/function-runtime.ts +0 -24
  74. package/src/templates/edge/imageconfig.json +0 -3
  75. package/src/templates/edge/ipx.ts +0 -5
  76. package/src/templates/edge/matchers.json +0 -1
  77. package/src/templates/edge/middleware-runtime.ts +0 -62
  78. package/src/templates/edge/next-dev.js +0 -104
  79. package/src/templates/edge/rsc-data.ts +0 -5
  80. package/src/templates/edge/shims.js +0 -77
  81. package/src/templates/edge-shared/next-utils.ts +0 -407
  82. package/src/templates/edge-shared/nextConfig.json +0 -3
  83. package/src/templates/edge-shared/prerender-manifest.json +0 -7
  84. package/src/templates/edge-shared/rsc-data.ts +0 -78
  85. package/src/templates/edge-shared/utils.test.ts +0 -114
  86. package/src/templates/edge-shared/utils.ts +0 -315
  87. package/src/templates/vendor/import_map.json +0 -13
  88. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/fmt/colors.ts +0 -0
  89. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/_diff.ts +0 -0
  90. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/asserts.ts +0 -0
  91. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/asserts.ts +0 -0
  92. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/os.ts +0 -0
  93. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/abortable.ts +0 -0
  94. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deadline.ts +0 -0
  95. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/debounce.ts +0 -0
  96. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deferred.ts +0 -0
  97. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/delay.ts +0 -0
  98. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mod.ts +0 -0
  99. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +0 -0
  100. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/pool.ts +0 -0
  101. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/retry.ts +0 -0
  102. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/tee.ts +0 -0
  103. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +0 -0
  104. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +0 -0
  105. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +0 -0
  106. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64.ts +0 -0
  107. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64url.ts +0 -0
  108. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/flags/mod.ts +0 -0
  109. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/colors.ts +0 -0
  110. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/printf.ts +0 -0
  111. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/http/cookie.ts +0 -0
  112. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_core.ts +0 -0
  113. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.d.ts +0 -0
  114. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.mjs +0 -0
  115. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_global.d.ts +0 -0
  116. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_next_tick.ts +0 -0
  117. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +0 -0
  118. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/process.ts +0 -0
  119. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +0 -0
  120. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +0 -0
  121. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.d.ts +0 -0
  122. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.mjs +0 -0
  123. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +0 -0
  124. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_utils.ts +0 -0
  125. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assert.ts +0 -0
  126. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assertion_error.ts +0 -0
  127. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/async_hooks.ts +0 -0
  128. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/buffer.ts +0 -0
  129. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/events.ts +0 -0
  130. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +0 -0
  131. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +0 -0
  132. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +0 -0
  133. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +0 -0
  134. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +0 -0
  135. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/errors.ts +0 -0
  136. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +0 -0
  137. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +0 -0
  138. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/net.ts +0 -0
  139. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +0 -0
  140. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/options.ts +0 -0
  141. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +0 -0
  142. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +0 -0
  143. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +0 -0
  144. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +0 -0
  145. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +0 -0
  146. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +0 -0
  147. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +0 -0
  148. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +0 -0
  149. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +0 -0
  150. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +0 -0
  151. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +0 -0
  152. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util.mjs +0 -0
  153. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +0 -0
  154. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +0 -0
  155. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +0 -0
  156. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +0 -0
  157. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +0 -0
  158. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +0 -0
  159. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +0 -0
  160. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +0 -0
  161. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +0 -0
  162. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +0 -0
  163. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +0 -0
  164. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +0 -0
  165. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +0 -0
  166. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +0 -0
  167. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +0 -0
  168. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +0 -0
  169. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +0 -0
  170. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +0 -0
  171. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +0 -0
  172. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +0 -0
  173. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +0 -0
  174. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +0 -0
  175. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +0 -0
  176. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +0 -0
  177. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +0 -0
  178. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +0 -0
  179. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +0 -0
  180. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +0 -0
  181. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +0 -0
  182. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +0 -0
  183. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +0 -0
  184. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +0 -0
  185. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +0 -0
  186. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +0 -0
  187. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +0 -0
  188. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +0 -0
  189. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +0 -0
  190. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +0 -0
  191. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +0 -0
  192. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +0 -0
  193. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +0 -0
  194. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +0 -0
  195. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +0 -0
  196. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +0 -0
  197. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +0 -0
  198. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +0 -0
  199. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +0 -0
  200. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +0 -0
  201. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +0 -0
  202. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +0 -0
  203. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +0 -0
  204. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +0 -0
  205. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +0 -0
  206. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +0 -0
  207. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +0 -0
  208. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +0 -0
  209. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +0 -0
  210. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +0 -0
  211. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +0 -0
  212. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +0 -0
  213. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/process.ts +0 -0
  214. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/stream.ts +0 -0
  215. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/string_decoder.ts +0 -0
  216. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util/types.ts +0 -0
  217. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util.ts +0 -0
  218. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_constants.ts +0 -0
  219. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_interface.ts +0 -0
  220. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_util.ts +0 -0
  221. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/common.ts +0 -0
  222. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/glob.ts +0 -0
  223. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/mod.ts +0 -0
  224. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/posix.ts +0 -0
  225. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/separator.ts +0 -0
  226. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/win32.ts +0 -0
  227. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/streams/write_all.ts +0 -0
  228. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_diff.ts +0 -0
  229. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_format.ts +0 -0
  230. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/asserts.ts +0 -0
  231. /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/types.d.ts +0 -0
  232. /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +0 -0
  233. /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +0 -0
  234. /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +0 -0
  235. /package/{src/templates → edge-runtime}/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +0 -0
  236. /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +0 -0
  237. /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +0 -0
  238. /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +0 -0
  239. /package/{src/templates → edge-runtime}/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +0 -0
@@ -1,246 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateRedirects = exports.generateDynamicRewrites = exports.generateStaticRedirects = void 0;
7
- const chalk_1 = require("chalk");
8
- const destr_1 = __importDefault(require("destr"));
9
- const fs_extra_1 = require("fs-extra");
10
- const outdent_1 = require("outdent");
11
- const pathe_1 = require("pathe");
12
- const constants_1 = require("../constants");
13
- const edge_1 = require("./edge");
14
- const files_1 = require("./files");
15
- const utils_1 = require("./utils");
16
- const matchesMiddleware = (middleware, route) => middleware.some((middlewarePath) => route.startsWith(middlewarePath));
17
- const generateLocaleRedirects = ({ i18n, basePath, trailingSlash, }) => {
18
- const redirects = [];
19
- // If the cookie is set, we need to redirect at the origin
20
- redirects.push({
21
- from: `${basePath}/`,
22
- to: constants_1.HANDLER_FUNCTION_PATH,
23
- status: 200,
24
- force: true,
25
- conditions: {
26
- Cookie: ['NEXT_LOCALE'],
27
- },
28
- });
29
- i18n.locales.forEach((locale) => {
30
- if (locale === i18n.defaultLocale) {
31
- return;
32
- }
33
- redirects.push({
34
- from: `${basePath}/`,
35
- to: `${basePath}/${locale}${trailingSlash ? '/' : ''}`,
36
- status: 301,
37
- conditions: {
38
- Language: [locale],
39
- },
40
- force: true,
41
- });
42
- });
43
- return redirects;
44
- };
45
- const generateStaticRedirects = ({ netlifyConfig, nextConfig: { i18n, basePath }, }) => {
46
- // Static files are in `static`
47
- netlifyConfig.redirects.push({ from: `${basePath}/_next/static/*`, to: `/static/:splat`, status: 200 });
48
- if (i18n) {
49
- netlifyConfig.redirects.push({ from: `${basePath}/:locale/_next/static/*`, to: `/static/:splat`, status: 200 });
50
- }
51
- };
52
- exports.generateStaticRedirects = generateStaticRedirects;
53
- /**
54
- * Routes that match origin middleware need to always use the SSR function
55
- * This generates a rewrite for every middleware in every locale, both with and without a splat
56
- */
57
- const generateMiddlewareRewrites = ({ basePath, middleware, i18n, buildId }) => {
58
- const handlerRewrite = (from) => ({
59
- from: `${basePath}${from}`,
60
- to: constants_1.HANDLER_FUNCTION_PATH,
61
- status: 200,
62
- });
63
- return (middleware
64
- .map((route) => {
65
- var _a;
66
- const unlocalized = [handlerRewrite(`${route}`), handlerRewrite(`${route}/*`)];
67
- if (((_a = i18n === null || i18n === void 0 ? void 0 : i18n.locales) === null || _a === void 0 ? void 0 : _a.length) > 0) {
68
- const localized = i18n.locales.map((locale) => [
69
- handlerRewrite(`/${locale}${route}`),
70
- handlerRewrite(`/${locale}${route}/*`),
71
- handlerRewrite(`/_next/data/${buildId}/${locale}${route}/*`),
72
- ]);
73
- // With i18n, all data routes are prefixed with the locale, but the HTML also has the unprefixed default
74
- return [...unlocalized, ...localized];
75
- }
76
- return [...unlocalized, handlerRewrite(`/_next/data/${buildId}${route}/*`)];
77
- })
78
- // Flatten the array of arrays. Can't use flatMap as it might be 2 levels deep
79
- .flat(2));
80
- };
81
- const generateStaticIsrRewrites = ({ staticRouteEntries, basePath, i18n, buildId, middleware, appPathRoutes, }) => {
82
- const staticIsrRoutesThatMatchMiddleware = [];
83
- const staticRoutePaths = new Set();
84
- const staticIsrRewrites = [];
85
- staticRouteEntries.forEach(([route, { initialRevalidateSeconds, dataRoute, srcRoute }]) => {
86
- if ((0, utils_1.isApiRoute)(route) || (0, utils_1.is404Route)(route, i18n)) {
87
- return;
88
- }
89
- staticRoutePaths.add(route);
90
- if (initialRevalidateSeconds === false) {
91
- // These can be ignored, as they're static files handled by the CDN
92
- return;
93
- }
94
- // appDir routes are a different format, so we need to handle them differently
95
- const isAppDir = (0, edge_1.isAppDirRoute)(srcRoute, appPathRoutes);
96
- // The default locale is served from the root, not the localised path
97
- if ((i18n === null || i18n === void 0 ? void 0 : i18n.defaultLocale) && (route.startsWith(`/${i18n.defaultLocale}/`) || route === `/${i18n.defaultLocale}`)) {
98
- route = route.slice(i18n.defaultLocale.length + 1) || '/';
99
- staticRoutePaths.add(route);
100
- if (matchesMiddleware(middleware, route)) {
101
- staticIsrRoutesThatMatchMiddleware.push(route);
102
- }
103
- staticIsrRewrites.push(...(0, utils_1.redirectsForNextRouteWithData)({
104
- route,
105
- dataRoute: isAppDir ? dataRoute : (0, utils_1.routeToDataRoute)(route, buildId, i18n.defaultLocale),
106
- basePath,
107
- to: constants_1.ODB_FUNCTION_PATH,
108
- force: true,
109
- }));
110
- }
111
- else if (matchesMiddleware(middleware, route)) {
112
- // Routes that match origin middleware can't use the ODB. Edge middleware will always return false
113
- staticIsrRoutesThatMatchMiddleware.push(route);
114
- }
115
- else {
116
- // ISR routes use the ODB handler
117
- staticIsrRewrites.push(
118
- // No i18n, because the route is already localized
119
- ...(0, utils_1.redirectsForNextRoute)({
120
- route,
121
- basePath,
122
- to: constants_1.ODB_FUNCTION_PATH,
123
- force: true,
124
- buildId,
125
- dataRoute: isAppDir ? dataRoute : null,
126
- i18n: null,
127
- }));
128
- }
129
- });
130
- return {
131
- staticRoutePaths,
132
- staticIsrRoutesThatMatchMiddleware,
133
- staticIsrRewrites,
134
- };
135
- };
136
- /**
137
- * Generate rewrites for all dynamic routes
138
- */
139
- const generateDynamicRewrites = ({ dynamicRoutes, prerenderedDynamicRoutes, middleware, basePath, buildId, i18n, is404Isr, appPathRoutes, }) => {
140
- const dynamicRewrites = [];
141
- const dynamicRoutesThatMatchMiddleware = [];
142
- dynamicRoutes.forEach((route) => {
143
- if ((0, utils_1.isApiRoute)(route.page) || (0, utils_1.is404Route)(route.page, i18n)) {
144
- return;
145
- }
146
- if (route.page in prerenderedDynamicRoutes) {
147
- if (matchesMiddleware(middleware, route.page)) {
148
- dynamicRoutesThatMatchMiddleware.push(route.page);
149
- }
150
- else if ((0, edge_1.isAppDirRoute)(route.page, appPathRoutes)) {
151
- dynamicRewrites.push(...(0, utils_1.redirectsForNextRoute)({
152
- route: route.page,
153
- buildId,
154
- basePath,
155
- to: constants_1.ODB_FUNCTION_PATH,
156
- i18n,
157
- dataRoute: prerenderedDynamicRoutes[route.page].dataRoute,
158
- withData: true,
159
- }));
160
- }
161
- else if (prerenderedDynamicRoutes[route.page].fallback === false &&
162
- !is404Isr &&
163
- !(0, destr_1.default)(process.env.LEGACY_FALLBACK_FALSE)) {
164
- dynamicRewrites.push(...(0, utils_1.redirectsForNext404Route)({ route: route.page, buildId, basePath, i18n }));
165
- }
166
- else {
167
- dynamicRewrites.push(...(0, utils_1.redirectsForNextRoute)({ route: route.page, buildId, basePath, to: constants_1.ODB_FUNCTION_PATH, i18n }));
168
- }
169
- }
170
- else {
171
- // If the route isn't prerendered, it's SSR
172
- dynamicRewrites.push(...(0, utils_1.redirectsForNextRoute)({ route: route.page, buildId, basePath, to: constants_1.HANDLER_FUNCTION_PATH, i18n }));
173
- }
174
- });
175
- return {
176
- dynamicRoutesThatMatchMiddleware,
177
- dynamicRewrites,
178
- };
179
- };
180
- exports.generateDynamicRewrites = generateDynamicRewrites;
181
- const generateRedirects = async ({ netlifyConfig, nextConfig: { i18n, basePath, trailingSlash, appDir }, buildId, apiLambdas, }) => {
182
- const { dynamicRoutes: prerenderedDynamicRoutes, routes: prerenderedStaticRoutes } = await (0, fs_extra_1.readJSON)((0, pathe_1.join)(netlifyConfig.build.publish, 'prerender-manifest.json'));
183
- const { dynamicRoutes, staticRoutes } = await (0, fs_extra_1.readJSON)((0, pathe_1.join)(netlifyConfig.build.publish, 'routes-manifest.json'));
184
- if (i18n && i18n.localeDetection !== false) {
185
- netlifyConfig.redirects.push(...generateLocaleRedirects({ i18n, basePath, trailingSlash }));
186
- }
187
- // This is only used in prod, so dev uses `next dev` directly
188
- netlifyConfig.redirects.push(
189
- // API routes always need to be served from the regular function
190
- ...(0, utils_1.getApiRewrites)(basePath, apiLambdas),
191
- // Preview mode gets forced to the function, to bypass pre-rendered pages, but static files need to be skipped
192
- ...(await (0, utils_1.getPreviewRewrites)({ basePath, appDir })));
193
- const middleware = await (0, files_1.getMiddleware)(netlifyConfig.build.publish);
194
- netlifyConfig.redirects.push(...generateMiddlewareRewrites({ basePath, i18n, middleware, buildId }));
195
- const appPathRoutes = await (0, edge_1.loadAppPathRoutesManifest)(netlifyConfig);
196
- const staticRouteEntries = Object.entries(prerenderedStaticRoutes);
197
- const is404Isr = staticRouteEntries.some(([route, { initialRevalidateSeconds }]) => (0, utils_1.is404Route)(route, i18n) && initialRevalidateSeconds !== false);
198
- const routesThatMatchMiddleware = [];
199
- const { staticRoutePaths, staticIsrRewrites, staticIsrRoutesThatMatchMiddleware } = generateStaticIsrRewrites({
200
- staticRouteEntries,
201
- basePath,
202
- i18n,
203
- buildId,
204
- middleware,
205
- appPathRoutes,
206
- });
207
- routesThatMatchMiddleware.push(...staticIsrRoutesThatMatchMiddleware);
208
- netlifyConfig.redirects.push(...staticIsrRewrites);
209
- // Add rewrites for all static SSR routes. This is Next 12+
210
- staticRoutes === null || staticRoutes === void 0 ? void 0 : staticRoutes.forEach((route) => {
211
- if (staticRoutePaths.has(route.page) || (0, utils_1.isApiRoute)(route.page) || (0, utils_1.is404Route)(route.page)) {
212
- // Prerendered static routes are either handled by the CDN or are ISR
213
- return;
214
- }
215
- netlifyConfig.redirects.push(...(0, utils_1.redirectsForNextRoute)({ route: route.page, buildId, basePath, to: constants_1.HANDLER_FUNCTION_PATH, i18n }));
216
- });
217
- // Add rewrites for all dynamic routes (both SSR and ISR)
218
- const { dynamicRewrites, dynamicRoutesThatMatchMiddleware } = (0, exports.generateDynamicRewrites)({
219
- dynamicRoutes,
220
- prerenderedDynamicRoutes,
221
- middleware,
222
- basePath,
223
- buildId,
224
- i18n,
225
- is404Isr,
226
- appPathRoutes,
227
- });
228
- netlifyConfig.redirects.push(...dynamicRewrites);
229
- routesThatMatchMiddleware.push(...dynamicRoutesThatMatchMiddleware);
230
- // Final fallback
231
- netlifyConfig.redirects.push({
232
- from: `${basePath}/*`,
233
- to: constants_1.HANDLER_FUNCTION_PATH,
234
- status: 200,
235
- });
236
- const middlewareMatches = new Set(routesThatMatchMiddleware).size;
237
- if (middlewareMatches > 0) {
238
- console.log((0, chalk_1.yellowBright)((0, outdent_1.outdent) `
239
- There ${middlewareMatches === 1
240
- ? `is one statically-generated or ISR route that matches`
241
- : `are ${middlewareMatches} statically-generated or ISR routes that match`} a middleware function. Matched routes will always be served from the SSR function and will not use ISR or be served from the CDN.
242
- If this was not intended, ensure that your middleware only matches routes that you intend to use SSR.
243
- `));
244
- }
245
- };
246
- exports.generateRedirects = generateRedirects;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,226 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.escapeStringRegexp = exports.getRemotePatterns = exports.isBundleSizeCheckDisabled = exports.getCustomImageResponseHeaders = exports.isNextAuthInstalled = exports.findModuleFromBase = exports.shouldSkip = exports.getPreviewRewrites = exports.getApiRewrites = exports.redirectsForNextRouteWithData = exports.redirectsForNext404Route = exports.redirectsForNextRoute = exports.is404Route = exports.isApiRoute = exports.localizeRoute = exports.routeToDataRoute = exports.generateNetlifyRoutes = exports.toNetlifyRoute = exports.getFunctionNameForPage = void 0;
7
- const globby_1 = __importDefault(require("globby"));
8
- const pathe_1 = require("pathe");
9
- const constants_1 = require("../constants");
10
- const RESERVED_FILENAME = /[^\w_-]/g;
11
- /**
12
- * Given a Next route, generates a valid Netlify function name.
13
- * If "background" is true then the function name will have `-background`
14
- * appended to it, meaning that it is executed as a background function.
15
- */
16
- const getFunctionNameForPage = (page, background = false) => `${page
17
- .replace(constants_1.CATCH_ALL_REGEX, '_$1-SPLAT')
18
- .replace(constants_1.OPTIONAL_CATCH_ALL_REGEX, '-SPLAT')
19
- .replace(constants_1.DYNAMIC_PARAMETER_REGEX, '_$1-PARAM')
20
- .replace(RESERVED_FILENAME, '_')}-${background ? 'background' : 'handler'}`;
21
- exports.getFunctionNameForPage = getFunctionNameForPage;
22
- const toNetlifyRoute = (nextRoute) => {
23
- const netlifyRoutes = [nextRoute];
24
- // If the route is an optional catch-all route, we need to add a second
25
- // Netlify route for the base path (when no parameters are present).
26
- // The file ending must be present!
27
- if (constants_1.OPTIONAL_CATCH_ALL_REGEX.test(nextRoute)) {
28
- let netlifyRoute = nextRoute.replace(constants_1.OPTIONAL_CATCH_ALL_REGEX, '$2');
29
- // create an empty string, but actually needs to be a forward slash
30
- if (netlifyRoute === '') {
31
- netlifyRoute = '/';
32
- }
33
- // When optional catch-all route is at top-level, the regex on line 19 will
34
- // create an incorrect route for the data route. For example, it creates
35
- // /_next/data/%BUILDID%.json, but NextJS looks for
36
- // /_next/data/%BUILDID%/index.json
37
- netlifyRoute = netlifyRoute.replace(/(\/_next\/data\/[^/]+).json/, '$1/index.json');
38
- // Add second route to the front of the array
39
- netlifyRoutes.unshift(netlifyRoute);
40
- }
41
- return netlifyRoutes.map((route) => route
42
- // Replace catch-all, e.g., [...slug]
43
- .replace(constants_1.CATCH_ALL_REGEX, '/:$1/*')
44
- // Replace optional catch-all, e.g., [[...slug]]
45
- .replace(constants_1.OPTIONAL_CATCH_ALL_REGEX, '/*')
46
- // Replace dynamic parameters, e.g., [id]
47
- .replace(constants_1.DYNAMIC_PARAMETER_REGEX, '/:$1'));
48
- };
49
- exports.toNetlifyRoute = toNetlifyRoute;
50
- const generateNetlifyRoutes = ({ route, dataRoute, withData = true, }) => [...(withData ? (0, exports.toNetlifyRoute)(dataRoute) : []), ...(0, exports.toNetlifyRoute)(route)];
51
- exports.generateNetlifyRoutes = generateNetlifyRoutes;
52
- const routeToDataRoute = (route, buildId, locale) => `/_next/data/${buildId}${locale ? `/${locale}` : ''}${route === '/' ? (locale ? '' : '/index') : route}.json`;
53
- exports.routeToDataRoute = routeToDataRoute;
54
- // Default locale is served from root, not localized
55
- const localizeRoute = (route, locale, defaultLocale) => locale === defaultLocale ? route : `/${locale}${route}`;
56
- exports.localizeRoute = localizeRoute;
57
- const netlifyRoutesForNextRoute = ({ route, buildId, i18n, withData = true, dataRoute, }) => {
58
- var _a;
59
- if (!((_a = i18n === null || i18n === void 0 ? void 0 : i18n.locales) === null || _a === void 0 ? void 0 : _a.length)) {
60
- return (0, exports.generateNetlifyRoutes)({ route, dataRoute: dataRoute || (0, exports.routeToDataRoute)(route, buildId), withData }).map((redirect) => ({
61
- redirect,
62
- locale: false,
63
- }));
64
- }
65
- const { locales, defaultLocale } = i18n;
66
- const routes = [];
67
- locales.forEach((locale) => {
68
- // Data route is always localized, except for appDir
69
- const localizedDataRoute = dataRoute
70
- ? (0, exports.localizeRoute)(dataRoute, locale, defaultLocale)
71
- : (0, exports.routeToDataRoute)(route, buildId, locale);
72
- routes.push(...(0, exports.generateNetlifyRoutes)({
73
- route: (0, exports.localizeRoute)(route, locale, defaultLocale),
74
- dataRoute: localizedDataRoute,
75
- withData,
76
- }).map((redirect) => ({
77
- redirect,
78
- locale,
79
- })));
80
- });
81
- return routes;
82
- };
83
- const isApiRoute = (route) => route.startsWith('/api/') || route === '/api';
84
- exports.isApiRoute = isApiRoute;
85
- const is404Route = (route, i18n) => i18n ? i18n.locales.some((locale) => route === `/${locale}/404`) : route === '/404';
86
- exports.is404Route = is404Route;
87
- const redirectsForNextRoute = ({ route, buildId, basePath, to, i18n, status = 200, force = false, withData = true, dataRoute, }) => netlifyRoutesForNextRoute({ route, buildId, i18n, withData, dataRoute }).map(({ redirect }) => ({
88
- from: `${basePath}${redirect}`,
89
- to,
90
- status,
91
- force,
92
- }));
93
- exports.redirectsForNextRoute = redirectsForNextRoute;
94
- const redirectsForNext404Route = ({ route, buildId, basePath, i18n, force = false, }) => netlifyRoutesForNextRoute({ route, buildId, i18n }).map(({ redirect, locale }) => ({
95
- from: `${basePath}${redirect}`,
96
- to: locale ? `${basePath}/${locale}/404.html` : `${basePath}/404.html`,
97
- status: 404,
98
- force,
99
- }));
100
- exports.redirectsForNext404Route = redirectsForNext404Route;
101
- const redirectsForNextRouteWithData = ({ route, dataRoute, basePath, to, status = 200, force = false, }) => (0, exports.generateNetlifyRoutes)({ route, dataRoute, withData: true }).map((redirect) => ({
102
- from: `${basePath}${redirect}`,
103
- to,
104
- status,
105
- force,
106
- }));
107
- exports.redirectsForNextRouteWithData = redirectsForNextRouteWithData;
108
- const getApiRewrites = (basePath, apiLambdas) => {
109
- const apiRewrites = apiLambdas.flatMap((lambda) => lambda.routes.map((apiRoute) => {
110
- const [from] = (0, exports.toNetlifyRoute)(`${basePath}${apiRoute.route}`);
111
- // Scheduled functions can't be invoked directly, so we 404 them.
112
- if (apiRoute.config.type === "experimental-scheduled" /* ApiRouteType.SCHEDULED */) {
113
- return { from, to: '/404.html', status: 404 };
114
- }
115
- return {
116
- from,
117
- to: `/.netlify/functions/${lambda.functionName}`,
118
- status: 200,
119
- };
120
- }));
121
- return [
122
- ...apiRewrites,
123
- {
124
- from: `${basePath}/api/*`,
125
- to: constants_1.HANDLER_FUNCTION_PATH,
126
- status: 200,
127
- },
128
- ];
129
- };
130
- exports.getApiRewrites = getApiRewrites;
131
- const getPreviewRewrites = async ({ basePath, appDir }) => {
132
- const publicFiles = await (0, globby_1.default)('**/*', { cwd: (0, pathe_1.join)(appDir, 'public') });
133
- // Preview mode gets forced to the function, to bypass pre-rendered pages, but static files need to be skipped
134
- return [
135
- ...publicFiles.map((file) => ({
136
- from: `${basePath}/${file}`,
137
- // This is a no-op, but we do it to stop it matching the following rule
138
- to: `${basePath}/${file}`,
139
- conditions: { Cookie: ['__prerender_bypass', '__next_preview_data'] },
140
- status: 200,
141
- })),
142
- {
143
- from: `${basePath}/*`,
144
- to: constants_1.HANDLER_FUNCTION_PATH,
145
- status: 200,
146
- conditions: { Cookie: ['__prerender_bypass', '__next_preview_data'] },
147
- force: true,
148
- },
149
- ];
150
- };
151
- exports.getPreviewRewrites = getPreviewRewrites;
152
- const shouldSkip = () => process.env.NEXT_PLUGIN_FORCE_RUN === 'false' ||
153
- process.env.NEXT_PLUGIN_FORCE_RUN === '0' ||
154
- process.env.NETLIFY_NEXT_PLUGIN_SKIP === 'true' ||
155
- process.env.NETLIFY_NEXT_PLUGIN_SKIP === '1';
156
- exports.shouldSkip = shouldSkip;
157
- /**
158
- * Given an array of base paths and candidate modules, return the first one that exists
159
- */
160
- const findModuleFromBase = ({ paths, candidates }) => {
161
- for (const candidate of candidates) {
162
- try {
163
- const modulePath = require.resolve(candidate, { paths });
164
- if (modulePath) {
165
- return modulePath;
166
- }
167
- }
168
- catch {
169
- // Ignore the error
170
- }
171
- }
172
- // if we couldn't find a module from paths, let's try to resolve from here
173
- for (const candidate of candidates) {
174
- try {
175
- const modulePath = require.resolve(candidate);
176
- if (modulePath) {
177
- return modulePath;
178
- }
179
- }
180
- catch {
181
- // Ignore the error
182
- }
183
- }
184
- return null;
185
- };
186
- exports.findModuleFromBase = findModuleFromBase;
187
- const isNextAuthInstalled = () => {
188
- try {
189
- // eslint-disable-next-line import/no-unassigned-import, import/no-extraneous-dependencies, n/no-extraneous-require
190
- require('next-auth');
191
- return true;
192
- }
193
- catch {
194
- // Ignore the MODULE_NOT_FOUND error
195
- return false;
196
- }
197
- };
198
- exports.isNextAuthInstalled = isNextAuthInstalled;
199
- const getCustomImageResponseHeaders = (headers) => {
200
- const customImageResponseHeaders = headers.find((header) => { var _a; return (_a = header.for) === null || _a === void 0 ? void 0 : _a.startsWith('/_next/image/'); });
201
- if (customImageResponseHeaders) {
202
- return customImageResponseHeaders === null || customImageResponseHeaders === void 0 ? void 0 : customImageResponseHeaders.values;
203
- }
204
- return null;
205
- };
206
- exports.getCustomImageResponseHeaders = getCustomImageResponseHeaders;
207
- const isBundleSizeCheckDisabled = () => process.env.DISABLE_BUNDLE_ZIP_SIZE_CHECK === '1' || process.env.DISABLE_BUNDLE_ZIP_SIZE_CHECK === 'true';
208
- exports.isBundleSizeCheckDisabled = isBundleSizeCheckDisabled;
209
- const getRemotePatterns = (experimental, images) => {
210
- var _a;
211
- // Where remote patterns is configured pre-v12.2.5
212
- if ((_a = experimental.images) === null || _a === void 0 ? void 0 : _a.remotePatterns) {
213
- return experimental.images.remotePatterns;
214
- }
215
- // Where remote patterns is configured after v12.2.5
216
- if (images.remotePatterns) {
217
- return images.remotePatterns || [];
218
- }
219
- return [];
220
- };
221
- exports.getRemotePatterns = getRemotePatterns;
222
- // Taken from next/src/shared/lib/escape-regexp.ts
223
- const reHasRegExp = /[|\\{}()[\]^$+*?.-]/;
224
- const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g;
225
- const escapeStringRegexp = (str) => (reHasRegExp.test(str) ? str.replace(reReplaceRegExp, '\\$&') : str);
226
- exports.escapeStringRegexp = escapeStringRegexp;
@@ -1,182 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.warnForRootRedirects = exports.warnForProblematicUserRewrites = exports.getProblematicUserRewrites = exports.checkZipSize = exports.checkForRootPublish = exports.checkNextSiteHasBuilt = exports.checkForOldFunctions = exports.verifyNetlifyBuildVersion = void 0;
30
- const fs_1 = require("fs");
31
- const path_1 = __importStar(require("path"));
32
- const chalk_1 = require("chalk");
33
- const node_stream_zip_1 = require("node-stream-zip");
34
- const outdent_1 = require("outdent");
35
- const pretty_bytes_1 = __importDefault(require("pretty-bytes"));
36
- const semver_1 = require("semver");
37
- const constants_1 = require("../constants");
38
- const utils_1 = require("./utils");
39
- // This is when nft support was added
40
- const REQUIRED_BUILD_VERSION = '>=18.16.0';
41
- const verifyNetlifyBuildVersion = ({ IS_LOCAL, NETLIFY_BUILD_VERSION, failBuild, }) => {
42
- // We check for build version because that's what's available to us, but prompt about the cli because that's what they can upgrade
43
- if (IS_LOCAL && !(0, semver_1.satisfies)(NETLIFY_BUILD_VERSION, REQUIRED_BUILD_VERSION, { includePrerelease: true })) {
44
- return failBuild((0, outdent_1.outdent) `
45
- This version of the Next Runtime requires netlify-cli@6.12.4 or higher. Please upgrade and try again.
46
- You can do this by running: "npm install -g netlify-cli@latest" or "yarn global add netlify-cli@latest"
47
- `);
48
- }
49
- };
50
- exports.verifyNetlifyBuildVersion = verifyNetlifyBuildVersion;
51
- const checkForOldFunctions = async ({ functions }) => {
52
- const allOldFunctions = await functions.list();
53
- const oldFunctions = allOldFunctions.filter(({ name }) => name.startsWith('next_'));
54
- if (oldFunctions.length !== 0) {
55
- console.log((0, chalk_1.yellowBright)((0, outdent_1.outdent) `
56
- We have found the following functions in your site that seem to be left over from the old Next.js plugin (v3). We have guessed this because the name starts with "next_".
57
-
58
- ${(0, chalk_1.reset)(oldFunctions.map(({ name }) => `- ${name}`).join('\n'))}
59
-
60
- If they were created by the old plugin, these functions are likely to cause errors so should be removed. You can do this by deleting the following directories:
61
-
62
- ${(0, chalk_1.reset)(oldFunctions.map(({ mainFile }) => `- ${path_1.default.relative(process.cwd(), path_1.default.dirname(mainFile))}`).join('\n'))}
63
- `));
64
- }
65
- };
66
- exports.checkForOldFunctions = checkForOldFunctions;
67
- const checkNextSiteHasBuilt = ({ publish, failBuild, }) => {
68
- if (!(0, fs_1.existsSync)(path_1.default.join(publish, 'BUILD_ID'))) {
69
- let outWarning;
70
- if (path_1.default.basename(publish) === 'out') {
71
- outWarning = `Your publish directory is set to "out", but in most cases it should be ".next".`;
72
- }
73
- else if (path_1.default.basename(publish) !== '.next' && (0, fs_1.existsSync)(path_1.default.join('.next', 'BUILD_ID'))) {
74
- outWarning = (0, outdent_1.outdent) `
75
- However, a '.next' directory was found with a production build.
76
- Consider changing your 'publish' directory to '.next'
77
- `;
78
- }
79
- else {
80
- outWarning = `In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.`;
81
- }
82
- return failBuild((0, outdent_1.outdent) `
83
- The directory "${publish}" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
84
- ${outWarning}
85
- If you are using "next export" then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true".
86
- `);
87
- }
88
- if ((0, fs_1.existsSync)(path_1.default.join(publish, 'export-detail.json'))) {
89
- return failBuild((0, outdent_1.outdent) `
90
- Detected that "next export" was run, but site is incorrectly publishing the ".next" directory.
91
- The publish directory should be set to "out", and you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true".
92
- `);
93
- }
94
- };
95
- exports.checkNextSiteHasBuilt = checkNextSiteHasBuilt;
96
- const checkForRootPublish = ({ publish, failBuild, }) => {
97
- if (path_1.default.resolve(publish) === path_1.default.resolve('.')) {
98
- failBuild((0, outdent_1.outdent) `
99
- Your publish directory is pointing to the base directory of your site. This is not supported for Next.js sites, and is probably a mistake.
100
- In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config, or the Next site is in a subdirectory.
101
- `);
102
- }
103
- };
104
- exports.checkForRootPublish = checkForRootPublish;
105
- const checkZipSize = async (file, maxSize = constants_1.LAMBDA_MAX_SIZE, warningSize = constants_1.LAMBDA_WARNING_SIZE) => {
106
- // Requires contacting the Netlify Support team to fully enable.
107
- // Enabling this without contacting them can result in failed deploys.
108
- if ((0, utils_1.isBundleSizeCheckDisabled)()) {
109
- console.warn('Function bundle size check was DISABLED with the DISABLE_BUNDLE_ZIP_SIZE_CHECK environment variable. Your deployment will break if it exceeds the maximum supported size of function zip files in your account.');
110
- return;
111
- }
112
- if (!(0, fs_1.existsSync)(file)) {
113
- console.warn(`Could not check zip size because ${file} does not exist`);
114
- return;
115
- }
116
- const fileSize = await fs_1.promises.stat(file).then(({ size }) => size);
117
- if (fileSize < warningSize) {
118
- return;
119
- }
120
- // We don't fail the build, because the actual hard max size is larger so it might still succeed
121
- console.log((0, chalk_1.yellowBright)((0, outdent_1.outdent) `
122
- The function zip ${(0, chalk_1.blueBright)((0, path_1.relative)(process.cwd(), file))} size is ${(0, pretty_bytes_1.default)(fileSize)}, which is larger than the recommended maximum size of ${(0, pretty_bytes_1.default)(warningSize)}.
123
- This will fail the build if the unzipped size is bigger than the maximum size of ${(0, pretty_bytes_1.default)(maxSize)}.
124
- There are a few reasons this could happen. You may have accidentally bundled a large dependency, or you might have a
125
- large number of pre-rendered pages included.
126
- `));
127
- const zip = new node_stream_zip_1.async({ file });
128
- console.log(`Contains ${await zip.entriesCount} files`);
129
- const sortedFiles = Object.values(await zip.entries()).sort((a, b) => b.size - a.size);
130
- const largest = {};
131
- for (let i = 0; i < 10 && i < sortedFiles.length; i++) {
132
- largest[`${i + 1}`] = {
133
- File: sortedFiles[i].name,
134
- 'Compressed Size': (0, pretty_bytes_1.default)(sortedFiles[i].compressedSize),
135
- 'Uncompressed Size': (0, pretty_bytes_1.default)(sortedFiles[i].size),
136
- };
137
- }
138
- console.log((0, chalk_1.yellowBright) `\n\nThese are the largest files in the zip:`);
139
- console.table(largest);
140
- console.log((0, chalk_1.greenBright) `\n\nFor more information on fixing this, see ${(0, chalk_1.blueBright) `https://ntl.fyi/large-next-functions`}`);
141
- };
142
- exports.checkZipSize = checkZipSize;
143
- const getProblematicUserRewrites = ({ redirects, basePath, }) => {
144
- const userRewrites = [];
145
- for (const redirect of redirects) {
146
- // This is the first of the runtime-generated redirects so we can stop checking
147
- if (redirect.from === `${basePath}/_next/static/*` && redirect.to === `/static/:splat` && redirect.status === 200) {
148
- break;
149
- }
150
- if (
151
- // Redirects are fine
152
- (redirect.status === 200 || redirect.status === 404) &&
153
- // Rewriting to a function is also fine
154
- !redirect.to.startsWith('/.netlify/') &&
155
- // ...so is proxying
156
- !redirect.to.startsWith('http')) {
157
- userRewrites.push(redirect);
158
- }
159
- }
160
- return userRewrites;
161
- };
162
- exports.getProblematicUserRewrites = getProblematicUserRewrites;
163
- const warnForProblematicUserRewrites = ({ redirects, basePath, }) => {
164
- const userRewrites = (0, exports.getProblematicUserRewrites)({ redirects, basePath });
165
- if (userRewrites.length === 0) {
166
- return;
167
- }
168
- console.log((0, chalk_1.yellowBright)((0, outdent_1.outdent) `
169
- You have the following Netlify rewrite${userRewrites.length === 1 ? '' : 's'} that might cause conflicts with the Next.js Runtime:
170
-
171
- ${(0, chalk_1.reset)(userRewrites.map(({ from, to, status }) => `- ${from} ${to} ${status}`).join('\n'))}
172
-
173
- For more information, see https://ntl.fyi/next-rewrites
174
- `));
175
- };
176
- exports.warnForProblematicUserRewrites = warnForProblematicUserRewrites;
177
- const warnForRootRedirects = ({ appDir }) => {
178
- if ((0, fs_1.existsSync)((0, path_1.join)(appDir, '_redirects'))) {
179
- console.log((0, chalk_1.yellowBright)(`You have a "_redirects" file in your root directory, which is not deployed and will be ignored. If you want it to be used, please move it into "public".`));
180
- }
181
- };
182
- exports.warnForRootRedirects = warnForRootRedirects;