@kasperpeulen/vitest-plugin-nextjs 0.0.0-alpha.0 → 0.1.0-alpha.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 +249 -2
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/action-ids.d.ts +18 -0
- package/dist/action-ids.js +44 -0
- package/dist/adapter.d.ts +8 -0
- package/dist/adapter.js +12 -0
- package/dist/app-requests.d.ts +63 -0
- package/dist/app-requests.js +253 -0
- package/dist/browser-context.d.ts +24 -0
- package/dist/browser-context.js +157 -0
- package/dist/build-output.d.ts +68 -0
- package/dist/build-output.js +216 -0
- package/dist/build.d.ts +26 -0
- package/dist/build.js +39 -0
- package/dist/built-files.d.ts +9 -0
- package/dist/built-files.js +22 -0
- package/dist/cache.d.ts +44 -0
- package/dist/cache.js +99 -0
- package/dist/client-components.d.ts +3 -0
- package/dist/client-components.js +4 -0
- package/dist/client-file-key.d.ts +5 -0
- package/dist/client-file-key.js +5 -0
- package/dist/client-files.d.ts +83 -0
- package/dist/client-files.js +186 -0
- package/dist/client-graph.d.ts +94 -0
- package/dist/client-graph.js +266 -0
- package/dist/client-modules.d.ts +10 -0
- package/dist/client-modules.js +43 -0
- package/dist/client.d.ts +42 -0
- package/dist/client.js +263 -0
- package/dist/commonjs.d.ts +44 -0
- package/dist/commonjs.js +111 -0
- package/dist/compat/browser/client.d.ts +19 -0
- package/dist/compat/browser/client.js +13 -0
- package/dist/compat/build.d.ts +145 -0
- package/dist/compat/build.js +149 -0
- package/dist/compat/checks.d.ts +16 -0
- package/dist/compat/checks.js +148 -0
- package/dist/compat/patches.d.ts +13 -0
- package/dist/compat/patches.js +30 -0
- package/dist/compat/paths.d.ts +74 -0
- package/dist/compat/paths.js +160 -0
- package/dist/compat/rsc/handlers.d.ts +2 -0
- package/dist/compat/rsc/handlers.js +2 -0
- package/dist/compat/rsc/prerender.d.ts +10 -0
- package/dist/compat/rsc/prerender.js +9 -0
- package/dist/compat/server/headers.d.ts +3 -0
- package/dist/compat/server/headers.js +3 -0
- package/dist/compat/ssr/build-output.d.ts +4 -0
- package/dist/compat/ssr/build-output.js +3 -0
- package/dist/compat/ssr/cache.d.ts +6 -0
- package/dist/compat/ssr/cache.js +6 -0
- package/dist/compat/ssr/handler.d.ts +8 -0
- package/dist/compat/ssr/handler.js +8 -0
- package/dist/compat/ssr/node-server.d.ts +5 -0
- package/dist/compat/ssr/node-server.js +4 -0
- package/dist/compat/ssr/render-errors.d.ts +4 -0
- package/dist/compat/ssr/render-errors.js +4 -0
- package/dist/compat/ssr/senders.d.ts +6 -0
- package/dist/compat/ssr/senders.js +6 -0
- package/dist/compat/types.d.ts +8 -0
- package/dist/compat/types.js +1 -0
- package/dist/compile.d.ts +31 -0
- package/dist/compile.js +140 -0
- package/dist/disk.d.ts +16 -0
- package/dist/disk.js +13 -0
- package/dist/document-loads.d.ts +15 -0
- package/dist/document-loads.js +53 -0
- package/dist/document.d.ts +79 -0
- package/dist/document.js +328 -0
- package/dist/downloads.d.ts +15 -0
- package/dist/downloads.js +71 -0
- package/dist/esm-require.d.ts +11 -0
- package/dist/esm-require.js +32 -0
- package/dist/fast-crypto/index.js +1093 -0
- package/dist/fast-crypto.d.ts +20 -0
- package/dist/fast-crypto.js +151 -0
- package/dist/flight.d.ts +19 -0
- package/dist/flight.js +42 -0
- package/dist/form-submission.d.ts +15 -0
- package/dist/form-submission.js +27 -0
- package/dist/from-page.d.ts +5 -0
- package/dist/from-page.js +44 -0
- package/dist/globals.d.ts +1 -0
- package/dist/globals.js +197 -0
- package/dist/host-document.d.ts +26 -0
- package/dist/host-document.js +34 -0
- package/dist/index.d.ts +280 -0
- package/dist/index.js +281 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +3 -0
- package/dist/leftovers.d.ts +11 -0
- package/dist/leftovers.js +55 -0
- package/dist/mode.d.ts +169 -0
- package/dist/mode.js +31 -0
- package/dist/node/LICENSES.md +3540 -0
- package/dist/node/assert/strict.js +29 -0
- package/dist/node/assert.js +3044 -0
- package/dist/node/buffer.js +1499 -0
- package/dist/node/child_process.js +45 -0
- package/dist/node/cluster.js +85 -0
- package/dist/node/console.js +96 -0
- package/dist/node/constants.js +495 -0
- package/dist/node/crypto.js +1388 -0
- package/dist/node/dgram.js +78 -0
- package/dist/node/diagnostics_channel.js +122 -0
- package/dist/node/dns/promises.js +129 -0
- package/dist/node/dns.js +137 -0
- package/dist/node/domain.js +43 -0
- package/dist/node/events.js +1155 -0
- package/dist/node/fs/promises.js +40 -0
- package/dist/node/fs.js +10375 -0
- package/dist/node/http.js +326 -0
- package/dist/node/http2.js +305 -0
- package/dist/node/https.js +57 -0
- package/dist/node/inspector/promises.js +66 -0
- package/dist/node/inspector.js +76 -0
- package/dist/node/module.js +205 -0
- package/dist/node/net.js +392 -0
- package/dist/node/os.js +259 -0
- package/dist/node/path/posix.js +25 -0
- package/dist/node/path/win32.js +25 -0
- package/dist/node/path.js +384 -0
- package/dist/node/perf_hooks.js +313 -0
- package/dist/node/process.js +452 -0
- package/dist/node/punycode.js +178 -0
- package/dist/node/querystring.js +934 -0
- package/dist/node/readline/promises.js +71 -0
- package/dist/node/readline.js +56 -0
- package/dist/node/repl.js +44 -0
- package/dist/node/sqlite.js +22 -0
- package/dist/node/stream/consumers.js +47 -0
- package/dist/node/stream/promises.js +6 -0
- package/dist/node/stream/web.js +52 -0
- package/dist/node/stream.js +4323 -0
- package/dist/node/string_decoder.js +276 -0
- package/dist/node/sys.js +6 -0
- package/dist/node/timers/promises.js +71 -0
- package/dist/node/timers.js +133 -0
- package/dist/node/tls.js +122 -0
- package/dist/node/trace_events.js +23 -0
- package/dist/node/tty.js +69 -0
- package/dist/node/url.js +1426 -0
- package/dist/node/util/types.js +1456 -0
- package/dist/node/util.js +4807 -0
- package/dist/node/v8.js +160 -0
- package/dist/node/vm.js +88 -0
- package/dist/node/wasi.js +16 -0
- package/dist/node/worker_threads.js +123 -0
- package/dist/node/zlib.js +1396 -0
- package/dist/node-builtins.d.ts +40 -0
- package/dist/node-builtins.js +74 -0
- package/dist/node-on-page.d.ts +46 -0
- package/dist/node-on-page.js +101 -0
- package/dist/node-platform.d.ts +36 -0
- package/dist/node-platform.js +152 -0
- package/dist/node-rendered.d.ts +21 -0
- package/dist/node-rendered.js +26 -0
- package/dist/node-server.d.ts +46 -0
- package/dist/node-server.js +193 -0
- package/dist/optimizer-cache-key.d.ts +26 -0
- package/dist/optimizer-cache-key.js +73 -0
- package/dist/own-package.d.ts +1 -0
- package/dist/own-package.js +6 -0
- package/dist/page-store.d.ts +33 -0
- package/dist/page-store.js +80 -0
- package/dist/page-timers.d.ts +22 -0
- package/dist/page-timers.js +47 -0
- package/dist/page.d.ts +112 -0
- package/dist/page.js +549 -0
- package/dist/paths.d.ts +13 -0
- package/dist/paths.js +47 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.js +995 -0
- package/dist/prerender-verdict.d.ts +8 -0
- package/dist/prerender-verdict.js +67 -0
- package/dist/project/context.d.ts +546 -0
- package/dist/project/context.js +111 -0
- package/dist/project/entries.d.ts +42 -0
- package/dist/project/entries.js +189 -0
- package/dist/project/env-worker.d.ts +1 -0
- package/dist/project/env-worker.js +9 -0
- package/dist/project/env.d.ts +36 -0
- package/dist/project/env.js +82 -0
- package/dist/project/layers.d.ts +31 -0
- package/dist/project/layers.js +150 -0
- package/dist/project/loaders.d.ts +71 -0
- package/dist/project/loaders.js +300 -0
- package/dist/project/metadata.d.ts +8 -0
- package/dist/project/metadata.js +34 -0
- package/dist/project/module-exports.d.ts +29 -0
- package/dist/project/module-exports.js +77 -0
- package/dist/project/routes.d.ts +19 -0
- package/dist/project/routes.js +92 -0
- package/dist/project/routing.d.ts +46 -0
- package/dist/project/routing.js +280 -0
- package/dist/project/transform.d.ts +8 -0
- package/dist/project/transform.js +110 -0
- package/dist/project/webpack.d.ts +46 -0
- package/dist/project/webpack.js +160 -0
- package/dist/project.d.ts +264 -0
- package/dist/project.js +58 -0
- package/dist/registry-global.d.ts +5 -0
- package/dist/registry-global.js +5 -0
- package/dist/registry.d.ts +241 -0
- package/dist/registry.js +30 -0
- package/dist/route-chunks.d.ts +13 -0
- package/dist/route-chunks.js +32 -0
- package/dist/route-lookup.d.ts +34 -0
- package/dist/route-lookup.js +207 -0
- package/dist/routes-ahead-shared.d.ts +17 -0
- package/dist/routes-ahead-shared.js +9 -0
- package/dist/routes-ahead.d.ts +10 -0
- package/dist/routes-ahead.js +54 -0
- package/dist/rsc.d.ts +19 -0
- package/dist/rsc.js +171 -0
- package/dist/server-action.d.ts +9 -0
- package/dist/server-action.js +15 -0
- package/dist/server-code.d.ts +176 -0
- package/dist/server-code.js +357 -0
- package/dist/server-in-front.d.ts +37 -0
- package/dist/server-in-front.js +90 -0
- package/dist/server-layers.d.ts +22 -0
- package/dist/server-layers.js +33 -0
- package/dist/setup-browser.d.ts +1 -0
- package/dist/setup-browser.js +8 -0
- package/dist/setup-node.d.ts +1 -0
- package/dist/setup-node.js +6 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +62 -0
- package/dist/speed-features.d.ts +13 -0
- package/dist/speed-features.js +95 -0
- package/dist/ssr.d.ts +70 -0
- package/dist/ssr.js +480 -0
- package/dist/static-build.d.ts +36 -0
- package/dist/static-build.js +92 -0
- package/dist/storage.d.ts +31 -0
- package/dist/storage.js +94 -0
- package/dist/styles-shared.d.ts +137 -0
- package/dist/styles-shared.js +124 -0
- package/dist/styles.d.ts +102 -0
- package/dist/styles.js +730 -0
- package/dist/stylesheet-versions.d.ts +17 -0
- package/dist/stylesheet-versions.js +43 -0
- package/dist/tester.html +10 -0
- package/dist/use-cache.d.ts +15 -0
- package/dist/use-cache.js +93 -0
- package/dist/vitest-version.d.ts +6 -0
- package/dist/vitest-version.js +12 -0
- package/package.json +125 -4
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
//#region src/compat/build.ts
|
|
2
|
+
/**
|
|
3
|
+
* The build code of the `next` that `projectRequire` finds. `fail` stops the
|
|
4
|
+
* run with what differs, and the version of that `next`.
|
|
5
|
+
*/
|
|
6
|
+
function loadNextBuild(projectRequire, fail) {
|
|
7
|
+
const load = (id) => {
|
|
8
|
+
let loaded;
|
|
9
|
+
const required = () => {
|
|
10
|
+
if (loaded) return loaded;
|
|
11
|
+
try {
|
|
12
|
+
return loaded = projectRequire(`${id}.js`);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return fail(`${id}.js does not load (${error.message})`, error);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return new Proxy((() => {}), {
|
|
18
|
+
get: (_, name) => {
|
|
19
|
+
const value = required()[name];
|
|
20
|
+
return value !== void 0 ? value : fail(`${id}.js has no export \`${String(name)}\``);
|
|
21
|
+
},
|
|
22
|
+
apply: (_, self, input) => Reflect.apply(required(), self, input)
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const loader = (module) => function(...input) {
|
|
26
|
+
return module.default.apply(this, input);
|
|
27
|
+
};
|
|
28
|
+
const loadConfig = load("next/dist/server/config").default;
|
|
29
|
+
const constants = load("next/constants");
|
|
30
|
+
const { COMPILER_NAMES } = constants;
|
|
31
|
+
const { APP_DIR_ALIAS, MIDDLEWARE_FILENAME, PROXY_FILENAME, WEBPACK_LAYERS, WEBPACK_RESOURCE_QUERIES } = load("next/dist/lib/constants");
|
|
32
|
+
const { findPagesDir } = load("next/dist/lib/find-pages-dir");
|
|
33
|
+
const { discoverRoutes, createPagesMapping } = load("next/dist/build/route-discovery");
|
|
34
|
+
const { normalizeCatchAllRoutes } = load("next/dist/build/normalize-catchall-routes");
|
|
35
|
+
const { normalizeAppPath, compareAppPaths, selectAppPageEntry } = load("next/dist/shared/lib/router/utils/app-paths");
|
|
36
|
+
const { isAppRouteRoute } = load("next/dist/lib/is-app-route-route");
|
|
37
|
+
const { isAppPageRoute } = load("next/dist/lib/is-app-page-route");
|
|
38
|
+
const { findMissingCanonicalInterceptionRoutes } = load("next/dist/shared/lib/router/utils/interception-routes");
|
|
39
|
+
const { MissingCanonicalInterceptionRoutesError } = load("next/dist/shared/lib/errors/missing-canonical-interception-routes-error");
|
|
40
|
+
const { IncompatibleParallelRouteSlotsError } = load("next/dist/shared/lib/errors/incompatible-parallel-route-slots-error");
|
|
41
|
+
const { UnmatchedAppPagesError } = load("next/dist/shared/lib/errors/unmatched-app-pages-error");
|
|
42
|
+
const { generateBuildId } = load("next/dist/build/generate-build-id");
|
|
43
|
+
const { getDefineEnv } = load("next/dist/build/define-env");
|
|
44
|
+
const { getNextPublicEnvironmentVariables, getNextConfigEnv } = load("next/dist/lib/static-env");
|
|
45
|
+
const { SUPPORTED_NATIVE_MODULES } = load("next/dist/build/webpack/plugins/middleware-plugin");
|
|
46
|
+
const compilerAliases = load("next/dist/build/create-compiler-aliases");
|
|
47
|
+
const { needsExperimentalReact } = load("next/dist/lib/needs-experimental-react");
|
|
48
|
+
const { loadEntrypoint } = load("next/dist/build/load-entrypoint");
|
|
49
|
+
const nextAppLoader = loader(load("next/dist/build/webpack/loaders/next-app-loader/index"));
|
|
50
|
+
const { IncrementalCache } = load("next/dist/server/lib/incremental-cache/index");
|
|
51
|
+
const swc = load("next/dist/build/swc/index");
|
|
52
|
+
const { getLoaderSWCOptions } = load("next/dist/build/swc/options");
|
|
53
|
+
const loadJsConfig = load("next/dist/build/load-jsconfig").default;
|
|
54
|
+
const { getRSCModuleInformation, getAppPageStaticInfo } = load("next/dist/build/analysis/get-page-static-info");
|
|
55
|
+
const { nextImageLoaderRegex } = load("next/dist/build/webpack-config");
|
|
56
|
+
const nextImageLoader = loader(load("next/dist/build/webpack/loaders/next-image-loader/index"));
|
|
57
|
+
const { getNextFontLoader } = load("next/dist/build/webpack/config/blocks/css/loaders/next-font");
|
|
58
|
+
const { getPostCssPlugins } = load("next/dist/build/webpack/config/blocks/css/plugins");
|
|
59
|
+
const { findConfig } = load("next/dist/lib/find-config");
|
|
60
|
+
const { getCssModuleLoader } = load("next/dist/build/webpack/config/blocks/css/loaders/modules");
|
|
61
|
+
const localByDefault = load("next/dist/compiled/postcss-modules-local-by-default/index");
|
|
62
|
+
const { getSupportedBrowsers } = load("next/dist/build/get-supported-browsers");
|
|
63
|
+
const nextFontLoader = loader(load("next/dist/build/webpack/loaders/next-font-loader/index"));
|
|
64
|
+
const nextRootParamsLoader = loader(load("next/dist/build/webpack/loaders/next-root-params-loader"));
|
|
65
|
+
const imageOptimizer = load("next/dist/server/image-optimizer");
|
|
66
|
+
const loadCustomRoutes = load("next/dist/lib/load-custom-routes").default;
|
|
67
|
+
const { generateInterceptionRoutesRewrites } = load("next/dist/lib/generate-interception-routes-rewrites");
|
|
68
|
+
const { NEXT_URL } = load("next/dist/client/components/app-router-headers");
|
|
69
|
+
const { generateRoutesManifest } = load("next/dist/build/generate-routes-manifest");
|
|
70
|
+
const { handleBuildComplete } = load("next/dist/build/adapter/build-complete");
|
|
71
|
+
const { Bundler } = load("next/dist/lib/bundler");
|
|
72
|
+
const { getFilesInDir } = load("next/dist/lib/get-files-in-dir");
|
|
73
|
+
const { PAGE_TYPES } = load("next/dist/lib/page-types");
|
|
74
|
+
const rootPageType = PAGE_TYPES.ROOT ?? fail("next/dist/lib/page-types.js has no `PAGE_TYPES.ROOT`");
|
|
75
|
+
const { getStaticInfoIncludingLayouts } = load("next/dist/build/get-static-info-including-layouts");
|
|
76
|
+
const { getEdgeServerEntry } = load("next/dist/build/entries");
|
|
77
|
+
const { getNamedMiddlewareRegex } = load("next/dist/shared/lib/router/utils/route-regex");
|
|
78
|
+
const nextMiddlewareLoader = loader(load("next/dist/build/webpack/loaders/next-middleware-loader"));
|
|
79
|
+
const { getContentType, getExtension } = load("next/dist/server/serve-static");
|
|
80
|
+
const nextMetadataImageLoader = loader(load("next/dist/build/webpack/loaders/next-metadata-image-loader"));
|
|
81
|
+
const nextMetadataRouteLoader = loader(load("next/dist/build/webpack/loaders/next-metadata-route-loader"));
|
|
82
|
+
return {
|
|
83
|
+
loadConfig,
|
|
84
|
+
PHASE_PRODUCTION_BUILD: constants.PHASE_PRODUCTION_BUILD,
|
|
85
|
+
findPagesDir,
|
|
86
|
+
generateBuildId,
|
|
87
|
+
COMPILER_NAMES,
|
|
88
|
+
APP_DIR_ALIAS,
|
|
89
|
+
MIDDLEWARE_FILENAME,
|
|
90
|
+
PROXY_FILENAME,
|
|
91
|
+
WEBPACK_LAYERS,
|
|
92
|
+
WEBPACK_RESOURCE_QUERIES,
|
|
93
|
+
discoverRoutes,
|
|
94
|
+
createPagesMapping,
|
|
95
|
+
normalizeCatchAllRoutes,
|
|
96
|
+
normalizeAppPath,
|
|
97
|
+
compareAppPaths,
|
|
98
|
+
selectAppPageEntry,
|
|
99
|
+
isAppRouteRoute,
|
|
100
|
+
isAppPageRoute,
|
|
101
|
+
findMissingCanonicalInterceptionRoutes,
|
|
102
|
+
MissingCanonicalInterceptionRoutesError,
|
|
103
|
+
IncompatibleParallelRouteSlotsError,
|
|
104
|
+
UnmatchedAppPagesError,
|
|
105
|
+
getDefineEnv,
|
|
106
|
+
getNextPublicEnvironmentVariables,
|
|
107
|
+
getNextConfigEnv,
|
|
108
|
+
SUPPORTED_NATIVE_MODULES,
|
|
109
|
+
compilerAliases,
|
|
110
|
+
needsExperimentalReact,
|
|
111
|
+
loadEntrypoint,
|
|
112
|
+
nextAppLoader,
|
|
113
|
+
IncrementalCache,
|
|
114
|
+
swc,
|
|
115
|
+
getLoaderSWCOptions,
|
|
116
|
+
loadJsConfig,
|
|
117
|
+
getRSCModuleInformation,
|
|
118
|
+
getAppPageStaticInfo,
|
|
119
|
+
nextImageLoaderRegex,
|
|
120
|
+
nextImageLoader,
|
|
121
|
+
getNextFontLoader,
|
|
122
|
+
getPostCssPlugins,
|
|
123
|
+
getSupportedBrowsers,
|
|
124
|
+
getCssModuleLoader,
|
|
125
|
+
localByDefault,
|
|
126
|
+
findConfig,
|
|
127
|
+
nextFontLoader,
|
|
128
|
+
nextRootParamsLoader,
|
|
129
|
+
imageOptimizer,
|
|
130
|
+
loadCustomRoutes,
|
|
131
|
+
generateInterceptionRoutesRewrites,
|
|
132
|
+
NEXT_URL,
|
|
133
|
+
generateRoutesManifest,
|
|
134
|
+
handleBuildComplete,
|
|
135
|
+
Bundler,
|
|
136
|
+
getFilesInDir,
|
|
137
|
+
rootPageType,
|
|
138
|
+
getStaticInfoIncludingLayouts,
|
|
139
|
+
getEdgeServerEntry,
|
|
140
|
+
getNamedMiddlewareRegex,
|
|
141
|
+
nextMiddlewareLoader,
|
|
142
|
+
getContentType,
|
|
143
|
+
getExtension,
|
|
144
|
+
nextMetadataImageLoader,
|
|
145
|
+
nextMetadataRouteLoader
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { loadNextBuild };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NewExport } from "../node-platform.js";
|
|
2
|
+
import { NextContext } from "../project/context.js";
|
|
3
|
+
|
|
4
|
+
//#region src/compat/checks.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* What the modules of this package in the browser assume about Next's runtime.
|
|
7
|
+
* Returns the files of Next's own boundaries, for the route of a node.
|
|
8
|
+
*/
|
|
9
|
+
declare function checkRuntime(context: NextContext): {
|
|
10
|
+
builtinBoundaries: {
|
|
11
|
+
[k: string]: string;
|
|
12
|
+
};
|
|
13
|
+
newExports: Record<string, NewExport[]>;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { checkRuntime };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { aliasPaths, builtinBoundary, instrumentationModule, nodePlatformModules } from "./paths.js";
|
|
2
|
+
import { createNodePlatform, instrumentationRequire } from "../node-platform.js";
|
|
3
|
+
import { declaredExports, exportNamesOf, hasExport } from "../project/module-exports.js";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
//#region src/compat/checks.ts
|
|
6
|
+
/**
|
|
7
|
+
* What the modules of this package in the browser assume about Next's runtime.
|
|
8
|
+
* Returns the files of Next's own boundaries, for the route of a node.
|
|
9
|
+
*/
|
|
10
|
+
function checkRuntime(context) {
|
|
11
|
+
const { projectRequire, fail, previewProps, next } = context;
|
|
12
|
+
const { IncrementalCache } = next;
|
|
13
|
+
const cache = new IncrementalCache({
|
|
14
|
+
fs: {},
|
|
15
|
+
serverDistDir: "/.next/server",
|
|
16
|
+
dev: false,
|
|
17
|
+
requestHeaders: {},
|
|
18
|
+
fetchCacheKeyPrefix: "prefix",
|
|
19
|
+
previewProps,
|
|
20
|
+
prerenderManifest: {
|
|
21
|
+
version: 4,
|
|
22
|
+
routes: {},
|
|
23
|
+
dynamicRoutes: {},
|
|
24
|
+
notFoundRoutes: [],
|
|
25
|
+
preview: previewProps
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (!cache.cacheHandler || cache.fetchCacheKeyPrefix !== "prefix") fail("`IncrementalCache` no longer takes `fs`, `serverDistDir` and `fetchCacheKeyPrefix`");
|
|
29
|
+
const withoutWhitespace = (code) => code.replace(/\s+/g, "");
|
|
30
|
+
const runtimeFile = (file) => {
|
|
31
|
+
const id = `next/dist/esm/${file}.js`;
|
|
32
|
+
let resolved;
|
|
33
|
+
let code;
|
|
34
|
+
try {
|
|
35
|
+
resolved = projectRequire.resolve(id);
|
|
36
|
+
code = fs.readFileSync(resolved, "utf8");
|
|
37
|
+
} catch (error) {
|
|
38
|
+
return fail(`${id} is not there`, error);
|
|
39
|
+
}
|
|
40
|
+
let compact;
|
|
41
|
+
return {
|
|
42
|
+
code,
|
|
43
|
+
export: (name) => {
|
|
44
|
+
if (!hasExport(resolved, name)) fail(`${id} has no export \`${name}\``);
|
|
45
|
+
},
|
|
46
|
+
contains: (...pieces) => {
|
|
47
|
+
for (const piece of pieces) if (!code.includes(piece)) fail(`${id} has no \`${piece}\``);
|
|
48
|
+
},
|
|
49
|
+
containsCode: (...pieces) => {
|
|
50
|
+
compact ??= withoutWhitespace(code);
|
|
51
|
+
for (const piece of pieces) if (!compact.includes(withoutWhitespace(piece))) fail(`${id} has no \`${piece}\``);
|
|
52
|
+
},
|
|
53
|
+
matches: (pattern, what) => {
|
|
54
|
+
if (!pattern.test(code)) fail(`${id} has no ${what}`);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const appIndex = runtimeFile("client/app-index");
|
|
59
|
+
appIndex.export("hydrate");
|
|
60
|
+
appIndex.contains("process.env.__NEXT_TEST_MODE", "__NEXT_HYDRATED_CB");
|
|
61
|
+
const builtinBoundaries = Object.fromEntries([
|
|
62
|
+
"global-error",
|
|
63
|
+
"not-found",
|
|
64
|
+
"forbidden",
|
|
65
|
+
"unauthorized"
|
|
66
|
+
].map((name) => {
|
|
67
|
+
const file = builtinBoundary(name);
|
|
68
|
+
try {
|
|
69
|
+
projectRequire.resolve(file);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
fail(`${file} is not there`, error);
|
|
72
|
+
}
|
|
73
|
+
return [name, file];
|
|
74
|
+
}));
|
|
75
|
+
appIndex.contains("const appElement = document", "ReactDOMClient.hydrateRoot(appElement", "ReactDOMClient.createRoot(appElement");
|
|
76
|
+
for (const name of ["onCaughtError", "onUncaughtError"]) appIndex.matches(new RegExp(`\\bconst\\s+reactRootOptions\\s*=\\s*\\{[^;]*[{,]\\s*${name}\\s*[:,}]`), `\`${name}\` in \`reactRootOptions\``);
|
|
77
|
+
appIndex.containsCode("ReactDOMClient.createRoot(appElement, reactRootOptions)", "...reactRootOptions");
|
|
78
|
+
runtimeFile("client/components/segment-cache/cache").contains("currentTree.segment === nextTree.segment");
|
|
79
|
+
runtimeFile("client/components/render-tree").contains("doesRouteStructureMatch(", "PrefetchHint.IsRootLayoutOrAbove", "isNavigatingToNewRootLayout(");
|
|
80
|
+
runtimeFile("client/asset-prefix").contains("document.currentScript", "/_next/");
|
|
81
|
+
const serverReferenceInfo = runtimeFile("shared/lib/server-reference-info");
|
|
82
|
+
for (const name of [
|
|
83
|
+
"SERVER_REFERENCE_ID_LENGTH",
|
|
84
|
+
"mightBeServerReferenceId",
|
|
85
|
+
"extractInfoFromServerReferenceId"
|
|
86
|
+
]) serverReferenceInfo.export(name);
|
|
87
|
+
runtimeFile("server/route-modules/route-module").contains("load-manifest.external", "loadManifestFromRelativePath", "evalManifestFromRelativePath");
|
|
88
|
+
runtimeFile("build/templates/app-page-runtime").contains("server/route-modules/app-page/module.compiled");
|
|
89
|
+
runtimeFile("server/app-render/get-css-inlined-link-tags").contains("filePath.replace(/\\.[^.]+$/, '')", "entryCSSFiles[filePathWithoutExt]");
|
|
90
|
+
runtimeFile("server/app-render/render-css-resource").contains("entryCssFile.inlined", "entryCssFile.content", "/_next/${encodeURIPath(entryCssFile.path)}");
|
|
91
|
+
runtimeFile("build/templates/app-page-runtime").contains("`Page changed from static to dynamic at runtime ${resolvedPathname}", "throw new NoFallbackError()");
|
|
92
|
+
runtimeFile("build/templates/app-route").contains("if (isIsr) throw err;");
|
|
93
|
+
runtimeFile("server/lib/router-utils/router-server-context").contains("Symbol.for('@next/router-server-methods')");
|
|
94
|
+
runtimeFile("server/route-modules/route-module").contains("routerServerContext.logErrorWithOriginalStack(err");
|
|
95
|
+
runtimeFile("server/route-modules/app-page/module").contains("this.matchers.get(prerenderManifest)");
|
|
96
|
+
runtimeFile("build/utils").contains("config.dynamic = dynamic;", "config.runtime = runtime;");
|
|
97
|
+
runtimeFile("build/index").containsCode("if (workerResult.prerenderedRoutes) {", "ssgPageRoutes = workerResult.prerenderedRoutes.filter((route)=>route.isPrerenderOutput !== false).map((route)=>route.pathname);", "} else if (!hasGenerateStaticParams && (appConfig.dynamic === 'error' || appConfig.dynamic === 'force-static')) {");
|
|
98
|
+
runtimeFile("server/route-modules/app-route/module").contains("if (prepared.hasNonStaticMethods) {", "handlers.POST || handlers.PUT || handlers.DELETE || handlers.PATCH || handlers.OPTIONS) {");
|
|
99
|
+
runtimeFile("server/app-render/create-component-tree").contains("const err = new DynamicServerError(`Page with \\`dynamic = \"force-dynamic\"\\` won't be rendered statically.`);");
|
|
100
|
+
runtimeFile("server/lib/implicit-tags").containsCode("const derivedTags = [`/layout`];");
|
|
101
|
+
runtimeFile("server/app-render/stream-ops").contains("process.env.__NEXT_USE_NODE_STREAMS");
|
|
102
|
+
const newExports = checkNodePlatform(context);
|
|
103
|
+
const instrumentation = runtimeFile(instrumentationModule);
|
|
104
|
+
const required = instrumentationRequire(instrumentation.code);
|
|
105
|
+
if (typeof required === "string") fail(`next/dist/esm/${instrumentationModule}.js has ${required}`);
|
|
106
|
+
return {
|
|
107
|
+
builtinBoundaries,
|
|
108
|
+
newExports
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function checkNodePlatform({ projectRequire, fail }) {
|
|
112
|
+
const nodePlatform = createNodePlatform("registry", "");
|
|
113
|
+
const appPageModule = aliasPaths.routeModule("app-page").slice(10);
|
|
114
|
+
const standIns = Object.entries({
|
|
115
|
+
...nodePlatformModules,
|
|
116
|
+
"ssr-app-page-module": [appPageModule]
|
|
117
|
+
});
|
|
118
|
+
const compiled = `next/dist/esm/${appPageModule}.compiled.js`;
|
|
119
|
+
try {
|
|
120
|
+
projectRequire.resolve(compiled);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
fail(`${compiled} is not there, which the plugin stands in for`, error);
|
|
123
|
+
}
|
|
124
|
+
const newExports = {};
|
|
125
|
+
for (const [name, modules] of standIns) {
|
|
126
|
+
const { names } = declaredExports(nodePlatform.load(name));
|
|
127
|
+
for (const nextModule of modules) {
|
|
128
|
+
const id = nextModule.startsWith("compiled/") ? `next/dist/${nextModule}` : `next/dist/esm/${nextModule}.js`;
|
|
129
|
+
let file;
|
|
130
|
+
try {
|
|
131
|
+
file = projectRequire.resolve(id);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
return fail(`${id} is not there, which the plugin stands in for`, error);
|
|
134
|
+
}
|
|
135
|
+
for (const exported of exportNamesOf(file)) {
|
|
136
|
+
if (names.has(exported)) continue;
|
|
137
|
+
names.add(exported);
|
|
138
|
+
(newExports[name] ??= []).push({
|
|
139
|
+
name: exported,
|
|
140
|
+
module: id
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return newExports;
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
export { checkRuntime };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/compat/patches.d.ts
|
|
2
|
+
type NextPatch = {
|
|
3
|
+
file: RegExp; /** What does not work without the patch. */
|
|
4
|
+
lost: string;
|
|
5
|
+
edits: [find: string, replace: string][];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The patches of Next's files, with `registry` the expression of the registry
|
|
9
|
+
* in the code they add.
|
|
10
|
+
*/
|
|
11
|
+
declare const nextPatches: (registry: string) => NextPatch[];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { NextPatch, nextPatches };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/compat/patches.ts
|
|
2
|
+
const appRender = /\/next\/dist\/esm\/server\/app-render\/app-render\.js$/;
|
|
3
|
+
/**
|
|
4
|
+
* The patches of Next's files, with `registry` the expression of the registry
|
|
5
|
+
* in the code they add.
|
|
6
|
+
*/
|
|
7
|
+
const nextPatches = (registry) => [
|
|
8
|
+
{
|
|
9
|
+
file: appRender,
|
|
10
|
+
lost: "`ssr: false` renders the HTML of the page anyway",
|
|
11
|
+
edits: [["workUnitAsyncStorage.run(requestStore, renderToWebFizzStream, appElement, fizzOptions)", `workUnitAsyncStorage.run(requestStore, renderToWebFizzStream, ${registry}?.openedByRequest?.getStore()?.ssr === false ? _jsx("html", { id: "__next_error__", children: _jsx("body", {}) }) : appElement, fizzOptions)`]]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
file: /\/next\/dist\/esm\/client\/components\/app-router-instance\.js$/,
|
|
15
|
+
lost: "`keepApp` cannot render a page in the kept app",
|
|
16
|
+
edits: [["if (globalActionQueue !== null) {", `if (globalActionQueue !== null && !${registry}?.replacingRouter) {`]]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
file: /\/next\/dist\/esm\/client\/react-client-callbacks\/report-global-error\.js$/,
|
|
20
|
+
lost: "with `keepApp`, a spy on `window.reportError` misses the errors of a page",
|
|
21
|
+
edits: [["reportError : (error)=>{", "(error)=>reportError(error) : (error)=>{"]]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
file: /\/next\/dist\/compiled\/react-dom\/cjs\/react-dom-(?:client|profiling)\.development\.js$/,
|
|
25
|
+
lost: "a page without HTML of the server warns of the `<script>` elements of the app",
|
|
26
|
+
edits: [["didWarnScriptTags ||", `didWarnScriptTags || ${registry}?.speedFeatures?.keepApp || ${registry}?.opened?.ssr === false ||`]]
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
//#endregion
|
|
30
|
+
export { nextPatches };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { NextLayer } from "../project.js";
|
|
2
|
+
|
|
3
|
+
//#region src/compat/paths.d.ts
|
|
4
|
+
/** The function a `"use cache"` function is compiled to call: see use-cache.ts. */
|
|
5
|
+
declare const cacheWrapper = "next/dist/build/webpack/loaders/next-flight-loader/cache-wrapper";
|
|
6
|
+
/**
|
|
7
|
+
* What the modules of this package import of Next in each layer, the modules
|
|
8
|
+
* of compat/rsc, compat/ssr, compat/server and compat/browser, and what the
|
|
9
|
+
* code that Vite and Vite RSC generate imports: plugin.ts pre-bundles them.
|
|
10
|
+
* Not what only `build: "production"` loads: `prerenderImports`.
|
|
11
|
+
*/
|
|
12
|
+
declare const runtimeImports: Record<NextLayer, string[]>;
|
|
13
|
+
/**
|
|
14
|
+
* What rsc/prerender.ts imports, for the build's verdict on which pathnames
|
|
15
|
+
* of a route it prerenders: in the rsc layer, and only with
|
|
16
|
+
* `build: "production"`, the one run that loads it.
|
|
17
|
+
*/
|
|
18
|
+
declare const prerenderImports: string[];
|
|
19
|
+
/** The module whose functions the shim of plugin.ts replaces, for Vite RSC's ids. */
|
|
20
|
+
declare const serverReferenceInfo = "next/dist/esm/shared/lib/server-reference-info.js";
|
|
21
|
+
/** The module of the asset prefix of Next's dev server, which plugin.ts gives none. */
|
|
22
|
+
declare const devAssetPrefix: RegExp;
|
|
23
|
+
/** Next's runtime of a page, which the entry of a page imports: see project/entries.ts. */
|
|
24
|
+
declare const appPageRuntime = "next/dist/build/templates/app-page-runtime";
|
|
25
|
+
/** Next's own boundaries, which the route of a node has at its root: see compat/checks.ts. */
|
|
26
|
+
declare const builtinBoundary: (name: string) => string;
|
|
27
|
+
/** The loader of a font of `next/font`, `google` or `local`. */
|
|
28
|
+
declare const fontLoaderPath: (name: string) => string;
|
|
29
|
+
/**
|
|
30
|
+
* React's Flight server, of the React that Next ships: the build for
|
|
31
|
+
* development and the one for production, of React and of its experimental
|
|
32
|
+
* channel. By the file.
|
|
33
|
+
*/
|
|
34
|
+
declare const vendoredFlightServer: RegExp;
|
|
35
|
+
declare const nextModulesWithStores: {
|
|
36
|
+
layer: "rsc" | "ssr";
|
|
37
|
+
module: string;
|
|
38
|
+
}[];
|
|
39
|
+
/** A module of `nextModulesWithStores`, in Next's ESM build. */
|
|
40
|
+
declare const withStoresId: (module: string) => string;
|
|
41
|
+
/** The modules of `nextModulesWithStores` by their file, of either build of Next's server. */
|
|
42
|
+
declare const withStoresFiles: (modules: string[]) => RegExp;
|
|
43
|
+
/**
|
|
44
|
+
* The modules of Next's Node.js server that node-platform.ts stands in for,
|
|
45
|
+
* by the name of the stand-in: each by its path in `next/dist`, without
|
|
46
|
+
* `esm/` and `.js`. compat/checks.ts checks that each is a file of the
|
|
47
|
+
* installed Next; an export its stand-in has not gets a stub.
|
|
48
|
+
*/
|
|
49
|
+
declare const nodePlatformModules: Record<string, string[]>;
|
|
50
|
+
/**
|
|
51
|
+
* The module of `nodePlatformModules` a specifier is of: of either build of
|
|
52
|
+
* Next, with or without `.js`, or `/index.js` for a directory.
|
|
53
|
+
*/
|
|
54
|
+
declare function nodePlatformModuleOf(specifier: string): string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The module of Next's server that loads the app's `instrumentation.ts`, by
|
|
57
|
+
* its path in `next/dist`: see node-platform.ts.
|
|
58
|
+
*/
|
|
59
|
+
declare const instrumentationModule = "server/lib/router-utils/instrumentation-globals.external";
|
|
60
|
+
/**
|
|
61
|
+
* What project/layers.ts adds to the alias tables of Next, as Next's build
|
|
62
|
+
* for Node.js and its module rules have it.
|
|
63
|
+
*/
|
|
64
|
+
declare const aliasPaths: {
|
|
65
|
+
openTelemetry: string; /** Next's polyfill of a module of Node.js. */
|
|
66
|
+
polyfill: (name: string) => string; /** The route module of a kind, which Next's bundle for Node.js has as `module.compiled`. */
|
|
67
|
+
routeModule: (kind: string) => string; /** Next's own module for `react-dom/server`, of React's channel. */
|
|
68
|
+
reactDomServer: (channel: string) => string; /** React's server renderer for web streams, of its channel and its build. */
|
|
69
|
+
reactDomServerEdge: (channel: string, build: string) => string; /** The contexts of Next's `*.shared-runtime` modules, of the bundle of its server. */
|
|
70
|
+
vendoredContexts: string;
|
|
71
|
+
sharedRuntime: (name: string) => string;
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { aliasPaths, appPageRuntime, builtinBoundary, cacheWrapper, devAssetPrefix, fontLoaderPath, instrumentationModule, nextModulesWithStores, nodePlatformModuleOf, nodePlatformModules, prerenderImports, runtimeImports, serverReferenceInfo, vendoredFlightServer, withStoresFiles, withStoresId };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//#region src/compat/paths.ts
|
|
2
|
+
/** The function a `"use cache"` function is compiled to call: see use-cache.ts. */
|
|
3
|
+
const cacheWrapper = "next/dist/build/webpack/loaders/next-flight-loader/cache-wrapper";
|
|
4
|
+
/**
|
|
5
|
+
* What the modules of this package import of Next in each layer, the modules
|
|
6
|
+
* of compat/rsc, compat/ssr, compat/server and compat/browser, and what the
|
|
7
|
+
* code that Vite and Vite RSC generate imports: plugin.ts pre-bundles them.
|
|
8
|
+
* Not what only `build: "production"` loads: `prerenderImports`.
|
|
9
|
+
*/
|
|
10
|
+
const runtimeImports = {
|
|
11
|
+
rsc: [
|
|
12
|
+
"next/dist/server/route-kind",
|
|
13
|
+
cacheWrapper,
|
|
14
|
+
"next/dist/server/lib/server-ipc/utils",
|
|
15
|
+
"next/dist/server/web/utils",
|
|
16
|
+
"next/dist/shared/lib/no-fallback-error.external"
|
|
17
|
+
],
|
|
18
|
+
ssr: [
|
|
19
|
+
"next/dist/server/route-modules/app-page/module",
|
|
20
|
+
"next/dist/server/lib/incremental-cache",
|
|
21
|
+
"next/dist/server/lib/incremental-cache/tags-manifest.external",
|
|
22
|
+
"next/dist/server/lib/node-fs-methods",
|
|
23
|
+
"next/dist/server/use-cache/handlers",
|
|
24
|
+
"next/dist/lib/constants",
|
|
25
|
+
"next/dist/shared/lib/page-path/normalize-page-path",
|
|
26
|
+
"next/dist/client/components/app-router-headers",
|
|
27
|
+
"next/dist/server/lib/server-action-request-meta",
|
|
28
|
+
"next/dist/server/lib/is-rsc-request",
|
|
29
|
+
"next/dist/shared/lib/router/utils/route-matcher",
|
|
30
|
+
"next/dist/shared/lib/router/utils/route-regex",
|
|
31
|
+
"next/dist/server/lib/server-ipc/utils",
|
|
32
|
+
"next/dist/server/lib/mock-request",
|
|
33
|
+
"next/dist/client/components/hooks-server-context",
|
|
34
|
+
"next/dist/server/web/utils",
|
|
35
|
+
"next/dist/client/components/http-access-fallback/http-access-fallback",
|
|
36
|
+
"next/dist/client/components/redirect",
|
|
37
|
+
"next/dist/client/components/redirect-error"
|
|
38
|
+
],
|
|
39
|
+
browser: [
|
|
40
|
+
"next/dist/client/app-bootstrap",
|
|
41
|
+
"next/dist/client/app-call-server",
|
|
42
|
+
"next/dist/client/app-index",
|
|
43
|
+
"next/dist/client/components/app-router",
|
|
44
|
+
"next/dist/client/components/app-router-instance",
|
|
45
|
+
"next/dist/client/components/router-reducer/create-initial-router-state",
|
|
46
|
+
"next/dist/client/components/segment-cache/bfcache",
|
|
47
|
+
"next/dist/client/components/segment-cache/cache",
|
|
48
|
+
"next/dist/shared/lib/head-manager-context.shared-runtime"
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* What rsc/prerender.ts imports, for the build's verdict on which pathnames
|
|
53
|
+
* of a route it prerenders: in the rsc layer, and only with
|
|
54
|
+
* `build: "production"`, the one run that loads it.
|
|
55
|
+
*/
|
|
56
|
+
const prerenderImports = [
|
|
57
|
+
"next/dist/build/segment-config/app/app-segments",
|
|
58
|
+
"next/dist/build/segment-config/app/collect-root-param-keys",
|
|
59
|
+
"next/dist/build/static-paths/app",
|
|
60
|
+
"next/dist/lib/fallback",
|
|
61
|
+
"next/dist/lib/is-edge-runtime",
|
|
62
|
+
"next/dist/lib/metadata/is-metadata-route",
|
|
63
|
+
"next/dist/server/route-modules/app-route/helpers/is-static-gen-enabled",
|
|
64
|
+
"next/dist/shared/lib/router/routes/app"
|
|
65
|
+
];
|
|
66
|
+
/** The module whose functions the shim of plugin.ts replaces, for Vite RSC's ids. */
|
|
67
|
+
const serverReferenceInfo = "next/dist/esm/shared/lib/server-reference-info.js";
|
|
68
|
+
/** The module of the asset prefix of Next's dev server, which plugin.ts gives none. */
|
|
69
|
+
const devAssetPrefix = /^next\/dist\/(esm\/)?client\/dev\/hot-reloader\/app\/asset-prefix(\.js)?$/;
|
|
70
|
+
/** Next's runtime of a page, which the entry of a page imports: see project/entries.ts. */
|
|
71
|
+
const appPageRuntime = "next/dist/build/templates/app-page-runtime";
|
|
72
|
+
/** Next's own boundaries, which the route of a node has at its root: see compat/checks.ts. */
|
|
73
|
+
const builtinBoundary = (name) => `next/dist/client/components/builtin/${name}.js`;
|
|
74
|
+
/** The loader of a font of `next/font`, `google` or `local`. */
|
|
75
|
+
const fontLoaderPath = (name) => `next/dist/compiled/@next/font/${name}/loader`;
|
|
76
|
+
/**
|
|
77
|
+
* React's Flight server, of the React that Next ships: the build for
|
|
78
|
+
* development and the one for production, of React and of its experimental
|
|
79
|
+
* channel. By the file.
|
|
80
|
+
*/
|
|
81
|
+
const vendoredFlightServer = /\/next\/dist\/compiled\/react-server-dom-webpack(?:-experimental)?\/cjs\/react-server-dom-webpack-server\.edge\.\w+\.js$/;
|
|
82
|
+
const nextModulesWithStores = [
|
|
83
|
+
{
|
|
84
|
+
layer: "rsc",
|
|
85
|
+
module: "use-cache/use-cache-wrapper.js"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
layer: "ssr",
|
|
89
|
+
module: "app-render/action-handler.js"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
layer: "ssr",
|
|
93
|
+
module: "app-render/app-render.js"
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
/** A module of `nextModulesWithStores`, in Next's ESM build. */
|
|
97
|
+
const withStoresId = (module) => `next/dist/esm/server/${module}`;
|
|
98
|
+
/** The modules of `nextModulesWithStores` by their file, of either build of Next's server. */
|
|
99
|
+
const withStoresFiles = (modules) => new RegExp(`/next/dist/(?:esm/)?server/(?:${modules.map((module) => module.replaceAll(".", "\\.")).join("|")})$`);
|
|
100
|
+
/**
|
|
101
|
+
* The modules of Next's Node.js server that node-platform.ts stands in for,
|
|
102
|
+
* by the name of the stand-in: each by its path in `next/dist`, without
|
|
103
|
+
* `esm/` and `.js`. compat/checks.ts checks that each is a file of the
|
|
104
|
+
* installed Next; an export its stand-in has not gets a stub.
|
|
105
|
+
*/
|
|
106
|
+
const nodePlatformModules = {
|
|
107
|
+
"react-server-node": ["server/app-render/react-server.node"],
|
|
108
|
+
"load-manifest": ["server/load-manifest.external"],
|
|
109
|
+
"node-environment": [
|
|
110
|
+
"server/node-environment",
|
|
111
|
+
...[
|
|
112
|
+
"error-inspect",
|
|
113
|
+
"console-file",
|
|
114
|
+
"console-exit",
|
|
115
|
+
"console-dim.external",
|
|
116
|
+
"unhandled-rejection.external",
|
|
117
|
+
"random",
|
|
118
|
+
"date",
|
|
119
|
+
"web-crypto",
|
|
120
|
+
"node-crypto",
|
|
121
|
+
"process-error-handlers"
|
|
122
|
+
].map((name) => `server/node-environment-extensions/${name}`),
|
|
123
|
+
"build/adapter/setup-node-env.external"
|
|
124
|
+
],
|
|
125
|
+
"fast-set-immediate": ["server/node-environment-extensions/fast-set-immediate.external"],
|
|
126
|
+
"gzip-size": ["compiled/gzip-size"],
|
|
127
|
+
"vendored-react": ["server/route-modules/app-page/vendored/rsc/entrypoints", "server/route-modules/app-page/vendored/ssr/entrypoints"]
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The module of `nodePlatformModules` a specifier is of: of either build of
|
|
131
|
+
* Next, with or without `.js`, or `/index.js` for a directory.
|
|
132
|
+
*/
|
|
133
|
+
function nodePlatformModuleOf(specifier) {
|
|
134
|
+
return /^next\/dist\/(?:esm\/)?(.+?)(?:\/index)?(?:\.js)?$/.exec(specifier)?.[1];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The module of Next's server that loads the app's `instrumentation.ts`, by
|
|
138
|
+
* its path in `next/dist`: see node-platform.ts.
|
|
139
|
+
*/
|
|
140
|
+
const instrumentationModule = "server/lib/router-utils/instrumentation-globals.external";
|
|
141
|
+
/**
|
|
142
|
+
* What project/layers.ts adds to the alias tables of Next, as Next's build
|
|
143
|
+
* for Node.js and its module rules have it.
|
|
144
|
+
*/
|
|
145
|
+
const aliasPaths = {
|
|
146
|
+
openTelemetry: "next/dist/compiled/@opentelemetry/api",
|
|
147
|
+
/** Next's polyfill of a module of Node.js. */
|
|
148
|
+
polyfill: (name) => `next/dist/compiled/${name}`,
|
|
149
|
+
/** The route module of a kind, which Next's bundle for Node.js has as `module.compiled`. */
|
|
150
|
+
routeModule: (kind) => `next/dist/server/route-modules/${kind}/module`,
|
|
151
|
+
/** Next's own module for `react-dom/server`, of React's channel. */
|
|
152
|
+
reactDomServer: (channel) => `next/dist/build/webpack/alias/react-dom-server${channel}.js`,
|
|
153
|
+
/** React's server renderer for web streams, of its channel and its build. */
|
|
154
|
+
reactDomServerEdge: (channel, build) => `next/dist/compiled/react-dom${channel}/cjs/react-dom-server.edge.${build}.js`,
|
|
155
|
+
/** The contexts of Next's `*.shared-runtime` modules, of the bundle of its server. */
|
|
156
|
+
vendoredContexts: "next/dist/server/route-modules/app-page/vendored/contexts",
|
|
157
|
+
sharedRuntime: (name) => `next/dist/shared/lib/${name}.shared-runtime`
|
|
158
|
+
};
|
|
159
|
+
//#endregion
|
|
160
|
+
export { aliasPaths, appPageRuntime, builtinBoundary, cacheWrapper, devAssetPrefix, fontLoaderPath, instrumentationModule, nextModulesWithStores, nodePlatformModuleOf, nodePlatformModules, prerenderImports, runtimeImports, serverReferenceInfo, vendoredFlightServer, withStoresFiles, withStoresId };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { collectSegments } from "next/dist/build/segment-config/app/app-segments.js";
|
|
2
|
+
import { collectRootParamKeys } from "next/dist/build/segment-config/app/collect-root-param-keys.js";
|
|
3
|
+
import { buildAppStaticPaths } from "next/dist/build/static-paths/app.js";
|
|
4
|
+
import { FallbackMode, fallbackModeToFallbackField } from "next/dist/lib/fallback.js";
|
|
5
|
+
import { isEdgeRuntime } from "next/dist/lib/is-edge-runtime.js";
|
|
6
|
+
import { isMetadataRoute, isStaticMetadataFile } from "next/dist/lib/metadata/is-metadata-route.js";
|
|
7
|
+
import { isStaticGenEnabled } from "next/dist/server/route-modules/app-route/helpers/is-static-gen-enabled.js";
|
|
8
|
+
import { parseNormalizedAppRoute } from "next/dist/shared/lib/router/routes/app.js";
|
|
9
|
+
import { AppRouteRouteModule } from "next/dist/server/route-modules/app-route/module.js";
|
|
10
|
+
export { type AppRouteRouteModule, type FallbackMode, buildAppStaticPaths, collectRootParamKeys, collectSegments, fallbackModeToFallbackField, isEdgeRuntime, isMetadataRoute, isStaticGenEnabled, isStaticMetadataFile, parseNormalizedAppRoute };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { collectSegments } from "next/dist/build/segment-config/app/app-segments.js";
|
|
2
|
+
import { collectRootParamKeys } from "next/dist/build/segment-config/app/collect-root-param-keys.js";
|
|
3
|
+
import { buildAppStaticPaths } from "next/dist/build/static-paths/app.js";
|
|
4
|
+
import { fallbackModeToFallbackField } from "next/dist/lib/fallback.js";
|
|
5
|
+
import { isEdgeRuntime } from "next/dist/lib/is-edge-runtime.js";
|
|
6
|
+
import { isMetadataRoute, isStaticMetadataFile } from "next/dist/lib/metadata/is-metadata-route.js";
|
|
7
|
+
import { isStaticGenEnabled } from "next/dist/server/route-modules/app-route/helpers/is-static-gen-enabled.js";
|
|
8
|
+
import { parseNormalizedAppRoute } from "next/dist/shared/lib/router/routes/app.js";
|
|
9
|
+
export { buildAppStaticPaths, collectRootParamKeys, collectSegments, fallbackModeToFallbackField, isEdgeRuntime, isMetadataRoute, isStaticGenEnabled, isStaticMetadataFile, parseNormalizedAppRoute };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { filterInternalHeaders } from "next/dist/server/lib/server-ipc/utils.js";
|
|
2
|
+
import { fromNodeOutgoingHttpHeaders, splitCookiesString, toNodeOutgoingHttpHeaders } from "next/dist/server/web/utils.js";
|
|
3
|
+
export { filterInternalHeaders, fromNodeOutgoingHttpHeaders, splitCookiesString, toNodeOutgoingHttpHeaders };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { filterInternalHeaders } from "next/dist/server/lib/server-ipc/utils.js";
|
|
2
|
+
import { fromNodeOutgoingHttpHeaders, splitCookiesString, toNodeOutgoingHttpHeaders } from "next/dist/server/web/utils.js";
|
|
3
|
+
export { filterInternalHeaders, fromNodeOutgoingHttpHeaders, splitCookiesString, toNodeOutgoingHttpHeaders };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RSC_SUFFIX } from "next/dist/lib/constants.js";
|
|
2
|
+
import { normalizePagePath } from "next/dist/shared/lib/page-path/normalize-page-path.js";
|
|
3
|
+
import { PrerenderManifest } from "next/dist/build/index.js";
|
|
4
|
+
export { type PrerenderManifest, RSC_SUFFIX, normalizePagePath };
|