@netlify/plugin-nextjs 4.41.3 → 5.0.0-beta.1
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.
- package/README.md +61 -17
- package/dist/build/cache.js +15 -0
- package/dist/build/content/prerendered.js +16 -0
- package/dist/build/content/server.js +18 -0
- package/dist/build/content/static.js +20 -0
- package/dist/build/functions/edge.js +14 -0
- package/dist/build/functions/server.js +16 -0
- package/dist/build/plugin-context.js +17 -0
- package/dist/esm-chunks/chunk-4AJYXTWN.js +17 -0
- package/dist/esm-chunks/chunk-5N2CWXSJ.js +564 -0
- package/dist/esm-chunks/chunk-A22224GM.js +113 -0
- package/dist/esm-chunks/chunk-AVWFCGVE.js +5536 -0
- package/dist/esm-chunks/chunk-B6QMRLBH.js +255 -0
- package/dist/esm-chunks/chunk-G3GM7JNF.js +92 -0
- package/dist/esm-chunks/chunk-GGHAQM5D.js +28 -0
- package/dist/esm-chunks/chunk-NOX2JUQZ.js +89 -0
- package/dist/esm-chunks/chunk-R4NHZWGU.js +32 -0
- package/dist/esm-chunks/chunk-RSKIKBZH.js +44 -0
- package/dist/esm-chunks/chunk-UXLNY5XK.js +86 -0
- package/dist/esm-chunks/chunk-VP3PT3VV.js +119 -0
- package/dist/esm-chunks/chunk-YZXA5QBC.js +60 -0
- package/dist/esm-chunks/chunk-Z7ZMLVTM.js +78 -0
- package/dist/index.js +66 -0
- package/dist/run/config.js +18 -0
- package/dist/run/constants.js +15 -0
- package/dist/run/handlers/cache.cjs +852 -0
- package/dist/run/handlers/server.js +3297 -0
- package/dist/run/headers.js +19 -0
- package/dist/run/next.cjs +1058 -0
- package/dist/run/revalidate.js +13 -0
- package/dist/run/systemlog.js +15 -0
- package/edge-runtime/README.md +29 -0
- package/edge-runtime/lib/headers.ts +26 -0
- package/edge-runtime/lib/middleware.ts +60 -0
- package/edge-runtime/lib/next-request.ts +59 -0
- package/edge-runtime/lib/response.ts +145 -0
- package/{src/templates/edge-shared/next-utils.ts → edge-runtime/lib/routing.ts} +64 -20
- package/edge-runtime/lib/util.ts +26 -0
- package/edge-runtime/middleware.ts +53 -0
- package/edge-runtime/shim/index.js +11 -0
- package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +1 -1
- package/edge-runtime/vendor/import_map.json +13 -0
- package/edge-runtime/vendor.ts +18 -0
- package/manifest.yml +1 -1
- package/package.json +23 -60
- package/index.js +0 -1
- package/lib/constants.js +0 -56
- package/lib/helpers/analysis.js +0 -115
- package/lib/helpers/cache.js +0 -46
- package/lib/helpers/compiler.js +0 -119
- package/lib/helpers/config.js +0 -192
- package/lib/helpers/dev.js +0 -20
- package/lib/helpers/edge.js +0 -328
- package/lib/helpers/files.js +0 -335
- package/lib/helpers/flags.js +0 -46
- package/lib/helpers/functions.js +0 -437
- package/lib/helpers/functionsMetaData.js +0 -46
- package/lib/helpers/matchers.js +0 -41
- package/lib/helpers/middlewareWatcher.js +0 -12
- package/lib/helpers/pack.js +0 -41
- package/lib/helpers/redirects.js +0 -246
- package/lib/helpers/types.js +0 -2
- package/lib/helpers/utils.js +0 -226
- package/lib/helpers/verification.js +0 -182
- package/lib/index.js +0 -194
- package/lib/templates/blobStorage.js +0 -30
- package/lib/templates/getApiHandler.js +0 -120
- package/lib/templates/getHandler.js +0 -201
- package/lib/templates/getPageResolver.js +0 -54
- package/lib/templates/handlerUtils.js +0 -268
- package/lib/templates/ipx.js +0 -13
- package/lib/templates/requireHooks.js +0 -105
- package/lib/templates/server.js +0 -159
- package/lib/templates/vendor.js +0 -20
- package/src/templates/edge/bundle.js +0 -8
- package/src/templates/edge/function-runtime.ts +0 -24
- package/src/templates/edge/imageconfig.json +0 -3
- package/src/templates/edge/ipx.ts +0 -5
- package/src/templates/edge/middleware-runtime.ts +0 -62
- package/src/templates/edge/next-dev.js +0 -104
- package/src/templates/edge/rsc-data.ts +0 -5
- package/src/templates/edge/shims.js +0 -77
- package/src/templates/edge-shared/nextConfig.json +0 -3
- package/src/templates/edge-shared/prerender-manifest.json +0 -7
- package/src/templates/edge-shared/rsc-data.ts +0 -78
- package/src/templates/edge-shared/utils.test.ts +0 -114
- package/src/templates/edge-shared/utils.ts +0 -315
- package/src/templates/vendor/import_map.json +0 -13
- /package/{src/templates/edge → edge-runtime}/matchers.json +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/fmt/colors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/_diff.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.134.0/testing/asserts.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/asserts.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/_util/os.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/abortable.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deadline.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/debounce.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/deferred.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/delay.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/pool.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/retry.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/async/tee.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/encoding/base64url.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/flags/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/colors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/fmt/printf.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/http/cookie.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_core.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_events.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_global.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_next_tick.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/process.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_stream.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/_utils.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assert.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/assertion_error.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/async_hooks.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/buffer.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/events.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/errors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/net.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/options.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/util.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/process.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/stream.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/string_decoder.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util/types.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/node/util.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_constants.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_interface.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/_util.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/common.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/glob.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/mod.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/posix.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/separator.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/path/win32.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/streams/write_all.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_diff.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/_format.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/testing/asserts.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/std@0.175.0/types.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +0 -0
- /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +0 -0
- /package/{src/templates → edge-runtime}/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +0 -0
package/lib/index.js
DELETED
|
@@ -1,194 +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
|
-
const path_1 = require("path");
|
|
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 constants_1 = require("./constants");
|
|
12
|
-
const cache_1 = require("./helpers/cache");
|
|
13
|
-
const config_1 = require("./helpers/config");
|
|
14
|
-
const dev_1 = require("./helpers/dev");
|
|
15
|
-
const edge_1 = require("./helpers/edge");
|
|
16
|
-
const files_1 = require("./helpers/files");
|
|
17
|
-
const flags_1 = require("./helpers/flags");
|
|
18
|
-
const functions_1 = require("./helpers/functions");
|
|
19
|
-
const redirects_1 = require("./helpers/redirects");
|
|
20
|
-
const utils_1 = require("./helpers/utils");
|
|
21
|
-
const verification_1 = require("./helpers/verification");
|
|
22
|
-
const blobStorage_1 = require("./templates/blobStorage");
|
|
23
|
-
const plugin = {
|
|
24
|
-
async onPreBuild({ constants, netlifyConfig, utils: { build: { failBuild }, cache, }, }) {
|
|
25
|
-
var _a;
|
|
26
|
-
const { publish } = netlifyConfig.build;
|
|
27
|
-
if ((0, utils_1.shouldSkip)()) {
|
|
28
|
-
await (0, cache_1.restoreCache)({ cache, publish });
|
|
29
|
-
console.log('Not running Next Runtime');
|
|
30
|
-
if ((0, fs_extra_1.existsSync)((0, path_1.join)(constants.INTERNAL_FUNCTIONS_SRC, constants_1.HANDLER_FUNCTION_NAME))) {
|
|
31
|
-
console.log(`Please ensure you remove any generated functions from ${constants.INTERNAL_FUNCTIONS_SRC}`);
|
|
32
|
-
}
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
(0, verification_1.checkForRootPublish)({ publish, failBuild });
|
|
36
|
-
(0, verification_1.verifyNetlifyBuildVersion)({ failBuild, ...constants });
|
|
37
|
-
await (0, cache_1.restoreCache)({ cache, publish });
|
|
38
|
-
(_a = netlifyConfig.build).environment || (_a.environment = {});
|
|
39
|
-
// eslint-disable-next-line unicorn/consistent-destructuring
|
|
40
|
-
netlifyConfig.build.environment.NEXT_PRIVATE_TARGET = 'server';
|
|
41
|
-
},
|
|
42
|
-
// eslint-disable-next-line max-lines-per-function
|
|
43
|
-
async onBuild({ constants, netlifyConfig, utils: { build: { failBuild }, }, featureFlags = {}, }) {
|
|
44
|
-
if ((0, utils_1.shouldSkip)()) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const { publish } = netlifyConfig.build;
|
|
48
|
-
(0, verification_1.checkNextSiteHasBuilt)({ publish, failBuild });
|
|
49
|
-
const { appDir, basePath, i18n, images, target, ignore, trailingSlash, outdir, experimental, routesManifest, pageExtensions, } = await (0, config_1.getNextConfig)({
|
|
50
|
-
publish,
|
|
51
|
-
failBuild,
|
|
52
|
-
});
|
|
53
|
-
await (0, edge_1.cleanupEdgeFunctions)(constants);
|
|
54
|
-
const middlewareManifest = await (0, edge_1.loadMiddlewareManifest)(netlifyConfig);
|
|
55
|
-
const config = await (0, config_1.getRequiredServerFiles)(publish);
|
|
56
|
-
if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.functions) &&
|
|
57
|
-
Object.keys(middlewareManifest.functions).length !== 0 &&
|
|
58
|
-
(0, destr_1.default)(process.env.NEXT_DISABLE_NETLIFY_EDGE)) {
|
|
59
|
-
failBuild((0, outdent_1.outdent) `
|
|
60
|
-
You are using Next.js experimental edge runtime, but have set NEXT_DISABLE_NETLIFY_EDGE to true. This is not supported.
|
|
61
|
-
To use edge runtime, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`}.
|
|
62
|
-
`);
|
|
63
|
-
}
|
|
64
|
-
if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.middleware) &&
|
|
65
|
-
Object.keys(middlewareManifest.middleware).length !== 0 &&
|
|
66
|
-
(0, destr_1.default)(process.env.NEXT_DISABLE_NETLIFY_EDGE)) {
|
|
67
|
-
console.log((0, chalk_1.redBright)((0, outdent_1.outdent) `
|
|
68
|
-
You are using Next.js Middleware without Netlify Edge Functions.
|
|
69
|
-
This is deprecated because it negatively affects performance and will disable ISR and static rendering.
|
|
70
|
-
It also disables advanced middleware features from @netlify/next
|
|
71
|
-
To get the best performance and use Netlify Edge Functions, remove the env var ${(0, chalk_1.bold) `NEXT_DISABLE_NETLIFY_EDGE`}.
|
|
72
|
-
`));
|
|
73
|
-
}
|
|
74
|
-
if ((0, utils_1.isNextAuthInstalled)()) {
|
|
75
|
-
const userDefinedNextAuthUrl = config.config.env.NEXTAUTH_URL;
|
|
76
|
-
if (userDefinedNextAuthUrl) {
|
|
77
|
-
console.log(`NextAuth package detected, NEXTAUTH_URL environment variable set by user in next.config.js to ${userDefinedNextAuthUrl}`);
|
|
78
|
-
}
|
|
79
|
-
else if (process.env.NEXTAUTH_URL) {
|
|
80
|
-
// When the value is specified in the netlify.toml or the Netlify UI (will be evaluated in this order)
|
|
81
|
-
const nextAuthUrl = `${process.env.NEXTAUTH_URL}${basePath}`;
|
|
82
|
-
console.log(`NextAuth package detected, NEXTAUTH_URL environment variable set by user in Netlify configuration to ${nextAuthUrl}`);
|
|
83
|
-
config.config.env.NEXTAUTH_URL = nextAuthUrl;
|
|
84
|
-
await (0, config_1.updateRequiredServerFiles)(publish, config);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
// Using the deploy prime url in production leads to issues because the unique deploy ID is part of the generated URL
|
|
88
|
-
// and will not match the expected URL in the callback URL of an OAuth application.
|
|
89
|
-
const nextAuthUrl = `${process.env.CONTEXT === 'production' ? process.env.URL : process.env.DEPLOY_PRIME_URL}${basePath}`;
|
|
90
|
-
console.log(`NextAuth package detected, setting NEXTAUTH_URL environment variable to ${nextAuthUrl}`);
|
|
91
|
-
config.config.env.NEXTAUTH_URL = nextAuthUrl;
|
|
92
|
-
await (0, config_1.updateRequiredServerFiles)(publish, config);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const buildId = (0, fs_extra_1.readFileSync)((0, path_1.join)(publish, 'BUILD_ID'), 'utf8').trim();
|
|
96
|
-
const apiLambdas = (0, flags_1.splitApiRoutes)(featureFlags, publish)
|
|
97
|
-
? await (0, functions_1.getAPILambdas)(publish, appDir, pageExtensions)
|
|
98
|
-
: await (0, functions_1.getExtendedApiRouteConfigs)(publish, appDir, pageExtensions).then((extendedRoutes) => extendedRoutes.map(functions_1.packSingleFunction));
|
|
99
|
-
const ssrLambdas = (0, flags_1.bundleBasedOnNftFiles)(featureFlags) ? await (0, functions_1.getSSRLambdas)(publish) : [];
|
|
100
|
-
await (0, functions_1.generateFunctions)(constants, appDir, apiLambdas, ssrLambdas);
|
|
101
|
-
await (0, functions_1.generatePagesResolver)(constants);
|
|
102
|
-
await (0, config_1.configureHandlerFunctions)({
|
|
103
|
-
netlifyConfig,
|
|
104
|
-
ignore,
|
|
105
|
-
publish: (0, path_1.relative)(process.cwd(), publish),
|
|
106
|
-
apiLambdas,
|
|
107
|
-
ssrLambdas,
|
|
108
|
-
splitApiRoutes: (0, flags_1.splitApiRoutes)(featureFlags, publish),
|
|
109
|
-
});
|
|
110
|
-
await (0, files_1.movePublicFiles)({ appDir, outdir, publish, basePath });
|
|
111
|
-
if (!(0, destr_1.default)(process.env.SERVE_STATIC_FILES_FROM_ORIGIN)) {
|
|
112
|
-
const useBlobs = (0, flags_1.useBlobsForISRAssets)(featureFlags);
|
|
113
|
-
const { NETLIFY_API_HOST, NETLIFY_API_TOKEN, SITE_ID } = constants;
|
|
114
|
-
const testBlobStorage = useBlobs
|
|
115
|
-
? new blobStorage_1.Blobs({
|
|
116
|
-
authentication: {
|
|
117
|
-
apiURL: `https://${NETLIFY_API_HOST}`,
|
|
118
|
-
token: NETLIFY_API_TOKEN,
|
|
119
|
-
},
|
|
120
|
-
context: `deploy:${process.env.DEPLOY_ID}`,
|
|
121
|
-
siteID: SITE_ID,
|
|
122
|
-
})
|
|
123
|
-
: undefined;
|
|
124
|
-
const netliBlob = testBlobStorage && (await (0, blobStorage_1.isBlobStorageAvailable)(testBlobStorage)) ? testBlobStorage : undefined;
|
|
125
|
-
await (0, files_1.moveStaticPages)({ target, netlifyConfig, nextConfig: { basePath, i18n }, netliBlob });
|
|
126
|
-
}
|
|
127
|
-
await (0, redirects_1.generateStaticRedirects)({
|
|
128
|
-
netlifyConfig,
|
|
129
|
-
nextConfig: { basePath, i18n },
|
|
130
|
-
});
|
|
131
|
-
await (0, functions_1.setupImageFunction)({
|
|
132
|
-
constants,
|
|
133
|
-
imageconfig: images,
|
|
134
|
-
netlifyConfig,
|
|
135
|
-
basePath,
|
|
136
|
-
remotePatterns: (0, utils_1.getRemotePatterns)(experimental, images),
|
|
137
|
-
responseHeaders: (0, utils_1.getCustomImageResponseHeaders)(netlifyConfig.headers),
|
|
138
|
-
});
|
|
139
|
-
await (0, redirects_1.generateRedirects)({
|
|
140
|
-
netlifyConfig,
|
|
141
|
-
nextConfig: { basePath, i18n, trailingSlash, appDir },
|
|
142
|
-
buildId,
|
|
143
|
-
apiLambdas,
|
|
144
|
-
});
|
|
145
|
-
await (0, edge_1.writeEdgeFunctions)({ constants, netlifyConfig, routesManifest });
|
|
146
|
-
},
|
|
147
|
-
async onPostBuild({ netlifyConfig: { build: { publish }, redirects, headers, }, utils: { status, cache, functions, build: { failBuild }, }, constants: { FUNCTIONS_DIST }, }) {
|
|
148
|
-
await (0, cache_1.saveCache)({ cache, publish });
|
|
149
|
-
if ((0, utils_1.shouldSkip)()) {
|
|
150
|
-
status.show({
|
|
151
|
-
title: 'Next Runtime did not run',
|
|
152
|
-
summary: `Next cache was stored, but all other functions were skipped because ${process.env.NETLIFY_NEXT_PLUGIN_SKIP
|
|
153
|
-
? `NETLIFY_NEXT_PLUGIN_SKIP is set`
|
|
154
|
-
: `NEXT_PLUGIN_FORCE_RUN is set to ${process.env.NEXT_PLUGIN_FORCE_RUN}`}`,
|
|
155
|
-
});
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
await (0, verification_1.checkForOldFunctions)({ functions });
|
|
159
|
-
await (0, verification_1.checkZipSize)((0, path_1.join)(FUNCTIONS_DIST, `${constants_1.ODB_FUNCTION_NAME}.zip`));
|
|
160
|
-
const nextConfig = await (0, config_1.getNextConfig)({ publish, failBuild });
|
|
161
|
-
const { basePath, appDir, experimental, } = nextConfig;
|
|
162
|
-
(0, config_1.generateCustomHeaders)(nextConfig, headers);
|
|
163
|
-
(0, verification_1.warnForProblematicUserRewrites)({ basePath, redirects });
|
|
164
|
-
(0, verification_1.warnForRootRedirects)({ appDir });
|
|
165
|
-
await (0, functions_1.warnOnApiRoutes)({ FUNCTIONS_DIST });
|
|
166
|
-
// we are removing metadata files from Publish directory
|
|
167
|
-
// we have to do this after functions were bundled as bundling still
|
|
168
|
-
// require those files, but we don't want to publish them
|
|
169
|
-
await (0, files_1.removeMetadataFiles)(publish);
|
|
170
|
-
if (experimental === null || experimental === void 0 ? void 0 : experimental.appDir) {
|
|
171
|
-
console.log('🧪 Thank you for testing "appDir" support on Netlify. For known issues and to give feedback, visit https://ntl.fyi/next-13-feedback');
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
// The types haven't been updated yet
|
|
176
|
-
const nextRuntime = (_inputs, meta = {}) => {
|
|
177
|
-
var _a;
|
|
178
|
-
if (!((_a = meta === null || meta === void 0 ? void 0 : meta.events) === null || _a === void 0 ? void 0 : _a.has('onPreDev'))) {
|
|
179
|
-
return {
|
|
180
|
-
...plugin,
|
|
181
|
-
onEnd: ({ utils }) => {
|
|
182
|
-
utils.status.show({
|
|
183
|
-
title: 'Please upgrade to the latest version of the Netlify CLI',
|
|
184
|
-
summary: 'To support for the latest Next.js features, please upgrade to the latest version of the Netlify CLI',
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
...plugin,
|
|
191
|
-
onPreDev: dev_1.onPreDev,
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
module.exports = nextRuntime;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Blobs = exports.getNormalizedBlobKey = exports.getBlobInit = exports.setBlobInit = exports.isBlobStorageAvailable = void 0;
|
|
4
|
-
const buffer_1 = require("buffer");
|
|
5
|
-
const blobs_1 = require("@netlify/blobs");
|
|
6
|
-
Object.defineProperty(exports, "Blobs", { enumerable: true, get: function () { return blobs_1.Blobs; } });
|
|
7
|
-
const isBlobStorageAvailable = async (netliBlob) => {
|
|
8
|
-
try {
|
|
9
|
-
// request a key that is not present. If it returns `null` then the blob storage is available
|
|
10
|
-
// if it throws it's not available.
|
|
11
|
-
await netliBlob.get('any-key');
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.isBlobStorageAvailable = isBlobStorageAvailable;
|
|
19
|
-
let blobInit;
|
|
20
|
-
const setBlobInit = (init) => {
|
|
21
|
-
blobInit = init;
|
|
22
|
-
};
|
|
23
|
-
exports.setBlobInit = setBlobInit;
|
|
24
|
-
const getBlobInit = () => blobInit;
|
|
25
|
-
exports.getBlobInit = getBlobInit;
|
|
26
|
-
/**
|
|
27
|
-
* @netlify/blobs ATM has some limitation to keys, so we need to normalize it for now (they will be resolved so we will be able to remove this code)
|
|
28
|
-
*/
|
|
29
|
-
const getNormalizedBlobKey = (key) => buffer_1.Buffer.from(key).toString('base64url');
|
|
30
|
-
exports.getNormalizedBlobKey = getNormalizedBlobKey;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getApiHandler = void 0;
|
|
4
|
-
// Aliasing like this means the editor may be able to syntax-highlight the string
|
|
5
|
-
const outdent_1 = require("outdent");
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
7
|
-
const { Server } = require('http');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
// eslint-disable-next-line n/prefer-global/url, n/prefer-global/url-search-params
|
|
10
|
-
const { URLSearchParams, URL } = require('url');
|
|
11
|
-
const { Bridge } = require('@vercel/node-bridge/bridge');
|
|
12
|
-
const { getMultiValueHeaders } = require('./handlerUtils');
|
|
13
|
-
const { getNetlifyNextServer } = require('./server');
|
|
14
|
-
// We return a function and then call `toString()` on it to serialise it as the launcher function
|
|
15
|
-
const makeApiHandler = ({ conf, app, pageRoot, NextServer }) => {
|
|
16
|
-
var _a;
|
|
17
|
-
// Change working directory into the site root, unless using Nx, which moves the
|
|
18
|
-
// dist directory and handles this itself
|
|
19
|
-
const dir = path.resolve(__dirname, app);
|
|
20
|
-
if (pageRoot.startsWith(dir)) {
|
|
21
|
-
process.chdir(dir);
|
|
22
|
-
}
|
|
23
|
-
// This is just so nft knows about the page entrypoints. It's not actually used
|
|
24
|
-
try {
|
|
25
|
-
// eslint-disable-next-line n/no-missing-require
|
|
26
|
-
require.resolve('./pages.js');
|
|
27
|
-
}
|
|
28
|
-
catch { }
|
|
29
|
-
const NetlifyNextServer = getNetlifyNextServer(NextServer);
|
|
30
|
-
(_a = process.env).NODE_ENV || (_a.NODE_ENV = 'production');
|
|
31
|
-
// We don't want to write ISR files to disk in the lambda environment
|
|
32
|
-
conf.experimental.isrFlushToDisk = false;
|
|
33
|
-
// This is our flag that we use when patching the source
|
|
34
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
35
|
-
process.env._BYPASS_SSG = 'true';
|
|
36
|
-
for (const [key, value] of Object.entries(conf.env)) {
|
|
37
|
-
process.env[key] = String(value);
|
|
38
|
-
}
|
|
39
|
-
// We memoize this because it can be shared between requests, but don't instantiate it until
|
|
40
|
-
// the first request because we need the host and port.
|
|
41
|
-
let bridge;
|
|
42
|
-
const getBridge = (event, context) => {
|
|
43
|
-
var _a;
|
|
44
|
-
if (bridge) {
|
|
45
|
-
return bridge;
|
|
46
|
-
}
|
|
47
|
-
const customContext = (_a = context.clientContext) === null || _a === void 0 ? void 0 : _a.custom;
|
|
48
|
-
// Scheduled functions don't have a URL, but we need to give one so Next knows the route to serve
|
|
49
|
-
const url = event.rawUrl ? new URL(event.rawUrl) : new URL(path, process.env.URL || 'http://n');
|
|
50
|
-
const port = Number.parseInt(url.port) || 80;
|
|
51
|
-
const nextServer = new NetlifyNextServer({
|
|
52
|
-
conf,
|
|
53
|
-
dir,
|
|
54
|
-
customServer: false,
|
|
55
|
-
hostname: url.hostname,
|
|
56
|
-
port,
|
|
57
|
-
}, {
|
|
58
|
-
revalidateToken: customContext === null || customContext === void 0 ? void 0 : customContext.odb_refresh_hooks,
|
|
59
|
-
});
|
|
60
|
-
const requestHandler = nextServer.getRequestHandler();
|
|
61
|
-
const server = new Server(async (req, res) => {
|
|
62
|
-
try {
|
|
63
|
-
await requestHandler(req, res);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
console.error(error);
|
|
67
|
-
throw new Error('Error handling request. See function logs for details.');
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
bridge = new Bridge(server);
|
|
71
|
-
bridge.listen();
|
|
72
|
-
return bridge;
|
|
73
|
-
};
|
|
74
|
-
return async function handler(event, context) {
|
|
75
|
-
// Ensure that paths are encoded - but don't double-encode them
|
|
76
|
-
event.path = new URL(event.rawUrl).pathname;
|
|
77
|
-
// Next expects to be able to parse the query from the URL
|
|
78
|
-
const query = new URLSearchParams(event.queryStringParameters).toString();
|
|
79
|
-
event.path = query ? `${event.path}?${query}` : event.path;
|
|
80
|
-
const { headers, ...result } = await getBridge(event, context).launcher(event, context);
|
|
81
|
-
// Convert all headers to multiValueHeaders
|
|
82
|
-
const multiValueHeaders = getMultiValueHeaders(headers);
|
|
83
|
-
multiValueHeaders['cache-control'] = ['public, max-age=0, must-revalidate'];
|
|
84
|
-
console.log(`[${event.httpMethod}] ${event.path} (API)`);
|
|
85
|
-
return {
|
|
86
|
-
...result,
|
|
87
|
-
multiValueHeaders,
|
|
88
|
-
isBase64Encoded: result.encoding === 'base64',
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Handlers for API routes are simpler than page routes, but they each have a separate one
|
|
94
|
-
*/
|
|
95
|
-
const getApiHandler = ({ schedule, publishDir = '../../../.next', appDir = '../../..', nextServerModuleRelativeLocation, }) =>
|
|
96
|
-
// This is a string, but if you have the right editor plugin it should format as js (e.g. bierner.comment-tagged-templates in VS Code)
|
|
97
|
-
(0, outdent_1.outdent /* javascript */) `
|
|
98
|
-
process.env.NODE_ENV = 'production';
|
|
99
|
-
if (!${JSON.stringify(nextServerModuleRelativeLocation)}) {
|
|
100
|
-
throw new Error('Could not find Next.js server')
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const { Server } = require("http");
|
|
104
|
-
// We copy the file here rather than requiring from the node module
|
|
105
|
-
const { Bridge } = require("./bridge");
|
|
106
|
-
const { getMultiValueHeaders } = require('./handlerUtils')
|
|
107
|
-
const { getNetlifyNextServer } = require('./server')
|
|
108
|
-
const NextServer = require(${JSON.stringify(nextServerModuleRelativeLocation)}).default
|
|
109
|
-
|
|
110
|
-
${schedule ? `const { schedule } = require("@netlify/functions")` : ''}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const { config } = require("${publishDir}/required-server-files.json")
|
|
114
|
-
let staticManifest
|
|
115
|
-
const path = require("path");
|
|
116
|
-
const pageRoot = path.resolve(path.join(__dirname, "${publishDir}", "server"));
|
|
117
|
-
const handler = (${makeApiHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer })
|
|
118
|
-
exports.handler = ${schedule ? `schedule(${JSON.stringify(schedule)}, handler);` : 'handler'}
|
|
119
|
-
`;
|
|
120
|
-
exports.getApiHandler = getApiHandler;
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHandler = void 0;
|
|
4
|
-
// Aliasing like this means the editor may be able to syntax-highlight the string
|
|
5
|
-
const outdent_1 = require("outdent");
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
7
|
-
const { Buffer } = require('buffer');
|
|
8
|
-
const { promises } = require('fs');
|
|
9
|
-
const { Server } = require('http');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
// eslint-disable-next-line n/prefer-global/url, n/prefer-global/url-search-params
|
|
12
|
-
const { URLSearchParams, URL } = require('url');
|
|
13
|
-
const { Bridge } = require('@vercel/node-bridge/bridge');
|
|
14
|
-
const { setBlobInit } = require('./blobStorage');
|
|
15
|
-
const { augmentFsModule, getMaxAge, getMultiValueHeaders, getPrefetchResponse, normalizePath } = require('./handlerUtils');
|
|
16
|
-
const { overrideRequireHooks, applyRequireHooks } = require('./requireHooks');
|
|
17
|
-
const { getNetlifyNextServer } = require('./server');
|
|
18
|
-
// We return a function and then call `toString()` on it to serialise it as the launcher function
|
|
19
|
-
// eslint-disable-next-line max-lines-per-function
|
|
20
|
-
const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], blobsManifest = new Set(), mode = 'ssr', useHooks, }) => {
|
|
21
|
-
var _a;
|
|
22
|
-
// Change working directory into the site root, unless using Nx, which moves the
|
|
23
|
-
// dist directory and handles this itself
|
|
24
|
-
const dir = path.resolve(__dirname, app);
|
|
25
|
-
if (pageRoot.startsWith(dir)) {
|
|
26
|
-
process.chdir(dir);
|
|
27
|
-
}
|
|
28
|
-
// This is just so nft knows about the page entrypoints. It's not actually used
|
|
29
|
-
try {
|
|
30
|
-
// eslint-disable-next-line n/no-missing-require
|
|
31
|
-
require.resolve('./pages.js');
|
|
32
|
-
}
|
|
33
|
-
catch { }
|
|
34
|
-
const { appDir } = conf.experimental;
|
|
35
|
-
// Next 13.4 conditionally uses different React versions and we need to make sure we use the same one
|
|
36
|
-
// With the release of 13.5 experimental.appDir is no longer used.
|
|
37
|
-
// we will need to check if appDir is set and Next version before running requireHooks
|
|
38
|
-
if (appDir && useHooks)
|
|
39
|
-
overrideRequireHooks(conf.experimental);
|
|
40
|
-
const NetlifyNextServer = getNetlifyNextServer(NextServer);
|
|
41
|
-
if (appDir && useHooks)
|
|
42
|
-
applyRequireHooks();
|
|
43
|
-
const ONE_YEAR_IN_SECONDS = 31536000;
|
|
44
|
-
(_a = process.env).NODE_ENV || (_a.NODE_ENV = 'production');
|
|
45
|
-
// We don't want to write ISR files to disk in the lambda environment
|
|
46
|
-
conf.experimental.isrFlushToDisk = false;
|
|
47
|
-
for (const [key, value] of Object.entries(conf.env)) {
|
|
48
|
-
process.env[key] = String(value);
|
|
49
|
-
}
|
|
50
|
-
// Set during the request as it needs to get it from the request URL. Defaults to the URL env var
|
|
51
|
-
let base = process.env.URL;
|
|
52
|
-
augmentFsModule({ promises, staticManifest, blobsManifest, pageRoot, getBase: () => base });
|
|
53
|
-
// We memoize this because it can be shared between requests, but don't instantiate it until
|
|
54
|
-
// the first request because we need the host and port.
|
|
55
|
-
let bridge;
|
|
56
|
-
const getBridge = (event, context) => {
|
|
57
|
-
const { clientContext: { custom: customContext }, } = context;
|
|
58
|
-
if (bridge) {
|
|
59
|
-
return bridge;
|
|
60
|
-
}
|
|
61
|
-
const url = new URL(event.rawUrl);
|
|
62
|
-
const port = Number.parseInt(url.port) || 80;
|
|
63
|
-
base = url.origin;
|
|
64
|
-
const nextServer = new NetlifyNextServer({
|
|
65
|
-
conf,
|
|
66
|
-
dir,
|
|
67
|
-
customServer: false,
|
|
68
|
-
hostname: url.hostname,
|
|
69
|
-
port,
|
|
70
|
-
}, {
|
|
71
|
-
revalidateToken: customContext === null || customContext === void 0 ? void 0 : customContext.odb_refresh_hooks,
|
|
72
|
-
});
|
|
73
|
-
const requestHandler = nextServer.getRequestHandler();
|
|
74
|
-
const server = new Server(async (req, res) => {
|
|
75
|
-
try {
|
|
76
|
-
await requestHandler(req, res);
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
throw new Error('Error handling request. See function logs for details.');
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
bridge = new Bridge(server);
|
|
83
|
-
bridge.listen();
|
|
84
|
-
return bridge;
|
|
85
|
-
};
|
|
86
|
-
return async function handler(event, context) {
|
|
87
|
-
var _a, _b, _c, _d, _e;
|
|
88
|
-
let requestMode = mode;
|
|
89
|
-
const prefetchResponse = getPrefetchResponse(event, mode);
|
|
90
|
-
if (prefetchResponse) {
|
|
91
|
-
return prefetchResponse;
|
|
92
|
-
}
|
|
93
|
-
event.path = normalizePath(event);
|
|
94
|
-
// Next expects to be able to parse the query from the URL
|
|
95
|
-
const query = new URLSearchParams(event.queryStringParameters).toString();
|
|
96
|
-
event.path = query ? `${event.path}?${query}` : event.path;
|
|
97
|
-
if (event.headers['accept-language'] && (mode === 'odb' || event.headers['x-next-just-first-accept-language'])) {
|
|
98
|
-
// keep just first language to match Netlify redirect limitation:
|
|
99
|
-
// https://docs.netlify.com/routing/redirects/redirect-options/#redirect-by-country-or-language
|
|
100
|
-
// > Language-based redirects always match against the first language reported by the browser in the Accept-Language header regardless of quality value weighting.
|
|
101
|
-
// If we wouldn't keep just first language, it's possible for `next-server` to generate locale redirect that could be cached by ODB
|
|
102
|
-
// because it matches on every language listed: https://github.com/vercel/next.js/blob/5d9597879c46b383d595d6f7b37fd373325b7544/test/unit/accept-headers.test.ts
|
|
103
|
-
// 'x-next-just-first-accept-language' header is escape hatch to be able to hit this code for tests (both automated and manual)
|
|
104
|
-
event.headers['accept-language'] = event.headers['accept-language'].replace(/\s*,.*$/, '');
|
|
105
|
-
}
|
|
106
|
-
if ((_b = (_a = context === null || context === void 0 ? void 0 : context.clientContext) === null || _a === void 0 ? void 0 : _a.custom) === null || _b === void 0 ? void 0 : _b.blobs) {
|
|
107
|
-
const rawData = Buffer.from(context.clientContext.custom.blobs, 'base64');
|
|
108
|
-
const data = JSON.parse(rawData.toString('ascii'));
|
|
109
|
-
setBlobInit({
|
|
110
|
-
authentication: {
|
|
111
|
-
contextURL: data.url,
|
|
112
|
-
token: data.token,
|
|
113
|
-
},
|
|
114
|
-
context: `deploy:${event.headers['x-nf-deploy-id']}`,
|
|
115
|
-
siteID: event.headers['x-nf-site-id'],
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
const { headers, ...result } = await getBridge(event, context).launcher(event, context);
|
|
119
|
-
// Convert all headers to multiValueHeaders
|
|
120
|
-
const multiValueHeaders = getMultiValueHeaders(headers);
|
|
121
|
-
if (event.headers['x-next-debug-logging']) {
|
|
122
|
-
const response = {
|
|
123
|
-
headers: multiValueHeaders,
|
|
124
|
-
statusCode: result.statusCode,
|
|
125
|
-
};
|
|
126
|
-
console.log('Next server response:', JSON.stringify(response, null, 2));
|
|
127
|
-
}
|
|
128
|
-
if ((_d = (_c = multiValueHeaders['set-cookie']) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.includes('__prerender_bypass')) {
|
|
129
|
-
delete multiValueHeaders.etag;
|
|
130
|
-
multiValueHeaders['cache-control'] = ['no-cache'];
|
|
131
|
-
}
|
|
132
|
-
// Sending SWR headers causes undefined behaviour with the Netlify CDN
|
|
133
|
-
const cacheHeader = (_e = multiValueHeaders['cache-control']) === null || _e === void 0 ? void 0 : _e[0];
|
|
134
|
-
if (cacheHeader === null || cacheHeader === void 0 ? void 0 : cacheHeader.includes('stale-while-revalidate')) {
|
|
135
|
-
if (requestMode === 'odb') {
|
|
136
|
-
const ttl = getMaxAge(cacheHeader);
|
|
137
|
-
// Long-expiry TTL is basically no TTL, so we'll skip it
|
|
138
|
-
if (ttl > 0 && ttl < ONE_YEAR_IN_SECONDS) {
|
|
139
|
-
// ODBs currently have a minimum TTL of 60 seconds
|
|
140
|
-
result.ttl = Math.max(ttl, 60);
|
|
141
|
-
}
|
|
142
|
-
const ephemeralCodes = [301, 302, 307, 308];
|
|
143
|
-
if (ttl === ONE_YEAR_IN_SECONDS && ephemeralCodes.includes(result.statusCode)) {
|
|
144
|
-
// Only cache for 60s if default TTL provided
|
|
145
|
-
result.ttl = 60;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
multiValueHeaders['cache-control'] = ['public, max-age=0, must-revalidate'];
|
|
149
|
-
}
|
|
150
|
-
// ISR 404s are not served with SWR headers so we need to set the TTL here
|
|
151
|
-
if (requestMode === 'odb' && result.statusCode === 404) {
|
|
152
|
-
result.ttl = 60;
|
|
153
|
-
}
|
|
154
|
-
if (result.ttl > 0) {
|
|
155
|
-
requestMode = `odb ttl=${result.ttl}`;
|
|
156
|
-
}
|
|
157
|
-
multiValueHeaders['x-nf-render-mode'] = [requestMode];
|
|
158
|
-
console.log(`[${event.httpMethod}] ${event.path} (${requestMode === null || requestMode === void 0 ? void 0 : requestMode.toUpperCase()})`);
|
|
159
|
-
return {
|
|
160
|
-
...result,
|
|
161
|
-
multiValueHeaders,
|
|
162
|
-
isBase64Encoded: result.encoding === 'base64',
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
const getHandler = ({ isODB = false, publishDir = '../../../.next', appDir = '../../..', nextServerModuleRelativeLocation, useHooks, }) =>
|
|
167
|
-
// This is a string, but if you have the right editor plugin it should format as js (e.g. bierner.comment-tagged-templates in VS Code)
|
|
168
|
-
(0, outdent_1.outdent /* javascript */) `
|
|
169
|
-
if (!${JSON.stringify(nextServerModuleRelativeLocation)}) {
|
|
170
|
-
throw new Error('Could not find Next.js server')
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
process.env.NODE_ENV = 'production';
|
|
174
|
-
|
|
175
|
-
const { Buffer } = require('buffer')
|
|
176
|
-
const { Server } = require("http");
|
|
177
|
-
const { promises } = require("fs");
|
|
178
|
-
const { setBlobInit } = require('./blobStorage')
|
|
179
|
-
// We copy the file here rather than requiring from the node module
|
|
180
|
-
const { Bridge } = require("./bridge");
|
|
181
|
-
const { augmentFsModule, getMaxAge, getMultiValueHeaders, getPrefetchResponse, normalizePath, nextVersionNum } = require('./handlerUtils')
|
|
182
|
-
const { overrideRequireHooks, applyRequireHooks } = require("./requireHooks")
|
|
183
|
-
const { getNetlifyNextServer } = require("./server")
|
|
184
|
-
const NextServer = require(${JSON.stringify(nextServerModuleRelativeLocation)}).default
|
|
185
|
-
${isODB ? `const { builder } = require("@netlify/functions")` : ''}
|
|
186
|
-
const { config } = require("${publishDir}/required-server-files.json")
|
|
187
|
-
let staticManifest
|
|
188
|
-
try {
|
|
189
|
-
staticManifest = require("${publishDir}/static-manifest.json")
|
|
190
|
-
} catch {}
|
|
191
|
-
let blobsManifest
|
|
192
|
-
try {
|
|
193
|
-
blobsManifest = new Set(require("${publishDir}/blobs-manifest.json"))
|
|
194
|
-
} catch {}
|
|
195
|
-
const path = require("path");
|
|
196
|
-
const pageRoot = path.resolve(path.join(__dirname, "${publishDir}", "server"));
|
|
197
|
-
exports.handler = ${isODB
|
|
198
|
-
? `builder((${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, blobsManifest, mode: 'odb', useHooks: ${useHooks}}));`
|
|
199
|
-
: `(${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, blobsManifest, mode: 'ssr', useHooks: ${useHooks}});`}
|
|
200
|
-
`;
|
|
201
|
-
exports.getHandler = getHandler;
|
|
@@ -1,54 +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.getResolverForSourceFiles = exports.getResolverForPages = exports.getResolverForDependencies = exports.getAllPageDependencies = exports.getUniqueDependencies = void 0;
|
|
7
|
-
const globby_1 = __importDefault(require("globby"));
|
|
8
|
-
const outdent_1 = require("outdent");
|
|
9
|
-
const pathe_1 = require("pathe");
|
|
10
|
-
const constants_1 = require("../constants");
|
|
11
|
-
const files_1 = require("../helpers/files");
|
|
12
|
-
// Generate a file full of require.resolve() calls for all the pages in the
|
|
13
|
-
// build. This is used by the nft bundler to find all the pages.
|
|
14
|
-
const getUniqueDependencies = async (sourceFiles) => {
|
|
15
|
-
const dependencies = await Promise.all(sourceFiles.map((sourceFile) => (0, files_1.getDependenciesOfFile)(sourceFile)));
|
|
16
|
-
return [...new Set([...sourceFiles, ...dependencies.flat()])].sort();
|
|
17
|
-
};
|
|
18
|
-
exports.getUniqueDependencies = getUniqueDependencies;
|
|
19
|
-
const getAllPageDependencies = async (publish) => {
|
|
20
|
-
const root = (0, pathe_1.resolve)(publish, 'server');
|
|
21
|
-
const pageFiles = await (0, globby_1.default)('{pages,app}/**/*.js', {
|
|
22
|
-
cwd: root,
|
|
23
|
-
dot: true,
|
|
24
|
-
});
|
|
25
|
-
// We don't use `absolute: true` because that returns Windows paths on Windows.
|
|
26
|
-
// Instead we use pathe to normalize the paths.
|
|
27
|
-
return (0, exports.getUniqueDependencies)(pageFiles.map((pageFile) => (0, pathe_1.join)(root, pageFile)));
|
|
28
|
-
};
|
|
29
|
-
exports.getAllPageDependencies = getAllPageDependencies;
|
|
30
|
-
const getResolverForDependencies = ({ dependencies, functionDir, }) => {
|
|
31
|
-
const pageFiles = dependencies.map((file) => `require.resolve('${(0, pathe_1.relative)(functionDir, file)}')`);
|
|
32
|
-
return (0, outdent_1.outdent /* javascript */) `
|
|
33
|
-
// This file is purely to allow nft to know about these pages.
|
|
34
|
-
exports.resolvePages = () => {
|
|
35
|
-
try {
|
|
36
|
-
${pageFiles.sort().join('\n ')}
|
|
37
|
-
} catch {}
|
|
38
|
-
}
|
|
39
|
-
`;
|
|
40
|
-
};
|
|
41
|
-
exports.getResolverForDependencies = getResolverForDependencies;
|
|
42
|
-
const getResolverForPages = async (publish, packagePath) => {
|
|
43
|
-
const functionDir = (0, pathe_1.resolve)(packagePath, '.netlify', 'functions', constants_1.HANDLER_FUNCTION_NAME);
|
|
44
|
-
const dependencies = await (0, exports.getAllPageDependencies)(publish);
|
|
45
|
-
return (0, exports.getResolverForDependencies)({ dependencies, functionDir });
|
|
46
|
-
};
|
|
47
|
-
exports.getResolverForPages = getResolverForPages;
|
|
48
|
-
const getResolverForSourceFiles = async ({ functionsDir, sourceFiles, }) => {
|
|
49
|
-
// We don't need the actual name, just the relative path.
|
|
50
|
-
const functionDir = (0, pathe_1.resolve)(functionsDir, 'functionName');
|
|
51
|
-
const dependencies = await (0, exports.getUniqueDependencies)(sourceFiles);
|
|
52
|
-
return (0, exports.getResolverForDependencies)({ dependencies, functionDir });
|
|
53
|
-
};
|
|
54
|
-
exports.getResolverForSourceFiles = getResolverForSourceFiles;
|