@netlify/plugin-nextjs 4.40.1 → 4.40.3-rc.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/lib/helpers/config.js +10 -2
- package/lib/helpers/edge.js +3 -5
- package/lib/helpers/functions.js +2 -0
- package/lib/helpers/functionsMetaData.js +6 -3
- package/lib/index.js +1 -1
- package/lib/templates/getHandler.js +12 -7
- package/lib/templates/requireHooks.js +5 -5
- package/lib/templates/server.js +4 -1
- package/lib/templates/vendor.js +20 -0
- package/package.json +7 -4
- package/src/templates/edge/next-dev.js +3 -3
- package/src/templates/edge/shims.js +6 -6
- package/src/templates/edge-shared/next-utils.ts +3 -3
- package/src/templates/edge-shared/utils.ts +1 -1
- package/src/templates/vendor/deno.land/std@0.134.0/fmt/colors.ts +536 -0
- package/src/templates/vendor/deno.land/std@0.134.0/testing/_diff.ts +360 -0
- package/src/templates/vendor/deno.land/std@0.134.0/testing/asserts.ts +866 -0
- package/src/templates/vendor/deno.land/std@0.175.0/_util/asserts.ts +25 -0
- package/src/templates/vendor/deno.land/std@0.175.0/_util/os.ts +23 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/abortable.ts +149 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/deadline.ts +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/debounce.ts +79 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/deferred.ts +48 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/delay.ts +67 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/mod.ts +18 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +97 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/pool.ts +95 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/retry.ts +81 -0
- package/src/templates/vendor/deno.land/std@0.175.0/async/tee.ts +100 -0
- package/src/templates/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +49 -0
- package/src/templates/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +29 -0
- package/src/templates/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +45 -0
- package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64.ts +144 -0
- package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64url.ts +70 -0
- package/src/templates/vendor/deno.land/std@0.175.0/flags/mod.ts +785 -0
- package/src/templates/vendor/deno.land/std@0.175.0/fmt/colors.ts +569 -0
- package/src/templates/vendor/deno.land/std@0.175.0/fmt/printf.ts +939 -0
- package/src/templates/vendor/deno.land/std@0.175.0/http/cookie.ts +403 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_core.ts +77 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_events.d.ts +848 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_events.mjs +1033 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_global.d.ts +66 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_next_tick.ts +173 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +4 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/process.ts +131 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +146 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.d.ts +1488 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.mjs +746 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +129 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/_utils.ts +206 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/assert.ts +940 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/assertion_error.ts +579 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/async_hooks.ts +331 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/buffer.ts +13 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/events.ts +14 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +2074 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +2607 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +5 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/errors.ts +2867 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +123 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/net.ts +95 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +72 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/options.ts +45 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +272 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +137 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +580 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +320 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +229 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +242 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +669 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +118 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +2237 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +113 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util.mjs +143 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +317 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +229 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +16 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +18 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +12 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +86 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +16873 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +66 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +152 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +130 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +541 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +80 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +900 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +14 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +50 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +108 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +84 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +39 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +392 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +354 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +15 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +27 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +488 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +186 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +496 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +126 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +437 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +3 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/process.ts +705 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/stream.ts +37 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/string_decoder.ts +337 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/util/types.ts +4 -0
- package/src/templates/vendor/deno.land/std@0.175.0/node/util.ts +289 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_constants.ts +49 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_interface.ts +30 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/_util.ts +194 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/common.ts +40 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/glob.ts +418 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/mod.ts +53 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/posix.ts +487 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/separator.ts +7 -0
- package/src/templates/vendor/deno.land/std@0.175.0/path/win32.ts +962 -0
- package/src/templates/vendor/deno.land/std@0.175.0/streams/write_all.ts +64 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/_diff.ts +440 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/_format.ts +23 -0
- package/src/templates/vendor/deno.land/std@0.175.0/testing/asserts.ts +906 -0
- package/src/templates/vendor/deno.land/std@0.175.0/types.d.ts +89 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +133 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +112 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +88 -0
- package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +974 -0
- package/src/templates/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +621 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +8 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/error.js +9 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/next-url.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/cookies.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/utils.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/get-hostname.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/i18n/detect-domain-locale.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/i18n/normalize-locale-path.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/add-locale.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/add-path-prefix.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/add-path-suffix.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/format-next-pathname-info.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/get-next-pathname-info.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/parse-path.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/path-has-prefix.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/remove-path-prefix.js +2 -0
- package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/shared/lib/router/utils/remove-trailing-slash.js +2 -0
- package/src/templates/vendor/import_map.json +29 -0
- package/src/templates/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +50 -0
package/lib/helpers/config.js
CHANGED
|
@@ -49,9 +49,9 @@ const updateRequiredServerFiles = async (publish, modifiedConfig) => {
|
|
|
49
49
|
await (0, fs_extra_1.writeJSON)(configFile, modifiedConfig);
|
|
50
50
|
};
|
|
51
51
|
exports.updateRequiredServerFiles = updateRequiredServerFiles;
|
|
52
|
-
const resolveModuleRoot = (moduleName) => {
|
|
52
|
+
const resolveModuleRoot = (moduleName, paths = [process.cwd()]) => {
|
|
53
53
|
try {
|
|
54
|
-
return (0, pathe_1.dirname)((0, pathe_1.relative)(process.cwd(), require.resolve(`${moduleName}/package.json`, { paths
|
|
54
|
+
return (0, pathe_1.dirname)((0, pathe_1.relative)(process.cwd(), require.resolve(`${moduleName}/package.json`, { paths })));
|
|
55
55
|
}
|
|
56
56
|
catch {
|
|
57
57
|
return null;
|
|
@@ -89,6 +89,14 @@ const configureHandlerFunctions = async ({ netlifyConfig, publish, ignore = [],
|
|
|
89
89
|
const nextRoot = (0, exports.resolveModuleRoot)('next');
|
|
90
90
|
if (nextRoot) {
|
|
91
91
|
netlifyConfig.functions[functionName].included_files.push(`!${nextRoot}/dist/server/lib/squoosh/**/*.wasm`, `!${nextRoot}/dist/next-server/server/lib/squoosh/**/*.wasm`, `!${nextRoot}/dist/compiled/webpack/bundle4.js`, `!${nextRoot}/dist/compiled/webpack/bundle5.js`);
|
|
92
|
+
// on Next 13.5+ there is no longer statically analyzable import to styled-jsx/style
|
|
93
|
+
// so lambda fails to bundle it. Next require hooks actually try to resolve it
|
|
94
|
+
// and fail if it is not bundled, so we forcefully add it to lambda.
|
|
95
|
+
const styledJsxRoot = (0, exports.resolveModuleRoot)('styled-jsx', [(0, pathe_1.join)(process.cwd(), nextRoot)]);
|
|
96
|
+
if (styledJsxRoot) {
|
|
97
|
+
const styledJsxStyleModulePath = (0, pathe_1.join)(styledJsxRoot, 'style.js');
|
|
98
|
+
netlifyConfig.functions[functionName].included_files.push(styledJsxStyleModulePath);
|
|
99
|
+
}
|
|
92
100
|
}
|
|
93
101
|
excludedModules.forEach((moduleName) => {
|
|
94
102
|
const moduleRoot = (0, exports.resolveModuleRoot)(moduleName);
|
package/lib/helpers/edge.js
CHANGED
|
@@ -197,7 +197,6 @@ exports.getEdgeFunctionPatternForPage = getEdgeFunctionPatternForPage;
|
|
|
197
197
|
*/
|
|
198
198
|
// eslint-disable-next-line max-lines-per-function
|
|
199
199
|
const writeEdgeFunctions = async ({ netlifyConfig, routesManifest, constants: { PACKAGE_PATH = '' }, }) => {
|
|
200
|
-
var _a;
|
|
201
200
|
const generator = await (0, functionsMetaData_1.getPluginVersion)();
|
|
202
201
|
const manifest = {
|
|
203
202
|
functions: [],
|
|
@@ -209,7 +208,7 @@ const writeEdgeFunctions = async ({ netlifyConfig, routesManifest, constants: {
|
|
|
209
208
|
const { publish } = netlifyConfig.build;
|
|
210
209
|
const nextConfigFile = await (0, config_1.getRequiredServerFiles)(publish);
|
|
211
210
|
const nextConfig = nextConfigFile.config;
|
|
212
|
-
|
|
211
|
+
await (0, fs_extra_1.copy)(getEdgeTemplatePath('../vendor'), (0, path_1.join)(edgeFunctionRoot, 'vendor'));
|
|
213
212
|
await (0, fs_extra_1.copy)(getEdgeTemplatePath('../edge-shared'), (0, path_1.join)(edgeFunctionRoot, 'edge-shared'));
|
|
214
213
|
await (0, fs_extra_1.writeJSON)((0, path_1.join)(edgeFunctionRoot, 'edge-shared', 'nextConfig.json'), nextConfig);
|
|
215
214
|
await (0, fs_extra_1.copy)((0, path_1.join)(publish, 'prerender-manifest.json'), (0, path_1.join)(edgeFunctionRoot, 'edge-shared', 'prerender-manifest.json'));
|
|
@@ -278,8 +277,7 @@ const writeEdgeFunctions = async ({ netlifyConfig, routesManifest, constants: {
|
|
|
278
277
|
function: functionName,
|
|
279
278
|
name: edgeFunctionDefinition.name,
|
|
280
279
|
pattern,
|
|
281
|
-
|
|
282
|
-
cache: usesAppDir ? 'manual' : undefined,
|
|
280
|
+
cache: 'manual',
|
|
283
281
|
generator,
|
|
284
282
|
});
|
|
285
283
|
// pages-dir page routes also have a data route. If there's a match, add an entry mapping that to the function too
|
|
@@ -289,7 +287,7 @@ const writeEdgeFunctions = async ({ netlifyConfig, routesManifest, constants: {
|
|
|
289
287
|
function: functionName,
|
|
290
288
|
name: edgeFunctionDefinition.name,
|
|
291
289
|
pattern: dataRoute,
|
|
292
|
-
cache:
|
|
290
|
+
cache: 'manual',
|
|
293
291
|
generator,
|
|
294
292
|
});
|
|
295
293
|
}
|
package/lib/helpers/functions.js
CHANGED
|
@@ -66,11 +66,13 @@ const generateFunctions = async ({ INTERNAL_FUNCTIONS_SRC, PUBLISH_DIR, PACKAGE_
|
|
|
66
66
|
includedFiles.push(...nfInternalFiles);
|
|
67
67
|
}
|
|
68
68
|
const writeHandler = async (functionName, functionTitle, isODB) => {
|
|
69
|
+
const useHooks = await (0, functionsMetaData_1.useRequireHooks)();
|
|
69
70
|
const handlerSource = (0, getHandler_1.getHandler)({
|
|
70
71
|
isODB,
|
|
71
72
|
publishDir,
|
|
72
73
|
appDir: (0, pathe_1.relative)(functionDir, appDir),
|
|
73
74
|
nextServerModuleRelativeLocation,
|
|
75
|
+
useHooks,
|
|
74
76
|
});
|
|
75
77
|
await (0, fs_extra_1.ensureDir)((0, pathe_1.join)(functionsDir, functionName));
|
|
76
78
|
// write main handler file (standard or ODB)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeFunctionConfiguration = exports.getPluginVersion = void 0;
|
|
3
|
+
exports.writeFunctionConfiguration = exports.useRequireHooks = exports.getPluginVersion = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const pathe_1 = require("pathe");
|
|
6
|
+
const semver_1 = require("semver");
|
|
6
7
|
const constants_1 = require("../constants");
|
|
7
8
|
const config_1 = require("./config");
|
|
8
9
|
const getNextRuntimeVersion = async (packageJsonPath, useNodeModulesPath) => {
|
|
@@ -13,8 +14,8 @@ const getNextRuntimeVersion = async (packageJsonPath, useNodeModulesPath) => {
|
|
|
13
14
|
return useNodeModulesPath ? packagePlugin.version : packagePlugin.dependencies[constants_1.NEXT_PLUGIN];
|
|
14
15
|
};
|
|
15
16
|
const PLUGIN_PACKAGE_PATH = '.netlify/plugins/package.json';
|
|
16
|
-
const nextPluginVersion = async () => {
|
|
17
|
-
const moduleRoot = (0, config_1.resolveModuleRoot)(constants_1.NEXT_PLUGIN);
|
|
17
|
+
const nextPluginVersion = async (module) => {
|
|
18
|
+
const moduleRoot = (0, config_1.resolveModuleRoot)(module || constants_1.NEXT_PLUGIN);
|
|
18
19
|
const nodeModulesPath = moduleRoot ? (0, pathe_1.join)(moduleRoot, 'package.json') : null;
|
|
19
20
|
return ((await getNextRuntimeVersion(nodeModulesPath, true)) ||
|
|
20
21
|
(await getNextRuntimeVersion(PLUGIN_PACKAGE_PATH, false)) ||
|
|
@@ -23,6 +24,8 @@ const nextPluginVersion = async () => {
|
|
|
23
24
|
};
|
|
24
25
|
const getPluginVersion = async () => `${constants_1.NEXT_PLUGIN_NAME}@${await nextPluginVersion()}`;
|
|
25
26
|
exports.getPluginVersion = getPluginVersion;
|
|
27
|
+
const useRequireHooks = async () => (0, semver_1.satisfies)(await nextPluginVersion('next'), '13.3.3 - 13.4.9');
|
|
28
|
+
exports.useRequireHooks = useRequireHooks;
|
|
26
29
|
/**
|
|
27
30
|
* Creates a function configuration file for the given function.
|
|
28
31
|
*
|
package/lib/index.js
CHANGED
|
@@ -144,7 +144,7 @@ const plugin = {
|
|
|
144
144
|
await (0, verification_1.checkForOldFunctions)({ functions });
|
|
145
145
|
await (0, verification_1.checkZipSize)((0, path_1.join)(FUNCTIONS_DIST, `${constants_1.ODB_FUNCTION_NAME}.zip`));
|
|
146
146
|
const nextConfig = await (0, config_1.getNextConfig)({ publish, failBuild });
|
|
147
|
-
const { basePath, appDir, experimental } = nextConfig;
|
|
147
|
+
const { basePath, appDir, experimental, } = nextConfig;
|
|
148
148
|
(0, config_1.generateCustomHeaders)(nextConfig, headers);
|
|
149
149
|
(0, verification_1.warnForProblematicUserRewrites)({ basePath, redirects });
|
|
150
150
|
(0, verification_1.warnForRootRedirects)({ appDir });
|
|
@@ -15,7 +15,7 @@ const { overrideRequireHooks, applyRequireHooks } = require('./requireHooks');
|
|
|
15
15
|
const { getNetlifyNextServer } = require('./server');
|
|
16
16
|
// We return a function and then call `toString()` on it to serialise it as the launcher function
|
|
17
17
|
// eslint-disable-next-line max-lines-per-function
|
|
18
|
-
const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mode = 'ssr' }) => {
|
|
18
|
+
const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mode = 'ssr', useHooks, }) => {
|
|
19
19
|
var _a;
|
|
20
20
|
// Change working directory into the site root, unless using Nx, which moves the
|
|
21
21
|
// dist directory and handles this itself
|
|
@@ -29,10 +29,15 @@ const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mod
|
|
|
29
29
|
require.resolve('./pages.js');
|
|
30
30
|
}
|
|
31
31
|
catch { }
|
|
32
|
+
const { appDir } = conf.experimental;
|
|
32
33
|
// Next 13.4 conditionally uses different React versions and we need to make sure we use the same one
|
|
33
|
-
|
|
34
|
+
// With the release of 13.5 experimental.appDir is no longer used.
|
|
35
|
+
// we will need to check if appDir is set and Next version before running requireHooks
|
|
36
|
+
if (appDir && useHooks)
|
|
37
|
+
overrideRequireHooks(conf.experimental);
|
|
34
38
|
const NetlifyNextServer = getNetlifyNextServer(NextServer);
|
|
35
|
-
|
|
39
|
+
if (appDir && useHooks)
|
|
40
|
+
applyRequireHooks();
|
|
36
41
|
const ONE_YEAR_IN_SECONDS = 31536000;
|
|
37
42
|
(_a = process.env).NODE_ENV || (_a.NODE_ENV = 'production');
|
|
38
43
|
// We don't want to write ISR files to disk in the lambda environment
|
|
@@ -144,7 +149,7 @@ const makeHandler = ({ conf, app, pageRoot, NextServer, staticManifest = [], mod
|
|
|
144
149
|
};
|
|
145
150
|
};
|
|
146
151
|
};
|
|
147
|
-
const getHandler = ({ isODB = false, publishDir = '../../../.next', appDir = '../../..', nextServerModuleRelativeLocation, }) =>
|
|
152
|
+
const getHandler = ({ isODB = false, publishDir = '../../../.next', appDir = '../../..', nextServerModuleRelativeLocation, useHooks, }) =>
|
|
148
153
|
// 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)
|
|
149
154
|
(0, outdent_1.outdent /* javascript */) `
|
|
150
155
|
if (!${JSON.stringify(nextServerModuleRelativeLocation)}) {
|
|
@@ -157,7 +162,7 @@ const getHandler = ({ isODB = false, publishDir = '../../../.next', appDir = '..
|
|
|
157
162
|
const { promises } = require("fs");
|
|
158
163
|
// We copy the file here rather than requiring from the node module
|
|
159
164
|
const { Bridge } = require("./bridge");
|
|
160
|
-
const { augmentFsModule, getMaxAge, getMultiValueHeaders, getPrefetchResponse, normalizePath } = require('./handlerUtils')
|
|
165
|
+
const { augmentFsModule, getMaxAge, getMultiValueHeaders, getPrefetchResponse, normalizePath, nextVersionNum } = require('./handlerUtils')
|
|
161
166
|
const { overrideRequireHooks, applyRequireHooks } = require("./requireHooks")
|
|
162
167
|
const { getNetlifyNextServer } = require("./server")
|
|
163
168
|
const NextServer = require(${JSON.stringify(nextServerModuleRelativeLocation)}).default
|
|
@@ -170,7 +175,7 @@ const getHandler = ({ isODB = false, publishDir = '../../../.next', appDir = '..
|
|
|
170
175
|
const path = require("path");
|
|
171
176
|
const pageRoot = path.resolve(path.join(__dirname, "${publishDir}", "server"));
|
|
172
177
|
exports.handler = ${isODB
|
|
173
|
-
? `builder((${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'odb' }));`
|
|
174
|
-
: `(${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'ssr' });`}
|
|
178
|
+
? `builder((${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'odb', useHooks: ${useHooks}}));`
|
|
179
|
+
: `(${makeHandler.toString()})({ conf: config, app: "${appDir}", pageRoot, NextServer, staticManifest, mode: 'ssr', useHooks: ${useHooks}});`}
|
|
175
180
|
`;
|
|
176
181
|
exports.getHandler = getHandler;
|
|
@@ -10,18 +10,18 @@ exports.applyRequireHooks = exports.overrideRequireHooks = void 0;
|
|
|
10
10
|
const module_1 = __importDefault(require("module"));
|
|
11
11
|
const resolveFilename = module_1.default._resolveFilename;
|
|
12
12
|
const requireHooks = new Map();
|
|
13
|
-
const overrideRequireHooks = (
|
|
14
|
-
setRequireHooks(
|
|
13
|
+
const overrideRequireHooks = (experimental) => {
|
|
14
|
+
setRequireHooks(experimental);
|
|
15
15
|
resolveRequireHooks();
|
|
16
16
|
};
|
|
17
17
|
exports.overrideRequireHooks = overrideRequireHooks;
|
|
18
|
-
const setRequireHooks = (
|
|
18
|
+
const setRequireHooks = (experimental) => {
|
|
19
19
|
requireHooks.set('default', new Map([
|
|
20
20
|
['react', `react`],
|
|
21
21
|
['react/jsx-runtime', `react/jsx-runtime`],
|
|
22
22
|
]));
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
23
|
+
if (experimental.appDir) {
|
|
24
|
+
if (experimental.serverActions) {
|
|
25
25
|
requireHooks.set('experimental', new Map([
|
|
26
26
|
['react', `next/dist/compiled/react-experimental`],
|
|
27
27
|
['react/jsx-runtime', `next/dist/compiled/react-experimental/jsx-runtime`],
|
package/lib/templates/server.js
CHANGED
|
@@ -32,7 +32,10 @@ const getNetlifyNextServer = (NextServer) => {
|
|
|
32
32
|
// preserve the URL before Next.js mutates it for i18n
|
|
33
33
|
const { url, headers } = req;
|
|
34
34
|
// conditionally use the prebundled React module
|
|
35
|
-
|
|
35
|
+
// PrebundledReact should only apply when appDir is set it falls between the specified Next versions
|
|
36
|
+
const { experimental } = this.nextConfig;
|
|
37
|
+
if (experimental === null || experimental === void 0 ? void 0 : experimental.appDir)
|
|
38
|
+
this.netlifyPrebundleReact(url, this.nextConfig, parsedUrl);
|
|
36
39
|
// intercept on-demand revalidation requests and handle with the Netlify API
|
|
37
40
|
if (headers['x-prerender-revalidate'] && this.netlifyConfig.revalidateToken) {
|
|
38
41
|
// handle on-demand revalidation by purging the ODB cache
|
|
@@ -0,0 +1,20 @@
|
|
|
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");
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.40.
|
|
3
|
+
"version": "4.40.3-rc.0",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"lib/**/*",
|
|
8
8
|
"src/templates/edge/*",
|
|
9
9
|
"src/templates/edge-shared/*",
|
|
10
|
+
"src/templates/vendor/*",
|
|
10
11
|
"index.js",
|
|
11
12
|
"manifest.yml"
|
|
12
13
|
],
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"@netlify/esbuild": "0.14.39",
|
|
15
16
|
"@netlify/functions": "^1.6.0",
|
|
16
|
-
"@netlify/ipx": "^1.4.
|
|
17
|
+
"@netlify/ipx": "^1.4.5",
|
|
17
18
|
"@vercel/node-bridge": "^2.1.0",
|
|
18
19
|
"chalk": "^4.1.2",
|
|
19
20
|
"chokidar": "^3.5.3",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@delucis/if-env": "^1.1.2",
|
|
40
|
-
"@netlify/build": "^29.
|
|
41
|
+
"@netlify/build": "^29.22.5",
|
|
41
42
|
"@types/fs-extra": "^9.0.13",
|
|
42
43
|
"@types/jest": "^27.4.1",
|
|
43
44
|
"@types/merge-stream": "^1.1.2",
|
|
@@ -52,7 +53,9 @@
|
|
|
52
53
|
"publish:install": "npm ci",
|
|
53
54
|
"publish:test": "cd .. && npm ci && npm test",
|
|
54
55
|
"clean": "rimraf lib dist-types",
|
|
55
|
-
"build": "
|
|
56
|
+
"build": "run-s build:*",
|
|
57
|
+
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/vendor.ts --output=src/templates/vendor && patch src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts html_rewriter.patch",
|
|
58
|
+
"build:tsc": "tsc",
|
|
56
59
|
"watch": "tsc --watch",
|
|
57
60
|
"prepare": "npm run build"
|
|
58
61
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NextRequest } from '
|
|
2
|
-
import { NextResponse } from '
|
|
3
|
-
import { fromFileUrl } from '
|
|
1
|
+
import { NextRequest } from '../vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js'
|
|
2
|
+
import { NextResponse } from '../vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js'
|
|
3
|
+
import { fromFileUrl } from '../vendor/deno.land/std@0.175.0/path/mod.ts'
|
|
4
4
|
import { buildResponse, isFunction } from '../edge-shared/utils.ts'
|
|
5
5
|
|
|
6
6
|
globalThis.NFRequestContextMap ||= new Map()
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
// deno-lint-ignore-file prefer-const no-unused-vars
|
|
3
|
-
import { decode as _base64Decode } from '
|
|
4
|
-
import BufferCompat from '
|
|
5
|
-
import EventsCompat from '
|
|
6
|
-
import AsyncHooksCompat from '
|
|
7
|
-
import AssertCompat from '
|
|
8
|
-
import UtilCompat from '
|
|
3
|
+
import { decode as _base64Decode } from '../vendor/deno.land/std@0.175.0/encoding/base64.ts'
|
|
4
|
+
import BufferCompat from '../vendor/deno.land/std@0.175.0/node/buffer.ts'
|
|
5
|
+
import EventsCompat from '../vendor/deno.land/std@0.175.0/node/events.ts'
|
|
6
|
+
import AsyncHooksCompat from '../vendor/deno.land/std@0.175.0/node/async_hooks.ts'
|
|
7
|
+
import AssertCompat from '../vendor/deno.land/std@0.175.0/node/assert.ts'
|
|
8
|
+
import UtilCompat from '../vendor/deno.land/std@0.175.0/node/util.ts'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* These are the shims, polyfills and other kludges to make Next.js work in standards-compliant runtime.
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
// Deno imports
|
|
10
|
-
import type { Key } from '
|
|
10
|
+
import type { Key } from '../vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts'
|
|
11
11
|
|
|
12
|
-
import { compile, pathToRegexp } from '
|
|
13
|
-
import { getCookies } from '
|
|
12
|
+
import { compile, pathToRegexp } from '../vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts'
|
|
13
|
+
import { getCookies } from '../vendor/deno.land/std@0.175.0/http/cookie.ts'
|
|
14
14
|
|
|
15
15
|
// Inlined/re-implemented types
|
|
16
16
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from 'https://edge.netlify.com'
|
|
2
|
-
import { ElementHandlers, HTMLRewriter } from '
|
|
2
|
+
import { ElementHandlers, HTMLRewriter } from '../vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts'
|
|
3
3
|
|
|
4
4
|
export interface FetchEventResult {
|
|
5
5
|
response: Response
|