@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,46 +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.useBlobsForISRAssets = exports.bundleBasedOnNftFiles = exports.splitApiRoutes = void 0;
7
- const destr_1 = __importDefault(require("destr"));
8
- const fs_extra_1 = require("fs-extra");
9
- const pathe_1 = require("pathe");
10
- /**
11
- * If this flag is enabled, we generate individual Lambda functions for API Routes.
12
- * They're packed together in 50mb chunks to avoid hitting the Lambda size limit.
13
- *
14
- * To prevent bundling times from rising,
15
- * we use the "none" bundling strategy where we fully rely on Next.js' `.nft.json` files.
16
- * This should to a significant speedup, but is still experimental.
17
- *
18
- * If disabled, we bundle all API Routes into a single function.
19
- * This is can lead to large bundle sizes.
20
- *
21
- * Relies on `next-server.js.nft.json`, which is only supported in Next.js 12+.
22
- *
23
- * Disabled by default. Can be overriden using the NEXT_SPLIT_API_ROUTES env var.
24
- */
25
- const splitApiRoutes = (featureFlags, publish) => {
26
- var _a, _b;
27
- const isEnabled = (_b = (_a = (0, destr_1.default)(process.env.NEXT_SPLIT_API_ROUTES)) !== null && _a !== void 0 ? _a : featureFlags.next_split_api_routes) !== null && _b !== void 0 ? _b : false;
28
- if (isEnabled && !(0, fs_extra_1.existsSync)((0, pathe_1.join)(publish, 'next-server.js.nft.json'))) {
29
- console.warn('Trace-based bundling not possible on this version of Next.js. Speed up your builds significantly by upgrading to Next.js v12 or newer.');
30
- return false;
31
- }
32
- return isEnabled;
33
- };
34
- exports.splitApiRoutes = splitApiRoutes;
35
- const bundleBasedOnNftFiles = (featureFlags) => {
36
- var _a, _b;
37
- const isEnabled = (_b = (_a = (0, destr_1.default)(process.env.NEXT_BUNDLE_BASED_ON_NFT_FILES)) !== null && _a !== void 0 ? _a : featureFlags.next_bundle_based_on_nft_files) !== null && _b !== void 0 ? _b : false;
38
- return isEnabled;
39
- };
40
- exports.bundleBasedOnNftFiles = bundleBasedOnNftFiles;
41
- const useBlobsForISRAssets = (featureFlags) => {
42
- var _a, _b;
43
- const isEnabled = (_b = (_a = (0, destr_1.default)(process.env.NEXT_USE_BLOBS_FOR_ISR)) !== null && _a !== void 0 ? _a : featureFlags['next-runtime-use-blobs-for-isr-assets']) !== null && _b !== void 0 ? _b : false;
44
- return isEnabled;
45
- };
46
- exports.useBlobsForISRAssets = useBlobsForISRAssets;
@@ -1,437 +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.warnOnApiRoutes = exports.packSingleFunction = exports.getExtendedApiRouteConfigs = exports.getApiRouteConfigs = exports.getAPILambdas = exports.getSSRLambdas = exports.getCommonDependencies = exports.traceNPMPackage = exports.setupImageFunction = exports.generatePagesResolver = exports.generateFunctions = void 0;
7
- const node_bridge_1 = __importDefault(require("@vercel/node-bridge"));
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const destr_1 = __importDefault(require("destr"));
10
- const fs_extra_1 = require("fs-extra");
11
- const outdent_1 = require("outdent");
12
- const pathe_1 = require("pathe");
13
- const tiny_glob_1 = __importDefault(require("tiny-glob"));
14
- const constants_1 = require("../constants");
15
- const getApiHandler_1 = require("../templates/getApiHandler");
16
- const getHandler_1 = require("../templates/getHandler");
17
- const getPageResolver_1 = require("../templates/getPageResolver");
18
- const analysis_1 = require("./analysis");
19
- const config_1 = require("./config");
20
- const files_1 = require("./files");
21
- const functionsMetaData_1 = require("./functionsMetaData");
22
- const pack_1 = require("./pack");
23
- const utils_1 = require("./utils");
24
- const generateFunctions = async ({ INTERNAL_FUNCTIONS_SRC, PUBLISH_DIR, PACKAGE_PATH = '', FUNCTIONS_SRC = (0, pathe_1.join)(PACKAGE_PATH, constants_1.DEFAULT_FUNCTIONS_SRC), }, appDir, apiLambdas, ssrLambdas) => {
25
- const publish = (0, pathe_1.resolve)(PUBLISH_DIR);
26
- const functionsDir = (0, pathe_1.resolve)(INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC);
27
- const functionDir = (0, pathe_1.join)(functionsDir, constants_1.HANDLER_FUNCTION_NAME);
28
- const publishDir = (0, pathe_1.relative)(functionDir, publish);
29
- const nextServerModuleAbsoluteLocation = (0, files_1.getServerFile)(appDir, false);
30
- const nextServerModuleRelativeLocation = nextServerModuleAbsoluteLocation
31
- ? (0, pathe_1.relative)(functionDir, nextServerModuleAbsoluteLocation)
32
- : undefined;
33
- for (const apiLambda of apiLambdas) {
34
- const { functionName, functionTitle, routes, type, includedFiles } = apiLambda;
35
- const apiHandlerSource = (0, getApiHandler_1.getApiHandler)({
36
- // most api lambdas serve multiple routes, but scheduled functions need to be in separate lambdas.
37
- // so routes[0] is safe to access.
38
- schedule: type === "experimental-scheduled" /* ApiRouteType.SCHEDULED */ ? routes[0].config.schedule : undefined,
39
- publishDir,
40
- appDir: (0, pathe_1.relative)(functionDir, appDir),
41
- nextServerModuleRelativeLocation,
42
- });
43
- await (0, fs_extra_1.ensureDir)((0, pathe_1.join)(functionsDir, functionName));
44
- // write main API handler file
45
- await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsDir, functionName, `${functionName}.js`), apiHandlerSource);
46
- // copy handler dependencies (VercelNodeBridge, NetlifyNextServer, etc.)
47
- await (0, fs_extra_1.copyFile)(node_bridge_1.default, (0, pathe_1.join)(functionsDir, functionName, 'bridge.js'));
48
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'server.js'), (0, pathe_1.join)(functionsDir, functionName, 'server.js'));
49
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'requireHooks.js'), (0, pathe_1.join)(functionsDir, functionName, 'requireHooks.js'));
50
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'handlerUtils.js'), (0, pathe_1.join)(functionsDir, functionName, 'handlerUtils.js'));
51
- const resolveSourceFile = (file) => (0, pathe_1.join)(publish, 'server', file);
52
- // TODO: this should be unneeded once we use the `none` bundler everywhere
53
- const resolverSource = await (0, getPageResolver_1.getResolverForSourceFiles)({
54
- functionsDir,
55
- // These extra pages are always included by Next.js
56
- sourceFiles: [
57
- ...routes.map((route) => route.compiled),
58
- 'pages/_app.js',
59
- 'pages/_document.js',
60
- 'pages/_error.js',
61
- ].map(resolveSourceFile),
62
- });
63
- await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsDir, functionName, 'pages.js'), resolverSource);
64
- await (0, functionsMetaData_1.writeFunctionConfiguration)({ functionName, functionTitle, functionsDir });
65
- const nfInternalFiles = await (0, tiny_glob_1.default)((0, pathe_1.join)(functionsDir, functionName, '**'));
66
- includedFiles.push(...nfInternalFiles);
67
- }
68
- const writeHandler = async (functionName, functionTitle, isODB) => {
69
- const useHooks = await (0, functionsMetaData_1.useRequireHooks)();
70
- const handlerSource = (0, getHandler_1.getHandler)({
71
- isODB,
72
- publishDir,
73
- appDir: (0, pathe_1.relative)(functionDir, appDir),
74
- nextServerModuleRelativeLocation,
75
- useHooks,
76
- });
77
- await (0, fs_extra_1.ensureDir)((0, pathe_1.join)(functionsDir, functionName));
78
- // write main handler file (standard or ODB)
79
- await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsDir, functionName, `${functionName}.js`), handlerSource);
80
- // copy handler dependencies (VercelNodeBridge, NetlifyNextServer, etc.)
81
- await (0, fs_extra_1.copyFile)(node_bridge_1.default, (0, pathe_1.join)(functionsDir, functionName, 'bridge.js'));
82
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'server.js'), (0, pathe_1.join)(functionsDir, functionName, 'server.js'));
83
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'requireHooks.js'), (0, pathe_1.join)(functionsDir, functionName, 'requireHooks.js'));
84
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'handlerUtils.js'), (0, pathe_1.join)(functionsDir, functionName, 'handlerUtils.js'));
85
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'blobStorage.js'), (0, pathe_1.join)(functionsDir, functionName, 'blobStorage.js'));
86
- await (0, functionsMetaData_1.writeFunctionConfiguration)({ functionName, functionTitle, functionsDir });
87
- const nfInternalFiles = await (0, tiny_glob_1.default)((0, pathe_1.join)(functionsDir, functionName, '**'));
88
- const lambda = ssrLambdas.find((l) => l.functionName === functionName);
89
- if (lambda) {
90
- lambda.includedFiles.push(...nfInternalFiles);
91
- }
92
- };
93
- await writeHandler(constants_1.HANDLER_FUNCTION_NAME, constants_1.HANDLER_FUNCTION_TITLE, false);
94
- await writeHandler(constants_1.ODB_FUNCTION_NAME, constants_1.ODB_FUNCTION_TITLE, true);
95
- };
96
- exports.generateFunctions = generateFunctions;
97
- /**
98
- * Writes a file in each function directory that contains references to every page entrypoint.
99
- * This is just so that the nft bundler knows about them. We'll eventually do this better.
100
- */
101
- const generatePagesResolver = async ({ INTERNAL_FUNCTIONS_SRC, PUBLISH_DIR, PACKAGE_PATH = '', FUNCTIONS_SRC = (0, pathe_1.join)(PACKAGE_PATH, constants_1.DEFAULT_FUNCTIONS_SRC), }) => {
102
- const functionsPath = INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC;
103
- const jsSource = await (0, getPageResolver_1.getResolverForPages)(PUBLISH_DIR, PACKAGE_PATH);
104
- await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsPath, constants_1.ODB_FUNCTION_NAME, 'pages.js'), jsSource);
105
- await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsPath, constants_1.HANDLER_FUNCTION_NAME, 'pages.js'), jsSource);
106
- };
107
- exports.generatePagesResolver = generatePagesResolver;
108
- // Move our next/image function into the correct functions directory
109
- const setupImageFunction = async ({ constants: { IS_LOCAL, INTERNAL_FUNCTIONS_SRC, PACKAGE_PATH = '', FUNCTIONS_SRC = (0, pathe_1.join)(PACKAGE_PATH, constants_1.DEFAULT_FUNCTIONS_SRC), }, imageconfig = {}, netlifyConfig, basePath, remotePatterns, responseHeaders, }) => {
110
- const imagePath = imageconfig.path || '/_next/image';
111
- if ((0, destr_1.default)(process.env.DISABLE_IPX)) {
112
- // If no image loader is specified, need to redirect to a 404 page since there's no
113
- // backing loader to serve local site images once deployed to Netlify
114
- if (!IS_LOCAL && imageconfig.loader === 'default') {
115
- netlifyConfig.redirects.push({
116
- from: `${imagePath}*`,
117
- query: { url: ':url', w: ':width', q: ':quality' },
118
- to: '/404.html',
119
- status: 404,
120
- force: true,
121
- });
122
- }
123
- }
124
- else {
125
- const functionsPath = INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC;
126
- const functionName = `${constants_1.IMAGE_FUNCTION_NAME}.js`;
127
- const functionDirectory = (0, pathe_1.join)(functionsPath, constants_1.IMAGE_FUNCTION_NAME);
128
- await (0, fs_extra_1.ensureDir)(functionDirectory);
129
- await (0, fs_extra_1.writeJSON)((0, pathe_1.join)(functionDirectory, 'imageconfig.json'), {
130
- ...imageconfig,
131
- basePath: [basePath, constants_1.IMAGE_FUNCTION_NAME].join('/'),
132
- remotePatterns,
133
- responseHeaders,
134
- });
135
- await (0, fs_extra_1.copyFile)((0, pathe_1.join)(__dirname, '..', '..', 'lib', 'templates', 'ipx.js'), (0, pathe_1.join)(functionDirectory, functionName));
136
- (0, functionsMetaData_1.writeFunctionConfiguration)({
137
- functionName: constants_1.IMAGE_FUNCTION_NAME,
138
- functionTitle: constants_1.IMAGE_FUNCTION_TITLE,
139
- functionsDir: functionsPath,
140
- });
141
- // If we have edge functions then the request will have already been rewritten
142
- // so this won't match. This is matched if edge is disabled or unavailable.
143
- netlifyConfig.redirects.push({
144
- from: `${imagePath}*`,
145
- query: { url: ':url', w: ':width', q: ':quality' },
146
- to: `${basePath}/${constants_1.IMAGE_FUNCTION_NAME}/w_:width,q_:quality/:url`,
147
- status: 301,
148
- });
149
- netlifyConfig.redirects.push({
150
- from: `${basePath}/${constants_1.IMAGE_FUNCTION_NAME}/*`,
151
- to: `/.netlify/builders/${constants_1.IMAGE_FUNCTION_NAME}`,
152
- status: 200,
153
- });
154
- }
155
- if (basePath) {
156
- // next/image generates image static URLs that still point at the site root
157
- netlifyConfig.redirects.push({
158
- from: '/_next/static/image/*',
159
- to: '/static/image/:splat',
160
- status: 200,
161
- });
162
- }
163
- };
164
- exports.setupImageFunction = setupImageFunction;
165
- const traceRequiredServerFiles = async (publish) => {
166
- var _a, _b, _c;
167
- const requiredServerFiles = await (0, config_1.getRequiredServerFiles)(publish);
168
- let appDirRoot = (_a = requiredServerFiles.appDir) !== null && _a !== void 0 ? _a : (0, pathe_1.join)(publish, '..');
169
- if (requiredServerFiles.relativeAppDir && ((_b = requiredServerFiles.config) === null || _b === void 0 ? void 0 : _b.experimental.outputFileTracingRoot)) {
170
- appDirRoot = (0, pathe_1.join)(requiredServerFiles.config.experimental.outputFileTracingRoot, requiredServerFiles.relativeAppDir);
171
- }
172
- const files = (_c = requiredServerFiles.files) !== null && _c !== void 0 ? _c : [];
173
- const absoluteFiles = files.map((file) => (0, pathe_1.join)(appDirRoot, file));
174
- absoluteFiles.push((0, pathe_1.join)(publish, 'required-server-files.json'));
175
- return absoluteFiles;
176
- };
177
- const traceNextServer = async (publish) => {
178
- const nextServerDeps = await (0, files_1.getDependenciesOfFile)((0, pathe_1.join)(publish, 'next-server.js'));
179
- // during testing, i've seen `next-server` contain only one line.
180
- // this is a sanity check to make sure we're getting all the deps.
181
- if (nextServerDeps.length < 10) {
182
- console.error(nextServerDeps);
183
- throw new Error("next-server.js.nft.json didn't contain all dependencies.");
184
- }
185
- const filtered = nextServerDeps.filter((f) => {
186
- // NFT detects a bunch of large development files that we don't need.
187
- if (f.endsWith('.development.js'))
188
- return false;
189
- // not needed for API Routes!
190
- if (f.endsWith('node_modules/sass/sass.dart.js'))
191
- return false;
192
- return true;
193
- });
194
- return filtered;
195
- };
196
- const traceNPMPackage = async (packageName, publish) => {
197
- try {
198
- return await (0, tiny_glob_1.default)((0, pathe_1.join)((0, pathe_1.dirname)(require.resolve(packageName, { paths: [__dirname, publish] })), '**', '*'), {
199
- absolute: true,
200
- });
201
- }
202
- catch (error) {
203
- if (process.env.NODE_ENV === 'test') {
204
- return [];
205
- }
206
- throw error;
207
- }
208
- };
209
- exports.traceNPMPackage = traceNPMPackage;
210
- const getCommonDependencies = async (publish) => {
211
- const deps = await Promise.all([
212
- traceRequiredServerFiles(publish),
213
- traceNextServer(publish),
214
- // used by our own bridge.js
215
- (0, exports.traceNPMPackage)('follow-redirects', publish),
216
- // using package.json because otherwise, we'd find some /dist/... path
217
- (0, exports.traceNPMPackage)('@netlify/functions/package.json', publish),
218
- (0, exports.traceNPMPackage)('@netlify/blobs/package.json', publish),
219
- (0, exports.traceNPMPackage)('is-promise', publish),
220
- ]);
221
- return deps.flat(1);
222
- };
223
- exports.getCommonDependencies = getCommonDependencies;
224
- const sum = (arr) => arr.reduce((v, current) => v + current, 0);
225
- // TODO: cache results
226
- const getBundleWeight = async (patterns) => {
227
- const sizes = await Promise.all(patterns.flatMap(async (pattern) => {
228
- const files = await (0, tiny_glob_1.default)(pattern);
229
- return Promise.all(files.map(async (file) => {
230
- const fStat = await (0, fs_extra_1.stat)(file);
231
- if (fStat.isFile()) {
232
- return fStat.size;
233
- }
234
- return 0;
235
- }));
236
- }));
237
- return sum(sizes.flat(1));
238
- };
239
- const changeExtension = (file, extension) => {
240
- const base = (0, pathe_1.basename)(file, (0, pathe_1.extname)(file));
241
- return (0, pathe_1.join)((0, pathe_1.dirname)(file), base + extension);
242
- };
243
- const getSSRDependencies = async (publish) => {
244
- const prerenderManifest = await (0, fs_extra_1.readJSON)((0, pathe_1.join)(publish, 'prerender-manifest.json'));
245
- return [
246
- ...Object.entries(prerenderManifest.routes).flatMap(([route, ssgRoute]) => {
247
- if (ssgRoute.initialRevalidateSeconds === false) {
248
- return [];
249
- }
250
- if (ssgRoute.dataRoute.endsWith('.rsc')) {
251
- return [
252
- (0, pathe_1.join)(publish, 'server', 'app', ssgRoute.dataRoute),
253
- (0, pathe_1.join)(publish, 'server', 'app', changeExtension(ssgRoute.dataRoute, '.html')),
254
- ];
255
- }
256
- const trimmedPath = route === '/' ? 'index' : route.slice(1);
257
- return [
258
- (0, pathe_1.join)(publish, 'server', 'pages', `${trimmedPath}.html`),
259
- (0, pathe_1.join)(publish, 'server', 'pages', `${trimmedPath}.json`),
260
- ];
261
- }),
262
- (0, pathe_1.join)(publish, '**', '*.html'),
263
- (0, pathe_1.join)(publish, 'static-manifest.json'),
264
- (0, pathe_1.join)(publish, 'blobs-manifest.json'),
265
- ];
266
- };
267
- const getSSRLambdas = async (publish) => {
268
- const commonDependencies = await (0, exports.getCommonDependencies)(publish);
269
- const ssrRoutes = await getSSRRoutes(publish);
270
- // TODO: for now, they're the same - but we should separate them
271
- const nonOdbRoutes = ssrRoutes;
272
- const odbRoutes = ssrRoutes;
273
- const ssrDependencies = await getSSRDependencies(publish);
274
- return [
275
- {
276
- functionName: constants_1.HANDLER_FUNCTION_NAME,
277
- functionTitle: constants_1.HANDLER_FUNCTION_TITLE,
278
- includedFiles: [
279
- ...commonDependencies,
280
- ...ssrDependencies,
281
- ...nonOdbRoutes.flatMap((route) => route.includedFiles),
282
- ],
283
- routes: nonOdbRoutes,
284
- },
285
- {
286
- functionName: constants_1.ODB_FUNCTION_NAME,
287
- functionTitle: constants_1.ODB_FUNCTION_TITLE,
288
- includedFiles: [...commonDependencies, ...ssrDependencies, ...odbRoutes.flatMap((route) => route.includedFiles)],
289
- routes: odbRoutes,
290
- },
291
- ];
292
- };
293
- exports.getSSRLambdas = getSSRLambdas;
294
- const getSSRRoutes = async (publish) => {
295
- const pageManifest = (await (0, fs_extra_1.readJSON)((0, pathe_1.join)(publish, 'server', 'pages-manifest.json')));
296
- const pageManifestRoutes = Object.entries(pageManifest).filter(([page, compiled]) => !page.startsWith('/api/') && !compiled.endsWith('.html'));
297
- const appPathsManifest = await (0, fs_extra_1.readJSON)((0, pathe_1.join)(publish, 'server', 'app-paths-manifest.json')).catch(() => ({}));
298
- const appRoutes = Object.entries(appPathsManifest);
299
- const routes = [...pageManifestRoutes, ...appRoutes];
300
- return await Promise.all(routes.map(async ([route, compiled]) => {
301
- const functionName = (0, utils_1.getFunctionNameForPage)(route);
302
- const compiledPath = (0, pathe_1.join)(publish, 'server', compiled);
303
- const routeDependencies = await (0, files_1.getDependenciesOfFile)(compiledPath);
304
- const includedFiles = [compiledPath, ...routeDependencies];
305
- return {
306
- functionName,
307
- route,
308
- compiled,
309
- includedFiles,
310
- };
311
- }));
312
- };
313
- const getAPILambdas = async (publish, baseDir, pageExtensions) => {
314
- const commonDependencies = await (0, exports.getCommonDependencies)(publish);
315
- const threshold = constants_1.LAMBDA_WARNING_SIZE - (await getBundleWeight(commonDependencies));
316
- const apiRoutes = await (0, exports.getApiRouteConfigs)(publish, baseDir, pageExtensions);
317
- const packFunctions = async (routes, type) => {
318
- const weighedRoutes = await Promise.all(routes.map(async (route) => ({ value: route, weight: await getBundleWeight(route.includedFiles) })));
319
- const bins = (0, pack_1.pack)(weighedRoutes, threshold);
320
- return bins.map((bin) => {
321
- if (bin.length === 1) {
322
- const [func] = bin;
323
- const { functionName, functionTitle, config, includedFiles } = func;
324
- return {
325
- functionName,
326
- functionTitle,
327
- routes: [func],
328
- includedFiles: [...commonDependencies, ...includedFiles],
329
- type: config.type,
330
- };
331
- }
332
- const includedFiles = [...commonDependencies, ...bin.flatMap((route) => route.includedFiles)];
333
- const nonSingletonBins = bins.filter((b) => b.length > 1);
334
- if (nonSingletonBins.length === 1) {
335
- return {
336
- functionName: constants_1.API_FUNCTION_NAME,
337
- functionTitle: constants_1.API_FUNCTION_TITLE,
338
- includedFiles,
339
- routes: bin,
340
- type,
341
- };
342
- }
343
- const indexInNonSingletonBins = nonSingletonBins.indexOf(bin);
344
- return {
345
- functionName: `${constants_1.API_FUNCTION_NAME}-${indexInNonSingletonBins + 1}`,
346
- functionTitle: `${constants_1.API_FUNCTION_TITLE} ${indexInNonSingletonBins + 1}/${nonSingletonBins.length}`,
347
- includedFiles,
348
- routes: bin,
349
- type,
350
- };
351
- });
352
- };
353
- const standardFunctions = apiRoutes.filter((route) => !(0, analysis_1.isEdgeConfig)(route.config.runtime) &&
354
- route.config.type !== "experimental-background" /* ApiRouteType.BACKGROUND */ &&
355
- route.config.type !== "experimental-scheduled" /* ApiRouteType.SCHEDULED */);
356
- const scheduledFunctions = apiRoutes.filter((route) => route.config.type === "experimental-scheduled" /* ApiRouteType.SCHEDULED */);
357
- const backgroundFunctions = apiRoutes.filter((route) => route.config.type === "experimental-background" /* ApiRouteType.BACKGROUND */);
358
- const scheduledLambdas = scheduledFunctions.map(exports.packSingleFunction);
359
- const [standardLambdas, backgroundLambdas] = await Promise.all([
360
- packFunctions(standardFunctions),
361
- packFunctions(backgroundFunctions, "experimental-background" /* ApiRouteType.BACKGROUND */),
362
- ]);
363
- return [...standardLambdas, ...backgroundLambdas, ...scheduledLambdas];
364
- };
365
- exports.getAPILambdas = getAPILambdas;
366
- /**
367
- * Look for API routes, and extract the config from the source file.
368
- */
369
- const getApiRouteConfigs = async (publish, appDir, pageExtensions) => {
370
- const pages = await (0, fs_extra_1.readJSON)((0, pathe_1.join)(publish, 'server', 'pages-manifest.json'));
371
- const apiRoutes = Object.keys(pages).filter((page) => page.startsWith('/api/'));
372
- // two possible places
373
- // Ref: https://nextjs.org/docs/advanced-features/src-directory
374
- const pagesDir = (0, pathe_1.join)(appDir, 'pages');
375
- const srcPagesDir = (0, pathe_1.join)(appDir, 'src', 'pages');
376
- return await Promise.all(apiRoutes.map(async (apiRoute) => {
377
- const filePath = (0, files_1.getSourceFileForPage)(apiRoute, [pagesDir, srcPagesDir], pageExtensions);
378
- const config = await (0, analysis_1.extractConfigFromFile)(filePath, appDir);
379
- const functionName = (0, utils_1.getFunctionNameForPage)(apiRoute, config.type === "experimental-background" /* ApiRouteType.BACKGROUND */);
380
- const functionTitle = `${constants_1.API_FUNCTION_TITLE} ${apiRoute}`;
381
- const compiled = pages[apiRoute];
382
- const compiledPath = (0, pathe_1.join)(publish, 'server', compiled);
383
- const routeDependencies = await (0, files_1.getDependenciesOfFile)(compiledPath);
384
- const includedFiles = [compiledPath, ...routeDependencies];
385
- return {
386
- functionName,
387
- functionTitle,
388
- route: apiRoute,
389
- config,
390
- compiled,
391
- includedFiles,
392
- };
393
- }));
394
- };
395
- exports.getApiRouteConfigs = getApiRouteConfigs;
396
- /**
397
- * Looks for extended API routes (background and scheduled functions) and extract the config from the source file.
398
- */
399
- const getExtendedApiRouteConfigs = async (publish, appDir, pageExtensions) => {
400
- const settledApiRoutes = await (0, exports.getApiRouteConfigs)(publish, appDir, pageExtensions);
401
- // We only want to return the API routes that are background or scheduled functions
402
- return settledApiRoutes.filter((apiRoute) => apiRoute.config.type !== undefined);
403
- };
404
- exports.getExtendedApiRouteConfigs = getExtendedApiRouteConfigs;
405
- const packSingleFunction = (func) => ({
406
- functionName: func.functionName,
407
- functionTitle: func.functionTitle,
408
- includedFiles: func.includedFiles,
409
- routes: [func],
410
- type: func.config.type,
411
- });
412
- exports.packSingleFunction = packSingleFunction;
413
- /**
414
- * Warn the user of the caveats if they're using background or scheduled API routes
415
- */
416
- const warnOnApiRoutes = async ({ FUNCTIONS_DIST, }) => {
417
- const functionsManifestPath = (0, pathe_1.join)(FUNCTIONS_DIST, 'manifest.json');
418
- if (!(0, fs_extra_1.existsSync)(functionsManifestPath)) {
419
- return;
420
- }
421
- const { functions } = await (0, fs_extra_1.readJSON)(functionsManifestPath);
422
- if (functions.some((func) => func.name.endsWith('-background'))) {
423
- console.warn((0, outdent_1.outdent) `
424
- ${chalk_1.default.yellowBright `Using background API routes`}
425
- If your account type does not support background functions, the deploy will fail.
426
- During local development, background API routes will run as regular API routes, but in production they will immediately return an empty "202 Accepted" response.
427
- `);
428
- }
429
- if (functions.some((func) => func.schedule)) {
430
- console.warn((0, outdent_1.outdent) `
431
- ${chalk_1.default.yellowBright `Using scheduled API routes`}
432
- These are run on a schedule when deployed to production.
433
- You can test them locally by loading them in your browser but this will not be available when deployed, and any returned value is ignored.
434
- `);
435
- }
436
- };
437
- exports.warnOnApiRoutes = warnOnApiRoutes;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeFunctionConfiguration = exports.useRequireHooks = exports.getPluginVersion = void 0;
4
- const fs_extra_1 = require("fs-extra");
5
- const pathe_1 = require("pathe");
6
- const semver_1 = require("semver");
7
- const constants_1 = require("../constants");
8
- const config_1 = require("./config");
9
- const getNextRuntimeVersion = async (packageJsonPath, useNodeModulesPath) => {
10
- if (!(0, fs_extra_1.existsSync)(packageJsonPath)) {
11
- return;
12
- }
13
- const packagePlugin = await (0, fs_extra_1.readJSON)(packageJsonPath);
14
- return useNodeModulesPath ? packagePlugin.version : packagePlugin.dependencies[constants_1.NEXT_PLUGIN];
15
- };
16
- const PLUGIN_PACKAGE_PATH = '.netlify/plugins/package.json';
17
- const nextPluginVersion = async (module) => {
18
- const moduleRoot = (0, config_1.resolveModuleRoot)(module || constants_1.NEXT_PLUGIN);
19
- const nodeModulesPath = moduleRoot ? (0, pathe_1.join)(moduleRoot, 'package.json') : null;
20
- return ((await getNextRuntimeVersion(nodeModulesPath, true)) ||
21
- (await getNextRuntimeVersion(PLUGIN_PACKAGE_PATH, false)) ||
22
- // The runtime version should always be available, but if it's not, return 'unknown'
23
- 'unknown');
24
- };
25
- const getPluginVersion = async () => `${constants_1.NEXT_PLUGIN_NAME}@${await nextPluginVersion()}`;
26
- exports.getPluginVersion = getPluginVersion;
27
- const useRequireHooks = async () => (0, semver_1.satisfies)(await nextPluginVersion('next'), '13.3.3 - 13.4.9');
28
- exports.useRequireHooks = useRequireHooks;
29
- /**
30
- * Creates a function configuration file for the given function.
31
- *
32
- * @param functionInfo The information needed to create a function configuration file
33
- */
34
- const writeFunctionConfiguration = async (functionInfo) => {
35
- const { functionName, functionTitle, functionsDir } = functionInfo;
36
- const generator = await (0, exports.getPluginVersion)();
37
- const metadata = {
38
- config: {
39
- name: functionTitle,
40
- generator,
41
- },
42
- version: 1,
43
- };
44
- await (0, fs_extra_1.writeFile)((0, pathe_1.join)(functionsDir, functionName, `${functionName}.json`), JSON.stringify(metadata));
45
- };
46
- exports.writeFunctionConfiguration = writeFunctionConfiguration;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeLocaleOptional = exports.transformCaptureGroups = exports.stripLookahead = void 0;
4
- const regexp_tree_1 = require("regexp-tree");
5
- // The Go regexp lib doesn't support lookaheads, so we need to remove them
6
- const stripLookahead = (regex) => {
7
- // Early return if there's no lookahead
8
- if (!(regex === null || regex === void 0 ? void 0 : regex.includes('(?!'))) {
9
- return regex;
10
- }
11
- try {
12
- // Parse the regexp into an AST
13
- const re = (0, regexp_tree_1.transform)(new RegExp(regex), {
14
- Assertion(path) {
15
- // Remove the lookahead
16
- if (path.node.kind === 'Lookahead') {
17
- path.remove();
18
- }
19
- },
20
- });
21
- // Strip the leading and trailing slashes
22
- return re.toString().slice(1, -1);
23
- }
24
- catch {
25
- // Failed to parse regex, so return unchanged
26
- return regex;
27
- }
28
- };
29
- exports.stripLookahead = stripLookahead;
30
- // The Go regexp lib has alternative syntax for named capture groups
31
- const transformCaptureGroups = (regex) => regex.replace(/\(\?<\w+>/, '(');
32
- exports.transformCaptureGroups = transformCaptureGroups;
33
- const LOCALIZED_REGEX_PREFIX_13_1 = '(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))';
34
- const OPTIONAL_REGEX_PREFIX_13_1 = '(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/([^/.]{1,}))?';
35
- const LOCALIZED_REGEX_PREFIX_13_3 = '(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/((?!_next\\/)[^/.]{1,}))';
36
- const OPTIONAL_REGEX_PREFIX_13_3 = '(?:\\/(_next\\/data\\/[^/]{1,}))?(?:\\/((?!_next\\/)[^/.]{1,}))?';
37
- // Make the locale section of the matcher regex optional
38
- const makeLocaleOptional = (regex) => regex
39
- .replace(LOCALIZED_REGEX_PREFIX_13_1, OPTIONAL_REGEX_PREFIX_13_1)
40
- .replace(LOCALIZED_REGEX_PREFIX_13_3, OPTIONAL_REGEX_PREFIX_13_3);
41
- exports.makeLocaleOptional = makeLocaleOptional;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- const compiler_1 = require("./compiler");
5
- const run = async () => {
6
- const { isReady, watcher } = (0, compiler_1.watchForMiddlewareChanges)((0, path_1.resolve)(process.argv[2]));
7
- await isReady;
8
- if (process.argv[3] === '--once') {
9
- watcher.close();
10
- }
11
- };
12
- run();
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pack = void 0;
4
- /**
5
- * Naïve linear packing algorithm.
6
- * Takes items with weights, and packs them into boxes of a given threshold.
7
- * If an item weight exceeds the threshold, it is put into a box of its own.
8
- *
9
- * We're using this to combine many API Routes into fewer Lambda functions.
10
- *
11
- * This does not compute an optimal solution.
12
- * For that, we'd take the full dependency graph into account
13
- * and try to pack routes with intersecting dependencies together.
14
- * But since most of the lambda bundle consists of node_modules,
15
- * that probably won't help much.
16
- * In the future, we might think about using some graph-based analysis here!
17
- * Too complicated for now.
18
- */
19
- const pack = (items, threshold) => {
20
- const result = [];
21
- let currentBox = [];
22
- let currentWeight = 0;
23
- const sortedDescending = items.sort((a, b) => b.weight - a.weight);
24
- for (const item of sortedDescending) {
25
- const fitsInCurrentBox = currentWeight + item.weight <= threshold;
26
- if (fitsInCurrentBox) {
27
- currentBox.push(item.value);
28
- currentWeight += item.weight;
29
- }
30
- else {
31
- if (currentBox.length !== 0)
32
- result.push(currentBox);
33
- currentBox = [item.value];
34
- currentWeight = item.weight;
35
- }
36
- }
37
- if (currentBox.length !== 0)
38
- result.push(currentBox);
39
- return result;
40
- };
41
- exports.pack = pack;