@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.
- 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-62KDS27E.js +77 -0
- package/dist/esm-chunks/chunk-AVWFCGVE.js +5536 -0
- package/dist/esm-chunks/chunk-B6QMRLBH.js +255 -0
- package/dist/esm-chunks/chunk-G2VRYWGL.js +107 -0
- package/dist/esm-chunks/chunk-G3GM7JNF.js +92 -0
- package/dist/esm-chunks/chunk-GGHAQM5D.js +28 -0
- package/dist/esm-chunks/chunk-HPGTYMVD.js +113 -0
- package/dist/esm-chunks/chunk-PEBUKFKH.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-XD5TSLZO.js +85 -0
- package/dist/esm-chunks/chunk-ZBX3SNQG.js +561 -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 +849 -0
- package/dist/run/handlers/server.js +3289 -0
- package/dist/run/headers.js +19 -0
- package/dist/run/next.cjs +1055 -0
- package/dist/run/revalidate.js +13 -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/edge-runtime/lib/util.ts +26 -0
- package/edge-runtime/middleware.ts +40 -0
- package/edge-runtime/shim/index.js +8 -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/matchers.json +0 -1
- 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/next-utils.ts +0 -407
- 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-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
|
@@ -1,268 +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.getMatchedRoute = exports.localizeDataRoute = exports.localizeRoute = exports.unlocalizeRoute = exports.joinPaths = exports.normalizeRoute = exports.netlifyApiFetch = exports.normalizePath = exports.getPrefetchResponse = exports.augmentFsModule = exports.getMultiValueHeaders = exports.getMaxAge = exports.downloadFileFromCDN = void 0;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const os_1 = require("os");
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const stream_1 = require("stream");
|
|
11
|
-
const util_1 = require("util");
|
|
12
|
-
const follow_redirects_1 = require("follow-redirects");
|
|
13
|
-
const streamPipeline = (0, util_1.promisify)(stream_1.pipeline);
|
|
14
|
-
const writeFilePromisified = (0, util_1.promisify)(fs_1.writeFile);
|
|
15
|
-
/**
|
|
16
|
-
* Downloads a file from the CDN to the local aliased filesystem. This is a fallback, because in most cases we'd expect
|
|
17
|
-
* files required at runtime to not be sent to the CDN.
|
|
18
|
-
*/
|
|
19
|
-
const downloadFileFromCDN = async (url, destination) => {
|
|
20
|
-
console.log(`Downloading ${url} from CDN to ${destination}`);
|
|
21
|
-
const httpx = url.startsWith('https') ? follow_redirects_1.https : follow_redirects_1.http;
|
|
22
|
-
await new Promise((resolve, reject) => {
|
|
23
|
-
const req = httpx.get(url, { timeout: 10000, maxRedirects: 1 }, (response) => {
|
|
24
|
-
if (response.statusCode < 200 || response.statusCode > 299) {
|
|
25
|
-
reject(new Error(`Failed to download ${url}: ${response.statusCode} ${response.statusMessage || ''}`));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const fileStream = (0, fs_1.createWriteStream)(destination);
|
|
29
|
-
streamPipeline(response, fileStream)
|
|
30
|
-
.then(resolve)
|
|
31
|
-
.catch((error) => {
|
|
32
|
-
console.log(`Error downloading ${url}`, error);
|
|
33
|
-
reject(error);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
req.on('error', (error) => {
|
|
37
|
-
console.log(`Error downloading ${url}`, error);
|
|
38
|
-
reject(error);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
exports.downloadFileFromCDN = downloadFileFromCDN;
|
|
43
|
-
const downloadFileFromBlobs = async (filePath, destination) => {
|
|
44
|
-
console.log(`Downloading ${filePath} from Blobs Storage to ${destination}`);
|
|
45
|
-
const { Blobs, getNormalizedBlobKey, getBlobInit } =
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
47
|
-
require('./blobStorage');
|
|
48
|
-
const netliBlob = new Blobs(getBlobInit());
|
|
49
|
-
const blobKey = getNormalizedBlobKey(filePath);
|
|
50
|
-
const fileContent = await netliBlob.get(blobKey, { type: 'text' });
|
|
51
|
-
await writeFilePromisified(destination, fileContent);
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Parse maxage from a cache-control header
|
|
55
|
-
*/
|
|
56
|
-
const getMaxAge = (header) => {
|
|
57
|
-
const parts = header.split(',');
|
|
58
|
-
let maxAge;
|
|
59
|
-
for (const part of parts) {
|
|
60
|
-
const [key, value] = part.split('=');
|
|
61
|
-
if ((key === null || key === void 0 ? void 0 : key.trim()) === 's-maxage') {
|
|
62
|
-
maxAge = value === null || value === void 0 ? void 0 : value.trim();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (maxAge) {
|
|
66
|
-
const result = Number.parseInt(maxAge);
|
|
67
|
-
return Number.isNaN(result) ? 0 : result;
|
|
68
|
-
}
|
|
69
|
-
return 0;
|
|
70
|
-
};
|
|
71
|
-
exports.getMaxAge = getMaxAge;
|
|
72
|
-
const getMultiValueHeaders = (headers) => {
|
|
73
|
-
const multiValueHeaders = {};
|
|
74
|
-
for (const key of Object.keys(headers)) {
|
|
75
|
-
const header = headers[key];
|
|
76
|
-
if (Array.isArray(header)) {
|
|
77
|
-
multiValueHeaders[key] = header;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
multiValueHeaders[key] = [header];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return multiValueHeaders;
|
|
84
|
-
};
|
|
85
|
-
exports.getMultiValueHeaders = getMultiValueHeaders;
|
|
86
|
-
/**
|
|
87
|
-
* Monkey-patch the fs module to download missing files from the CDN
|
|
88
|
-
*/
|
|
89
|
-
const augmentFsModule = ({ promises, staticManifest, blobsManifest, pageRoot, getBase, }) => {
|
|
90
|
-
// Only do this if we have some static files moved to the CDN
|
|
91
|
-
if (staticManifest.length === 0) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
// These are static page files that have been removed from the function bundle
|
|
95
|
-
// In most cases these are served from the CDN, but for rewrites Next may try to read them
|
|
96
|
-
// from disk. We need to intercept these and load them from the CDN instead
|
|
97
|
-
// Sadly the only way to do this is to monkey-patch fs.promises. Yeah, I know.
|
|
98
|
-
const staticFiles = new Map(staticManifest);
|
|
99
|
-
const downloadPromises = new Map();
|
|
100
|
-
// Yes, you can cache stuff locally in a Lambda
|
|
101
|
-
const cacheDir = path_1.default.join((0, os_1.tmpdir)(), 'next-static-cache');
|
|
102
|
-
// Grab the real fs.promises.readFile...
|
|
103
|
-
const readfileOrig = promises.readFile;
|
|
104
|
-
const statsOrig = promises.stat;
|
|
105
|
-
const { getBlobInit } =
|
|
106
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
107
|
-
require('./blobStorage');
|
|
108
|
-
// ...then monkey-patch it to see if it's requesting a CDN file
|
|
109
|
-
promises.readFile = (async (file, options) => {
|
|
110
|
-
// file argument can be a string, URL, etc - Next.js cache reading uses a string
|
|
111
|
-
// and that's only thing we really want to handle here, so we just do type checking
|
|
112
|
-
// instead of trying to handle all possible type before checking weather read
|
|
113
|
-
// is about page files.
|
|
114
|
-
if (typeof file === 'string' && file.startsWith(pageRoot)) {
|
|
115
|
-
const baseUrl = getBase();
|
|
116
|
-
// We only want the part after `.next/server/`
|
|
117
|
-
const filePath = file.slice(pageRoot.length + 1);
|
|
118
|
-
if (!(0, fs_1.existsSync)(file)) {
|
|
119
|
-
// Is it in the CDN or Blobs Storage and not local?
|
|
120
|
-
const isStatic = staticFiles.has(filePath);
|
|
121
|
-
const isBlob = getBlobInit() ? blobsManifest.has(filePath) : false;
|
|
122
|
-
if (isStatic || isBlob) {
|
|
123
|
-
// This name is safe to use, because it's one that was already created by Next
|
|
124
|
-
const cacheFile = path_1.default.join(cacheDir, filePath);
|
|
125
|
-
const url = `${baseUrl}/${staticFiles.get(filePath)}`;
|
|
126
|
-
// If it's already downloading we can wait for it to finish
|
|
127
|
-
if (downloadPromises.has(url)) {
|
|
128
|
-
await downloadPromises.get(url);
|
|
129
|
-
}
|
|
130
|
-
// Have we already cached it? We download every time if running locally to avoid staleness
|
|
131
|
-
if ((!(0, fs_1.existsSync)(cacheFile) || process.env.NETLIFY_DEV) && baseUrl) {
|
|
132
|
-
await promises.mkdir(path_1.default.dirname(cacheFile), { recursive: true });
|
|
133
|
-
try {
|
|
134
|
-
// Append the path to our host and we can load it like a regular page
|
|
135
|
-
const downloadPromise = isStatic
|
|
136
|
-
? (0, exports.downloadFileFromCDN)(url, cacheFile)
|
|
137
|
-
: downloadFileFromBlobs(filePath, cacheFile);
|
|
138
|
-
downloadPromises.set(url, downloadPromise);
|
|
139
|
-
await downloadPromise;
|
|
140
|
-
}
|
|
141
|
-
finally {
|
|
142
|
-
downloadPromises.delete(url);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// Return the cache file
|
|
146
|
-
return readfileOrig(cacheFile, options);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return readfileOrig(file, options);
|
|
151
|
-
});
|
|
152
|
-
promises.stat = ((file, options) => {
|
|
153
|
-
// We only care about page files
|
|
154
|
-
if (file.startsWith(pageRoot)) {
|
|
155
|
-
// We only want the part after `.next/server`
|
|
156
|
-
const cacheFile = path_1.default.join(cacheDir, file.slice(pageRoot.length + 1));
|
|
157
|
-
if ((0, fs_1.existsSync)(cacheFile)) {
|
|
158
|
-
return statsOrig(cacheFile, options);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return statsOrig(file, options);
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
exports.augmentFsModule = augmentFsModule;
|
|
165
|
-
/**
|
|
166
|
-
* Prefetch requests are used to check for middleware redirects, and shouldn't trigger SSR.
|
|
167
|
-
*/
|
|
168
|
-
const getPrefetchResponse = (event, mode) => {
|
|
169
|
-
if (event.headers['x-middleware-prefetch'] && mode === 'ssr') {
|
|
170
|
-
return {
|
|
171
|
-
statusCode: 200,
|
|
172
|
-
body: '{}',
|
|
173
|
-
headers: {
|
|
174
|
-
'Content-Type': 'application/json',
|
|
175
|
-
'x-middleware-skip': '1',
|
|
176
|
-
// https://github.com/vercel/next.js/pull/42936/files#r1027563953
|
|
177
|
-
vary: 'x-middleware-prefetch',
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
return false;
|
|
182
|
-
};
|
|
183
|
-
exports.getPrefetchResponse = getPrefetchResponse;
|
|
184
|
-
const normalizePath = (event) => {
|
|
185
|
-
var _a;
|
|
186
|
-
if ((_a = event.headers) === null || _a === void 0 ? void 0 : _a.rsc) {
|
|
187
|
-
const originalPath = event.headers['x-rsc-route'];
|
|
188
|
-
if (originalPath) {
|
|
189
|
-
if (event.headers['x-next-debug-logging']) {
|
|
190
|
-
console.log('Original path:', originalPath);
|
|
191
|
-
}
|
|
192
|
-
return originalPath;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (event.headers['x-original-path']) {
|
|
196
|
-
if (event.headers['x-next-debug-logging']) {
|
|
197
|
-
console.log('Original path:', event.headers['x-original-path']);
|
|
198
|
-
}
|
|
199
|
-
return event.headers['x-original-path'];
|
|
200
|
-
}
|
|
201
|
-
// Ensure that paths are encoded - but don't double-encode them
|
|
202
|
-
return new URL(event.rawUrl).pathname;
|
|
203
|
-
};
|
|
204
|
-
exports.normalizePath = normalizePath;
|
|
205
|
-
// Simple Netlify API client
|
|
206
|
-
const netlifyApiFetch = ({ endpoint, payload, token, method = 'GET', }) => new Promise((resolve, reject) => {
|
|
207
|
-
const body = JSON.stringify(payload);
|
|
208
|
-
const req = follow_redirects_1.https.request({
|
|
209
|
-
hostname: 'api.netlify.com',
|
|
210
|
-
port: 443,
|
|
211
|
-
path: `/api/v1/${endpoint}`,
|
|
212
|
-
method,
|
|
213
|
-
headers: {
|
|
214
|
-
'Content-Type': 'application/json',
|
|
215
|
-
'Content-Length': body.length,
|
|
216
|
-
Authorization: `Bearer ${token}`,
|
|
217
|
-
},
|
|
218
|
-
}, (res) => {
|
|
219
|
-
let data = '';
|
|
220
|
-
res.on('data', (chunk) => {
|
|
221
|
-
data += chunk;
|
|
222
|
-
});
|
|
223
|
-
res.on('end', () => {
|
|
224
|
-
resolve(JSON.parse(data));
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
req.on('error', reject);
|
|
228
|
-
req.write(body);
|
|
229
|
-
req.end();
|
|
230
|
-
});
|
|
231
|
-
exports.netlifyApiFetch = netlifyApiFetch;
|
|
232
|
-
// Remove trailing slash from a route (except for the root route)
|
|
233
|
-
const normalizeRoute = (route) => (route.endsWith('/') ? route.slice(0, -1) || '/' : route);
|
|
234
|
-
exports.normalizeRoute = normalizeRoute;
|
|
235
|
-
// Join multiple paths together, ensuring that there is only one slash between them
|
|
236
|
-
const joinPaths = (...paths) => paths.reduce((a, b) => (a.endsWith('/') ? `${a}${b}` : `${a}/${b}`));
|
|
237
|
-
exports.joinPaths = joinPaths;
|
|
238
|
-
// Check if a route has a locale prefix (including the root route)
|
|
239
|
-
const isLocalized = (route, i18n) => i18n.locales.some((locale) => route === `/${locale}` || route.startsWith(`/${locale}/`));
|
|
240
|
-
// Remove the locale prefix from a route (if any)
|
|
241
|
-
const unlocalizeRoute = (route, i18n) => isLocalized(route, i18n) ? `/${route.split('/').slice(2).join('/')}` : route;
|
|
242
|
-
exports.unlocalizeRoute = unlocalizeRoute;
|
|
243
|
-
// Add the default locale prefix to a route (if necessary)
|
|
244
|
-
const localizeRoute = (route, i18n) => isLocalized(route, i18n) ? route : (0, exports.normalizeRoute)(`/${i18n.defaultLocale}${route}`);
|
|
245
|
-
exports.localizeRoute = localizeRoute;
|
|
246
|
-
// Normalize a data route to include the locale prefix and remove the index suffix
|
|
247
|
-
const localizeDataRoute = (dataRoute, localizedRoute) => {
|
|
248
|
-
if (dataRoute.endsWith('.rsc'))
|
|
249
|
-
return dataRoute;
|
|
250
|
-
const locale = localizedRoute.split('/').find(Boolean);
|
|
251
|
-
return dataRoute
|
|
252
|
-
.replace(new RegExp(`/_next/data/(.+?)/(${locale}/)?`), `/_next/data/$1/${locale}/`)
|
|
253
|
-
.replace(/\/index\.json$/, '.json');
|
|
254
|
-
};
|
|
255
|
-
exports.localizeDataRoute = localizeDataRoute;
|
|
256
|
-
const getMatchedRoute = (paths, routesManifest, parsedUrl, basePath, trailingSlash) => routesManifest === null || routesManifest === void 0 ? void 0 : routesManifest.find((route) => {
|
|
257
|
-
// Some internationalized routes are automatically removing the locale prefix making the path not match the route
|
|
258
|
-
// we can use the parsedURL, which has the locale included and will match
|
|
259
|
-
const base = '/';
|
|
260
|
-
return new RegExp(route.regex).test(new URL(
|
|
261
|
-
// If using basepath config, we have to use the original path to match the route
|
|
262
|
-
// This seems to only be an issue on the index page when using group routes
|
|
263
|
-
parsedUrl ||
|
|
264
|
-
(basePath && paths === (trailingSlash && !(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith('/')) ? `${basePath}/` : basePath)
|
|
265
|
-
? base
|
|
266
|
-
: paths), 'http://n').pathname);
|
|
267
|
-
});
|
|
268
|
-
exports.getMatchedRoute = getMatchedRoute;
|
package/lib/templates/ipx.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handler = void 0;
|
|
4
|
-
const ipx_1 = require("@netlify/ipx");
|
|
5
|
-
// @ts-ignore Injected at build time
|
|
6
|
-
const imageconfig_json_1 = require("./imageconfig.json");
|
|
7
|
-
exports.handler = (0, ipx_1.createIPXHandler)({
|
|
8
|
-
basePath: imageconfig_json_1.basePath,
|
|
9
|
-
domains: imageconfig_json_1.domains,
|
|
10
|
-
remotePatterns: imageconfig_json_1.remotePatterns,
|
|
11
|
-
responseHeaders: imageconfig_json_1.responseHeaders,
|
|
12
|
-
});
|
|
13
|
-
/* eslint-enable import/no-unresolved, @typescript-eslint/ban-ts-comment */
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable no-underscore-dangle, @typescript-eslint/no-explicit-any */
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.applyRequireHooks = exports.overrideRequireHooks = void 0;
|
|
8
|
-
// This is a modified version of the require hooks from Next.js
|
|
9
|
-
// https://github.com/vercel/next.js/blob/b04c70573ac199a9bb3ea42201e0865e610d5b67/packages/next/src/server/require-hook.ts
|
|
10
|
-
const module_1 = __importDefault(require("module"));
|
|
11
|
-
const resolveFilename = module_1.default._resolveFilename;
|
|
12
|
-
const requireHooks = new Map();
|
|
13
|
-
const overrideRequireHooks = (experimental) => {
|
|
14
|
-
setRequireHooks(experimental);
|
|
15
|
-
resolveRequireHooks();
|
|
16
|
-
};
|
|
17
|
-
exports.overrideRequireHooks = overrideRequireHooks;
|
|
18
|
-
const setRequireHooks = (experimental) => {
|
|
19
|
-
requireHooks.set('default', new Map([
|
|
20
|
-
['react', `react`],
|
|
21
|
-
['react/jsx-runtime', `react/jsx-runtime`],
|
|
22
|
-
]));
|
|
23
|
-
if (experimental.appDir) {
|
|
24
|
-
if (experimental.serverActions) {
|
|
25
|
-
requireHooks.set('experimental', new Map([
|
|
26
|
-
['react', `next/dist/compiled/react-experimental`],
|
|
27
|
-
['react/jsx-runtime', `next/dist/compiled/react-experimental/jsx-runtime`],
|
|
28
|
-
['react/jsx-dev-runtime', `next/dist/compiled/react-experimental/jsx-dev-runtime`],
|
|
29
|
-
['react-dom', `next/dist/compiled/react-dom-experimental/server-rendering-stub`],
|
|
30
|
-
['react-dom/client', `next/dist/compiled/react-dom-experimental/client`],
|
|
31
|
-
['react-dom/server', `next/dist/compiled/react-dom-experimental/server`],
|
|
32
|
-
['react-dom/server.browser', `next/dist/compiled/react-dom-experimental/server.browser`],
|
|
33
|
-
['react-dom/server.edge', `next/dist/compiled/react-dom-experimental/server.edge`],
|
|
34
|
-
['react-server-dom-webpack/client', `next/dist/compiled/react-server-dom-webpack-experimental/client`],
|
|
35
|
-
[
|
|
36
|
-
'react-server-dom-webpack/client.edge',
|
|
37
|
-
`next/dist/compiled/react-server-dom-webpack-experimental/client.edge`,
|
|
38
|
-
],
|
|
39
|
-
[
|
|
40
|
-
'react-server-dom-webpack/server.edge',
|
|
41
|
-
`next/dist/compiled/react-server-dom-webpack-experimental/server.edge`,
|
|
42
|
-
],
|
|
43
|
-
[
|
|
44
|
-
'react-server-dom-webpack/server.node',
|
|
45
|
-
`next/dist/compiled/react-server-dom-webpack-experimental/server.node`,
|
|
46
|
-
],
|
|
47
|
-
['styled-jsx', 'styled-jsx'],
|
|
48
|
-
['styled-jsx/style', 'styled-jsx/style'],
|
|
49
|
-
]));
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
requireHooks.set('next', new Map([
|
|
53
|
-
['react', `next/dist/compiled/react`],
|
|
54
|
-
['react/jsx-runtime', `next/dist/compiled/react/jsx-runtime`],
|
|
55
|
-
['react/jsx-dev-runtime', `next/dist/compiled/react/jsx-dev-runtime`],
|
|
56
|
-
['react-dom', `next/dist/compiled/react-dom/server-rendering-stub`],
|
|
57
|
-
['react-dom/client', `next/dist/compiled/react-dom/client`],
|
|
58
|
-
['react-dom/server', `next/dist/compiled/react-dom/server`],
|
|
59
|
-
['react-dom/server.browser', `next/dist/compiled/react-dom/server.browser`],
|
|
60
|
-
['react-dom/server.edge', `next/dist/compiled/react-dom/server.edge`],
|
|
61
|
-
['react-server-dom-webpack/client', `next/dist/compiled/react-server-dom-webpack/client`],
|
|
62
|
-
['react-server-dom-webpack/client.edge', `next/dist/compiled/react-server-dom-webpack/client.edge`],
|
|
63
|
-
['react-server-dom-webpack/server.edge', `next/dist/compiled/react-server-dom-webpack/server.edge`],
|
|
64
|
-
['react-server-dom-webpack/server.node', `next/dist/compiled/react-server-dom-webpack/server.node`],
|
|
65
|
-
['styled-jsx', 'styled-jsx'],
|
|
66
|
-
['styled-jsx/style', 'styled-jsx/style'],
|
|
67
|
-
]));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const resolveRequireHooks = () => {
|
|
72
|
-
// we may have changed the working directory in the handler
|
|
73
|
-
const opts = { paths: [process.cwd()] };
|
|
74
|
-
// resolve require hooks with module paths
|
|
75
|
-
requireHooks.forEach((mode) => {
|
|
76
|
-
mode.forEach((path, hook) => {
|
|
77
|
-
try {
|
|
78
|
-
const resolvedPath = require.resolve(path, opts);
|
|
79
|
-
mode.set(hook, resolvedPath);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
if (error.code === 'MODULE_NOT_FOUND') {
|
|
83
|
-
// module not present (older version of Next.js)
|
|
84
|
-
mode.delete(hook);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
const applyRequireHooks = () => {
|
|
94
|
-
// eslint-disable-next-line max-params, func-names
|
|
95
|
-
;
|
|
96
|
-
module_1.default._resolveFilename = function (originalResolveFilename, hooks, request, parent, isMain, options) {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
const reactMode = process.env.__NEXT_PRIVATE_PREBUNDLED_REACT || 'default';
|
|
99
|
-
const resolvedRequest = (_b = (_a = hooks.get(reactMode)) === null || _a === void 0 ? void 0 : _a.get(request)) !== null && _b !== void 0 ? _b : request;
|
|
100
|
-
return originalResolveFilename.call(module_1.default, resolvedRequest, parent, isMain, options);
|
|
101
|
-
// We use `bind` here to avoid referencing outside variables to create potential memory leaks.
|
|
102
|
-
}.bind(null, resolveFilename, requireHooks);
|
|
103
|
-
};
|
|
104
|
-
exports.applyRequireHooks = applyRequireHooks;
|
|
105
|
-
/* eslint-enable no-underscore-dangle, @typescript-eslint/no-explicit-any */
|
package/lib/templates/server.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNetlifyNextServer = void 0;
|
|
4
|
-
// eslint-disable-next-line n/no-deprecated-api -- this is what Next.js uses as well
|
|
5
|
-
const url_1 = require("url");
|
|
6
|
-
const handlerUtils_1 = require("./handlerUtils");
|
|
7
|
-
// eslint-disable-next-line max-lines-per-function
|
|
8
|
-
const getNetlifyNextServer = (NextServer) => {
|
|
9
|
-
class NetlifyNextServer extends NextServer {
|
|
10
|
-
getAppRouterReactVersion() {
|
|
11
|
-
var _a;
|
|
12
|
-
return ((_a = this.nextConfig.experimental) === null || _a === void 0 ? void 0 : _a.serverActions) ? 'experimental' : 'next';
|
|
13
|
-
}
|
|
14
|
-
constructor(options, netlifyConfig) {
|
|
15
|
-
super(options);
|
|
16
|
-
this.netlifyConfig = netlifyConfig;
|
|
17
|
-
// copy the prerender manifest so it doesn't get mutated by Next.js
|
|
18
|
-
const manifest = this.getPrerenderManifest();
|
|
19
|
-
this.netlifyPrerenderManifest = {
|
|
20
|
-
...manifest,
|
|
21
|
-
routes: { ...manifest.routes },
|
|
22
|
-
dynamicRoutes: { ...manifest.dynamicRoutes },
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
getPrerenderManifest() {
|
|
26
|
-
const manifest = super.getPrerenderManifest();
|
|
27
|
-
if (typeof (manifest === null || manifest === void 0 ? void 0 : manifest.dynamicRoutes) === 'object') {
|
|
28
|
-
for (const route of Object.values(manifest.dynamicRoutes)) {
|
|
29
|
-
// 'fallback' property is:
|
|
30
|
-
// - a string when fallback: true is used
|
|
31
|
-
// - `null` when fallback: blocking is used
|
|
32
|
-
// - `false` when fallback: false is used
|
|
33
|
-
// `fallback: true` is not working correctly with ODBs
|
|
34
|
-
// as we will cache fallback html forever, so
|
|
35
|
-
// we are treating those as `fallback: blocking`
|
|
36
|
-
// by editing the manifest
|
|
37
|
-
if (typeof route.fallback === 'string') {
|
|
38
|
-
route.fallback = null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return manifest;
|
|
43
|
-
}
|
|
44
|
-
getRequestHandler() {
|
|
45
|
-
const handler = super.getRequestHandler();
|
|
46
|
-
return async (req, res, parsedUrl) => {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
if (!parsedUrl && typeof ((_a = req === null || req === void 0 ? void 0 : req.headers) === null || _a === void 0 ? void 0 : _a['x-middleware-rewrite']) === 'string') {
|
|
49
|
-
parsedUrl = (0, url_1.parse)(req.headers['x-middleware-rewrite'], true);
|
|
50
|
-
}
|
|
51
|
-
// preserve the URL before Next.js mutates it for i18n
|
|
52
|
-
const { url, headers } = req;
|
|
53
|
-
// conditionally use the prebundled React module
|
|
54
|
-
// PrebundledReact should only apply when appDir is set it falls between the specified Next versions
|
|
55
|
-
const { experimental } = this.nextConfig;
|
|
56
|
-
if (experimental === null || experimental === void 0 ? void 0 : experimental.appDir)
|
|
57
|
-
this.netlifyPrebundleReact(url, this.nextConfig, parsedUrl);
|
|
58
|
-
// intercept on-demand revalidation requests and handle with the Netlify API
|
|
59
|
-
if (headers['x-prerender-revalidate'] && this.netlifyConfig.revalidateToken) {
|
|
60
|
-
// handle on-demand revalidation by purging the ODB cache
|
|
61
|
-
await this.netlifyRevalidate(url);
|
|
62
|
-
res = res;
|
|
63
|
-
res.statusCode = 200;
|
|
64
|
-
res.setHeader('x-nextjs-cache', 'REVALIDATED');
|
|
65
|
-
res.send();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
// force Next to revalidate all requests so that we always have fresh content
|
|
69
|
-
// for our ODBs and middleware is disabled at the origin
|
|
70
|
-
// but ignore in preview mode (prerender_bypass is set to true in preview mode)
|
|
71
|
-
// because otherwise revalidate will override preview mode
|
|
72
|
-
if (!((_b = headers.cookie) === null || _b === void 0 ? void 0 : _b.includes('__prerender_bypass'))) {
|
|
73
|
-
const isFirstODBRequest = headers['x-nf-builder-cache'] === 'miss';
|
|
74
|
-
// first ODB request should NOT be revalidated and instead it should try to serve cached version
|
|
75
|
-
if (!isFirstODBRequest) {
|
|
76
|
-
// this header controls whether Next.js will revalidate the page
|
|
77
|
-
// and needs to be set to the preview mode id to enable it
|
|
78
|
-
headers['x-prerender-revalidate'] = this.renderOpts.previewProps.previewModeId;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return handler(req, res, parsedUrl);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
// doing what they do in https://github.com/vercel/vercel/blob/1663db7ca34d3dd99b57994f801fb30b72fbd2f3/packages/next/src/server-build.ts#L576-L580
|
|
85
|
-
async netlifyPrebundleReact(path, { basePath, trailingSlash }, parsedUrl) {
|
|
86
|
-
var _a, _b;
|
|
87
|
-
const routesManifest = (_a = this.getRoutesManifest) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
88
|
-
const appPathsRoutes = (_b = this.getAppPathRoutes) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
89
|
-
const routes = routesManifest && [...routesManifest.staticRoutes, ...routesManifest.dynamicRoutes];
|
|
90
|
-
const matchedRoute = await (0, handlerUtils_1.getMatchedRoute)(path, routes, parsedUrl, basePath, trailingSlash);
|
|
91
|
-
const isAppRoute = appPathsRoutes && matchedRoute ? appPathsRoutes[matchedRoute.page] : false;
|
|
92
|
-
if (isAppRoute) {
|
|
93
|
-
// app routes should use prebundled React
|
|
94
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
95
|
-
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = this.getAppRouterReactVersion();
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
99
|
-
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = '';
|
|
100
|
-
}
|
|
101
|
-
async netlifyRevalidate(route) {
|
|
102
|
-
try {
|
|
103
|
-
// call netlify API to revalidate the path
|
|
104
|
-
const result = await (0, handlerUtils_1.netlifyApiFetch)({
|
|
105
|
-
endpoint: `sites/${process.env.SITE_ID}/refresh_on_demand_builders`,
|
|
106
|
-
payload: {
|
|
107
|
-
paths: this.getNetlifyPathsForRoute(route),
|
|
108
|
-
domain: this.hostname,
|
|
109
|
-
},
|
|
110
|
-
token: this.netlifyConfig.revalidateToken,
|
|
111
|
-
method: 'POST',
|
|
112
|
-
});
|
|
113
|
-
if (!result.ok) {
|
|
114
|
-
throw new Error(result.message);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
console.log(`Error revalidating ${route}:`, error.message);
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// eslint-disable-next-line class-methods-use-this, require-await
|
|
123
|
-
async runMiddleware() {
|
|
124
|
-
return {
|
|
125
|
-
finished: false,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
getNetlifyPathsForRoute(route) {
|
|
129
|
-
const { i18n } = this.nextConfig;
|
|
130
|
-
const { routes, dynamicRoutes } = this.netlifyPrerenderManifest;
|
|
131
|
-
// matches static routes
|
|
132
|
-
const normalizedRoute = (0, handlerUtils_1.normalizeRoute)(i18n ? (0, handlerUtils_1.localizeRoute)(route, i18n) : route);
|
|
133
|
-
if (normalizedRoute in routes) {
|
|
134
|
-
const { dataRoute } = routes[normalizedRoute];
|
|
135
|
-
const normalizedDataRoute = i18n ? (0, handlerUtils_1.localizeDataRoute)(dataRoute, normalizedRoute) : dataRoute;
|
|
136
|
-
return [route, normalizedDataRoute];
|
|
137
|
-
}
|
|
138
|
-
// matches dynamic routes
|
|
139
|
-
const unlocalizedRoute = i18n ? (0, handlerUtils_1.unlocalizeRoute)(normalizedRoute, i18n) : normalizedRoute;
|
|
140
|
-
for (const dynamicRoute in dynamicRoutes) {
|
|
141
|
-
const { dataRoute, routeRegex } = dynamicRoutes[dynamicRoute];
|
|
142
|
-
const matches = unlocalizedRoute.match(routeRegex);
|
|
143
|
-
if ((matches === null || matches === void 0 ? void 0 : matches.length) > 0) {
|
|
144
|
-
// remove the first match, which is the full route
|
|
145
|
-
matches.shift();
|
|
146
|
-
// replace the dynamic segments with the actual values
|
|
147
|
-
const interpolatedDataRoute = dataRoute.replace(/\[(.*?)]/g, () => matches.shift());
|
|
148
|
-
const normalizedDataRoute = i18n
|
|
149
|
-
? (0, handlerUtils_1.localizeDataRoute)(interpolatedDataRoute, normalizedRoute)
|
|
150
|
-
: interpolatedDataRoute;
|
|
151
|
-
return [route, normalizedDataRoute];
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
throw new Error(`not an ISR route`);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return NetlifyNextServer;
|
|
158
|
-
};
|
|
159
|
-
exports.getNetlifyNextServer = getNetlifyNextServer;
|
package/lib/templates/vendor.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// this file isn't meant to be imported.
|
|
3
|
-
// it's a list of all external modules that we use,
|
|
4
|
-
// and we vendor those into the `vendor/` directory
|
|
5
|
-
// for consumption in other files.
|
|
6
|
-
// Vendoring happens automatically as part of runtime `build` script.
|
|
7
|
-
// You can trigger just vendoring without full package build by running `build:vendor` script.
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
require("https://deno.land/std@0.175.0/encoding/base64.ts");
|
|
10
|
-
require("https://deno.land/std@0.175.0/http/cookie.ts");
|
|
11
|
-
require("https://deno.land/std@0.175.0/node/buffer.ts");
|
|
12
|
-
require("https://deno.land/std@0.175.0/node/events.ts");
|
|
13
|
-
require("https://deno.land/std@0.175.0/node/async_hooks.ts");
|
|
14
|
-
require("https://deno.land/std@0.175.0/node/assert.ts");
|
|
15
|
-
require("https://deno.land/std@0.175.0/node/util.ts");
|
|
16
|
-
require("https://deno.land/std@0.175.0/path/mod.ts");
|
|
17
|
-
require("https://deno.land/x/path_to_regexp@v6.2.1/index.ts");
|
|
18
|
-
require("https://deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts");
|
|
19
|
-
require("https://esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js");
|
|
20
|
-
require("https://esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js");
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This placeholder is replaced with the compiled Next.js bundle at build time
|
|
3
|
-
* @param {Object} props
|
|
4
|
-
* @param {import("./function-runtime.ts").RequestData} props.request
|
|
5
|
-
* @returns {Promise<import("../edge-shared/utils.ts").FetchEventResult>}
|
|
6
|
-
*/
|
|
7
|
-
export default async ({ request }) => {}
|
|
8
|
-
export const _DEFINITION = { env: [], files: [], page: 'placeholder', name: 'pages_placeholder', matchers: [] }
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'https://edge.netlify.com'
|
|
2
|
-
// Available at build time
|
|
3
|
-
import { _DEFINITION as edgeFunctionDefinition, default as edgeFunction } from './bundle.js'
|
|
4
|
-
import { buildNextRequest, buildResponse, redirectTrailingSlash } from '../edge-shared/utils.ts'
|
|
5
|
-
import nextConfig from '../edge-shared/nextConfig.json' assert { type: 'json' }
|
|
6
|
-
|
|
7
|
-
const handler = async (req: Request, context: Context) => {
|
|
8
|
-
const url = new URL(req.url)
|
|
9
|
-
const redirect = redirectTrailingSlash(url, nextConfig.trailingSlash)
|
|
10
|
-
if (redirect) {
|
|
11
|
-
return redirect
|
|
12
|
-
}
|
|
13
|
-
const request = buildNextRequest(req, context, nextConfig)
|
|
14
|
-
request.headers['x-matched-path'] ||= edgeFunctionDefinition.page
|
|
15
|
-
try {
|
|
16
|
-
const result = await edgeFunction({ request })
|
|
17
|
-
return buildResponse({ result, request: req, context })
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error(error)
|
|
20
|
-
return new Response(error.message, { status: 500 })
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default handler
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[]
|