@qzsy/vinext 0.1.12 → 0.1.81
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 +19 -5
- package/dist/build/inject-pregenerated-paths.d.ts +4 -0
- package/dist/build/inject-pregenerated-paths.js +18 -0
- package/dist/build/pages-client-assets-module.d.ts +11 -0
- package/dist/build/pages-client-assets-module.js +27 -0
- package/dist/build/prerender.d.ts +2 -1
- package/dist/build/prerender.js +11 -4
- package/dist/build/report.d.ts +2 -1
- package/dist/build/report.js +2 -1
- package/dist/build/run-prerender.d.ts +7 -0
- package/dist/build/run-prerender.js +9 -0
- package/dist/build/standalone.js +2 -0
- package/dist/check.d.ts +18 -0
- package/dist/check.js +77 -19
- package/dist/cli-dev-config.d.ts +12 -0
- package/dist/cli-dev-config.js +23 -0
- package/dist/cli.js +64 -28
- package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay-store.js +1 -1
- package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay.js +2 -2
- package/dist/cloudflare/deploy-config.d.ts +51 -0
- package/dist/cloudflare/deploy-config.js +153 -0
- package/dist/cloudflare/index.d.ts +1 -1
- package/dist/cloudflare/index.js +1 -1
- package/dist/cloudflare/project.d.ts +41 -0
- package/dist/cloudflare/project.js +243 -0
- package/dist/cloudflare/tpr.js +1 -1
- package/dist/config/config-matchers.js +14 -10
- package/dist/config/next-config.d.ts +6 -3
- package/dist/config/next-config.js +47 -1
- package/dist/config/server-external-packages.d.ts +4 -0
- package/dist/config/server-external-packages.js +91 -0
- package/dist/deploy.d.ts +2 -122
- package/dist/deploy.js +20 -793
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +70 -12
- package/dist/entries/app-rsc-manifest.js +8 -0
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +2 -1
- package/dist/entries/pages-server-entry.js +6 -2
- package/dist/image/image-adapters-virtual.d.ts +59 -0
- package/dist/image/image-adapters-virtual.js +50 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +160 -160
- package/dist/init-cloudflare.d.ts +43 -0
- package/dist/init-cloudflare.js +1000 -0
- package/dist/init-platform.d.ts +38 -0
- package/dist/init-platform.js +150 -0
- package/dist/init.d.ts +14 -37
- package/dist/init.js +205 -95
- package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
- package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
- package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
- package/dist/plugins/ast-scope.d.ts +16 -0
- package/dist/plugins/ast-scope.js +62 -0
- package/dist/plugins/ast-utils.js +3 -0
- package/dist/plugins/css-module-imports.d.ts +14 -0
- package/dist/plugins/css-module-imports.js +59 -0
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/middleware-server-only.d.ts +8 -6
- package/dist/plugins/middleware-server-only.js +8 -7
- package/dist/plugins/optimize-imports.js +1 -1
- package/dist/plugins/typeof-window.d.ts +1 -1
- package/dist/plugins/typeof-window.js +28 -56
- package/dist/routing/app-route-graph.d.ts +13 -2
- package/dist/routing/app-route-graph.js +116 -32
- package/dist/routing/app-router.d.ts +5 -0
- package/dist/routing/app-router.js +5 -0
- package/dist/routing/file-matcher.d.ts +8 -0
- package/dist/routing/file-matcher.js +10 -1
- package/dist/routing/pages-router.js +2 -2
- package/dist/server/app-browser-action-result.d.ts +2 -1
- package/dist/server/app-browser-action-result.js +5 -1
- package/dist/server/app-browser-entry.js +17 -12
- package/dist/server/app-browser-history-controller.d.ts +2 -1
- package/dist/server/app-browser-history-controller.js +6 -2
- package/dist/server/app-browser-interception-context.d.ts +1 -0
- package/dist/server/app-browser-interception-context.js +4 -2
- package/dist/server/app-browser-navigation-controller.js +1 -0
- package/dist/server/app-browser-server-action-client.js +2 -3
- package/dist/server/app-browser-state.d.ts +1 -0
- package/dist/server/app-browser-state.js +3 -2
- package/dist/server/app-fallback-renderer.d.ts +3 -2
- package/dist/server/app-fallback-renderer.js +12 -7
- package/dist/server/app-middleware.d.ts +2 -3
- package/dist/server/app-middleware.js +3 -2
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +12 -3
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +10 -3
- package/dist/server/app-page-cache-render.d.ts +1 -0
- package/dist/server/app-page-cache-render.js +8 -4
- package/dist/server/app-page-cache.d.ts +1 -0
- package/dist/server/app-page-cache.js +4 -1
- package/dist/server/app-page-dispatch.d.ts +11 -3
- package/dist/server/app-page-dispatch.js +55 -15
- package/dist/server/app-page-element-builder.d.ts +5 -1
- package/dist/server/app-page-element-builder.js +57 -20
- package/dist/server/app-page-head.d.ts +12 -0
- package/dist/server/app-page-head.js +42 -19
- package/dist/server/app-page-params.d.ts +2 -1
- package/dist/server/app-page-params.js +8 -1
- package/dist/server/app-page-probe.d.ts +1 -0
- package/dist/server/app-page-probe.js +6 -1
- package/dist/server/app-page-render-identity.d.ts +1 -0
- package/dist/server/app-page-render-identity.js +1 -1
- package/dist/server/app-page-render.d.ts +4 -1
- package/dist/server/app-page-render.js +8 -3
- package/dist/server/app-page-request.d.ts +22 -1
- package/dist/server/app-page-request.js +89 -13
- package/dist/server/app-page-route-wiring.d.ts +6 -1
- package/dist/server/app-page-route-wiring.js +31 -15
- package/dist/server/app-page-search-params-observation.d.ts +4 -2
- package/dist/server/app-page-search-params-observation.js +11 -7
- package/dist/server/app-page-segment-state.js +2 -0
- package/dist/server/app-route-handler-dispatch.js +1 -0
- package/dist/server/app-route-handler-execution.js +7 -2
- package/dist/server/app-route-handler-response.js +1 -0
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-route-module-loader.d.ts +2 -0
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-router-entry.d.ts +12 -0
- package/dist/server/app-router-entry.js +22 -8
- package/dist/server/app-router-image-optimization.d.ts +37 -0
- package/dist/server/app-router-image-optimization.js +40 -0
- package/dist/server/app-rsc-errors.js +7 -1
- package/dist/server/app-rsc-handler.js +27 -14
- package/dist/server/app-rsc-route-matching.d.ts +7 -0
- package/dist/server/app-rsc-route-matching.js +36 -3
- package/dist/server/app-segment-config.d.ts +12 -0
- package/dist/server/app-segment-config.js +91 -5
- package/dist/server/app-server-action-execution.d.ts +5 -0
- package/dist/server/app-server-action-execution.js +106 -33
- package/dist/server/app-ssr-entry.js +12 -1
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +1 -0
- package/dist/server/client-trace-metadata.js +26 -0
- package/dist/server/default-global-not-found-module.d.ts +14 -0
- package/dist/server/default-global-not-found-module.js +14 -0
- package/dist/server/dev-response-headers.d.ts +19 -0
- package/dist/server/dev-response-headers.js +78 -0
- package/dist/server/dev-server.js +8 -15
- package/dist/server/dev-stack-sourcemap.d.ts +1 -1
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/headers.d.ts +7 -15
- package/dist/server/headers.js +6 -15
- package/dist/server/image-optimization.d.ts +51 -1
- package/dist/server/image-optimization.js +52 -2
- package/dist/server/isr-cache.d.ts +1 -1
- package/dist/server/isr-cache.js +2 -2
- package/dist/server/middleware-runtime.js +6 -1
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +14 -3
- package/dist/server/pages-asset-tags.d.ts +4 -6
- package/dist/server/pages-asset-tags.js +12 -12
- package/dist/server/pages-client-assets.d.ts +12 -0
- package/dist/server/pages-client-assets.js +10 -0
- package/dist/server/pages-page-data.d.ts +23 -1
- package/dist/server/pages-page-data.js +43 -24
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +10 -4
- package/dist/server/pages-request-pipeline.d.ts +2 -0
- package/dist/server/pages-request-pipeline.js +25 -1
- package/dist/server/prerender-manifest.d.ts +3 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.js +47 -25
- package/dist/server/request-log.d.ts +5 -14
- package/dist/server/request-log.js +7 -1
- package/dist/server/request-pipeline.js +1 -0
- package/dist/server/seed-cache.js +4 -4
- package/dist/server/server-action-logger.d.ts +39 -0
- package/dist/server/server-action-logger.js +104 -0
- package/dist/server/worker-utils.d.ts +2 -1
- package/dist/server/worker-utils.js +7 -1
- package/dist/shims/app-router-scroll-state.d.ts +1 -0
- package/dist/shims/app-router-scroll-state.js +1 -0
- package/dist/shims/app-router-scroll.js +2 -1
- package/dist/shims/cache.js +19 -15
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +2 -1
- package/dist/shims/error-boundary.d.ts +19 -1
- package/dist/shims/error-boundary.js +11 -1
- package/dist/shims/form.d.ts +3 -1
- package/dist/shims/form.js +37 -43
- package/dist/shims/headers.d.ts +9 -1
- package/dist/shims/headers.js +31 -6
- package/dist/shims/image-optimization-url.d.ts +4 -0
- package/dist/shims/image-optimization-url.js +33 -1
- package/dist/shims/image.js +46 -13
- package/dist/shims/internal/app-route-detection.d.ts +2 -17
- package/dist/shims/internal/app-route-detection.js +4 -17
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -5
- package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
- package/dist/shims/internal/pages-router-components.d.ts +7 -0
- package/dist/shims/internal/pages-router-components.js +13 -0
- package/dist/shims/link.js +23 -16
- package/dist/shims/metadata.d.ts +3 -2
- package/dist/shims/metadata.js +8 -4
- package/dist/shims/navigation.js +4 -2
- package/dist/shims/root-params.d.ts +15 -1
- package/dist/shims/root-params.js +21 -1
- package/dist/shims/router.d.ts +2 -5
- package/dist/shims/router.js +41 -22
- package/dist/shims/server.js +3 -2
- package/dist/typegen.js +6 -5
- package/dist/utils/client-runtime-metadata.d.ts +2 -18
- package/dist/utils/client-runtime-metadata.js +31 -22
- package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
- package/dist/utils/domain-locale.d.ts +6 -3
- package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
- package/dist/{server → utils}/middleware-request-headers.js +2 -2
- package/dist/utils/path.d.ts +2 -1
- package/dist/utils/path.js +1 -1
- package/dist/utils/project.d.ts +9 -1
- package/dist/utils/project.js +21 -4
- package/dist/utils/protocol-headers.d.ts +17 -0
- package/dist/utils/protocol-headers.js +17 -0
- package/dist/utils/react-version.d.ts +4 -0
- package/dist/utils/react-version.js +44 -0
- package/package.json +29 -23
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
- /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { findInNodeModules, findViteConfigPath } from "../utils/project.js";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
//#region src/cloudflare/project.ts
|
|
6
|
+
/** Check whether a wrangler config file exists in the given directory. */
|
|
7
|
+
function hasWranglerConfig(root) {
|
|
8
|
+
return fs.existsSync(path.join(root, "wrangler.jsonc")) || fs.existsSync(path.join(root, "wrangler.json")) || fs.existsSync(path.join(root, "wrangler.toml")) || fs.existsSync(path.join(root, "cloudflare.config.ts"));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Detect the project structure (router, config, worker entry, package name).
|
|
12
|
+
*
|
|
13
|
+
* `root` is an OS-native filesystem path.
|
|
14
|
+
*/
|
|
15
|
+
function detectProject(root) {
|
|
16
|
+
const hasApp = resolveProjectDir(root, "app") !== null;
|
|
17
|
+
const hasPages = resolveProjectDir(root, "pages") !== null;
|
|
18
|
+
const isAppRouter = hasApp;
|
|
19
|
+
const isPagesRouter = !hasApp && hasPages;
|
|
20
|
+
const hasViteConfig = findViteConfigPath(root) !== void 0;
|
|
21
|
+
const wranglerConfigExists = hasWranglerConfig(root);
|
|
22
|
+
const hasWorkerEntry = fs.existsSync(path.join(root, "worker", "index.ts")) || fs.existsSync(path.join(root, "worker", "index.js"));
|
|
23
|
+
const hasCloudflarePlugin = findInNodeModules(root, "@cloudflare/vite-plugin") !== null;
|
|
24
|
+
const hasRscPlugin = findInNodeModules(root, "@vitejs/plugin-rsc") !== null;
|
|
25
|
+
const hasWrangler = findInNodeModules(root, ".bin/wrangler") !== null || findInNodeModules(root, ".bin/cf") !== null;
|
|
26
|
+
const pkgPath = path.join(root, "package.json");
|
|
27
|
+
let pkg = null;
|
|
28
|
+
if (fs.existsSync(pkgPath)) try {
|
|
29
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
30
|
+
} catch {}
|
|
31
|
+
let projectName = path.basename(root);
|
|
32
|
+
if (pkg?.name && typeof pkg.name === "string") projectName = pkg.name.replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
33
|
+
const hasTypeModule = pkg?.type === "module";
|
|
34
|
+
let hasISR = false;
|
|
35
|
+
let hasMDX = detectMDXFromConfig(root);
|
|
36
|
+
if (isAppRouter) {
|
|
37
|
+
const appDir = resolveProjectDir(root, "app");
|
|
38
|
+
if (appDir) {
|
|
39
|
+
const found = scanTreeForDetection(appDir, {
|
|
40
|
+
isr: true,
|
|
41
|
+
mdx: !hasMDX
|
|
42
|
+
});
|
|
43
|
+
hasISR = found.isr;
|
|
44
|
+
hasMDX = hasMDX || found.mdx;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (hasPages) {
|
|
48
|
+
const pagesDir = resolveProjectDir(root, "pages");
|
|
49
|
+
if (pagesDir) {
|
|
50
|
+
const found = scanTreeForDetection(pagesDir, {
|
|
51
|
+
isr: !hasISR,
|
|
52
|
+
mdx: !hasMDX
|
|
53
|
+
});
|
|
54
|
+
hasISR = hasISR || found.isr;
|
|
55
|
+
hasMDX = hasMDX || found.mdx;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
hasISR = hasISR || detectCacheComponents(root);
|
|
59
|
+
const allDeps = {
|
|
60
|
+
...pkg?.dependencies,
|
|
61
|
+
...pkg?.devDependencies
|
|
62
|
+
};
|
|
63
|
+
const hasCodeHike = "codehike" in allDeps;
|
|
64
|
+
const nativeModulesToStub = detectNativeModules(allDeps);
|
|
65
|
+
return {
|
|
66
|
+
root,
|
|
67
|
+
isAppRouter,
|
|
68
|
+
isPagesRouter,
|
|
69
|
+
hasViteConfig,
|
|
70
|
+
hasWranglerConfig: wranglerConfigExists,
|
|
71
|
+
hasWorkerEntry,
|
|
72
|
+
hasCloudflarePlugin,
|
|
73
|
+
hasRscPlugin,
|
|
74
|
+
hasWrangler,
|
|
75
|
+
projectName,
|
|
76
|
+
hasISR,
|
|
77
|
+
hasTypeModule,
|
|
78
|
+
hasMDX,
|
|
79
|
+
hasCodeHike,
|
|
80
|
+
nativeModulesToStub
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Matches App Router revalidation or Pages Router static generation exports. */
|
|
84
|
+
const ISR_PATTERN = /export\s+(?:const\s+revalidate\s*=|(?:async\s+)?function\s+getStaticProps\b|const\s+getStaticProps\s*=|\{[^}]*\bgetStaticProps\b[^}]*\})/;
|
|
85
|
+
/** Source extensions whose contents are scanned for the ISR pattern. */
|
|
86
|
+
const ISR_SCANNABLE_EXTENSION = /\.(ts|tsx|js|jsx)$/;
|
|
87
|
+
/**
|
|
88
|
+
* Resolve a project subdirectory (`app`/`pages`), preferring the root-level
|
|
89
|
+
* location and falling back to the `src/` variant. Returns null when neither
|
|
90
|
+
* exists.
|
|
91
|
+
*/
|
|
92
|
+
function resolveProjectDir(root, name) {
|
|
93
|
+
const rootDir = path.join(root, name);
|
|
94
|
+
try {
|
|
95
|
+
if (fs.statSync(rootDir).isDirectory()) return rootDir;
|
|
96
|
+
} catch {}
|
|
97
|
+
const srcDir = path.join(root, "src", name);
|
|
98
|
+
try {
|
|
99
|
+
if (fs.statSync(srcDir).isDirectory()) return srcDir;
|
|
100
|
+
} catch {}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Recursively walk `dir` once, evaluating the requested detection predicates
|
|
105
|
+
* per entry. Each flag short-circuits independently: an `.mdx` file sets `mdx`;
|
|
106
|
+
* a scannable source file containing `export const revalidate` sets `isr`. The
|
|
107
|
+
* walk stops as soon as every requested flag is satisfied, so callers that only
|
|
108
|
+
* want one signal don't pay for the other.
|
|
109
|
+
*
|
|
110
|
+
* Replaces the previous pair of single-purpose recursive walkers
|
|
111
|
+
* (`scanDirForPattern` + `scanDirForExtension`) that traversed the same tree
|
|
112
|
+
* twice. Detection semantics are unchanged: same dirs skipped (dotfiles,
|
|
113
|
+
* node_modules), same extension and content tests.
|
|
114
|
+
*/
|
|
115
|
+
function scanTreeForDetection(dir, want) {
|
|
116
|
+
const found = {
|
|
117
|
+
isr: false,
|
|
118
|
+
mdx: false
|
|
119
|
+
};
|
|
120
|
+
const walk = (current) => {
|
|
121
|
+
let entries;
|
|
122
|
+
try {
|
|
123
|
+
entries = fs.readdirSync(current, { withFileTypes: true });
|
|
124
|
+
} catch {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
for (const entry of entries) {
|
|
128
|
+
if ((!want.isr || found.isr) && (!want.mdx || found.mdx)) return;
|
|
129
|
+
const fullPath = path.join(current, entry.name);
|
|
130
|
+
if (entry.isDirectory()) {
|
|
131
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
132
|
+
walk(fullPath);
|
|
133
|
+
} else if (entry.isFile()) {
|
|
134
|
+
if (want.mdx && !found.mdx && entry.name.endsWith(".mdx")) found.mdx = true;
|
|
135
|
+
if (want.isr && !found.isr && ISR_SCANNABLE_EXTENSION.test(entry.name)) try {
|
|
136
|
+
if (ISR_PATTERN.test(fs.readFileSync(fullPath, "utf-8"))) found.isr = true;
|
|
137
|
+
} catch {}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
walk(dir);
|
|
142
|
+
return found;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Detect MDX usage declared in next.config (`pageExtensions` including "mdx" or
|
|
146
|
+
* an `@next/mdx` import). Filesystem `.mdx` detection is handled separately by
|
|
147
|
+
* the shared app/pages tree walk in `detectProject`.
|
|
148
|
+
*/
|
|
149
|
+
function detectMDXFromConfig(root) {
|
|
150
|
+
for (const f of [
|
|
151
|
+
"next.config.ts",
|
|
152
|
+
"next.config.mts",
|
|
153
|
+
"next.config.mjs",
|
|
154
|
+
"next.config.js",
|
|
155
|
+
"next.config.cjs"
|
|
156
|
+
]) {
|
|
157
|
+
const p = path.join(root, f);
|
|
158
|
+
if (fs.existsSync(p)) try {
|
|
159
|
+
const content = fs.readFileSync(p, "utf-8");
|
|
160
|
+
if (/pageExtensions.*mdx/i.test(content) || /@next\/mdx/.test(content)) return true;
|
|
161
|
+
} catch {}
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
function detectCacheComponents(root) {
|
|
166
|
+
for (const fileName of [
|
|
167
|
+
"next.config.ts",
|
|
168
|
+
"next.config.mts",
|
|
169
|
+
"next.config.mjs",
|
|
170
|
+
"next.config.js",
|
|
171
|
+
"next.config.cjs"
|
|
172
|
+
]) {
|
|
173
|
+
const configPath = path.join(root, fileName);
|
|
174
|
+
if (!fs.existsSync(configPath)) continue;
|
|
175
|
+
try {
|
|
176
|
+
if (/\bcacheComponents\s*:\s*true\b/.test(fs.readFileSync(configPath, "utf-8"))) return true;
|
|
177
|
+
} catch {}
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
/** Known native Node modules that can't run in Workers */
|
|
182
|
+
const NATIVE_MODULES_TO_STUB = [
|
|
183
|
+
"@resvg/resvg-js",
|
|
184
|
+
"satori",
|
|
185
|
+
"lightningcss",
|
|
186
|
+
"@napi-rs/canvas",
|
|
187
|
+
"sharp"
|
|
188
|
+
];
|
|
189
|
+
/**
|
|
190
|
+
* Detect native Node modules in the project's merged dependency map that need
|
|
191
|
+
* stubbing for Workers. Accepts the already-built `allDeps` (dependencies +
|
|
192
|
+
* devDependencies) so package.json is not re-read or re-parsed.
|
|
193
|
+
*/
|
|
194
|
+
function detectNativeModules(allDeps) {
|
|
195
|
+
return NATIVE_MODULES_TO_STUB.filter((mod) => mod in allDeps);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Check if a package is resolvable from a given root directory using
|
|
199
|
+
* Node's module resolution (createRequire). Handles hoisting, pnpm
|
|
200
|
+
* symlinks, monorepos, and Yarn PnP correctly.
|
|
201
|
+
*/
|
|
202
|
+
function isPackageResolvable(root, packageName) {
|
|
203
|
+
try {
|
|
204
|
+
createRequire(path.join(root, "package.json")).resolve(packageName);
|
|
205
|
+
return true;
|
|
206
|
+
} catch {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function getMissingDeps(info, _isResolvable = isPackageResolvable) {
|
|
211
|
+
const missing = [];
|
|
212
|
+
if (!info.hasCloudflarePlugin) missing.push({
|
|
213
|
+
name: "@cloudflare/vite-plugin",
|
|
214
|
+
version: "latest"
|
|
215
|
+
});
|
|
216
|
+
if (!info.hasWrangler) missing.push({
|
|
217
|
+
name: "wrangler",
|
|
218
|
+
version: "latest"
|
|
219
|
+
});
|
|
220
|
+
if (!_isResolvable(info.root, "@vitejs/plugin-react")) missing.push({
|
|
221
|
+
name: "@vitejs/plugin-react",
|
|
222
|
+
version: "latest"
|
|
223
|
+
});
|
|
224
|
+
if (info.isAppRouter && !info.hasRscPlugin) missing.push({
|
|
225
|
+
name: "@vitejs/plugin-rsc",
|
|
226
|
+
version: "latest"
|
|
227
|
+
});
|
|
228
|
+
if (info.isAppRouter) {
|
|
229
|
+
if (!_isResolvable(info.root, "react-server-dom-webpack")) missing.push({
|
|
230
|
+
name: "react-server-dom-webpack",
|
|
231
|
+
version: "latest"
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
if (info.hasMDX) {
|
|
235
|
+
if (!_isResolvable(info.root, "@mdx-js/rollup")) missing.push({
|
|
236
|
+
name: "@mdx-js/rollup",
|
|
237
|
+
version: "latest"
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return missing;
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
export { detectProject, getMissingDeps, hasWranglerConfig, isPackageResolvable };
|
package/dist/cloudflare/tpr.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { VINEXT_REVALIDATE_HEADER } from "../server/headers.js";
|
|
2
2
|
import { isrCacheKey } from "../server/isr-cache.js";
|
|
3
3
|
import { buildAppPageCacheTags } from "../server/app-page-cache.js";
|
|
4
|
-
import { ENTRY_PREFIX } from "
|
|
4
|
+
import { ENTRY_PREFIX } from "../packages/cloudflare/src/cache/kv-data-adapter.runtime.js";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VINEXT_MW_CTX_HEADER, VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER } from "../
|
|
2
|
-
import { buildRequestHeadersFromMiddlewareResponse } from "../
|
|
1
|
+
import { VINEXT_MW_CTX_HEADER, VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER } from "../utils/protocol-headers.js";
|
|
2
|
+
import { buildRequestHeadersFromMiddlewareResponse } from "../utils/middleware-request-headers.js";
|
|
3
3
|
import { parseCookieHeader } from "../utils/parse-cookie.js";
|
|
4
4
|
//#region src/config/config-matchers.ts
|
|
5
5
|
/**
|
|
@@ -526,11 +526,13 @@ function extractConstraint(str, re) {
|
|
|
526
526
|
*
|
|
527
527
|
* The root path `"/"` is preserved as-is.
|
|
528
528
|
*/
|
|
529
|
-
function stripTrailingSlashForConfigMatch(
|
|
530
|
-
return
|
|
529
|
+
function stripTrailingSlashForConfigMatch(value) {
|
|
530
|
+
return value.length > 1 && value.endsWith("/") ? value.slice(0, -1) : value;
|
|
531
531
|
}
|
|
532
532
|
function matchConfigPattern(pathname, pattern) {
|
|
533
|
+
const pathnameHadTrailingSlash = pathname.length > 1 && pathname.endsWith("/");
|
|
533
534
|
pathname = stripTrailingSlashForConfigMatch(pathname);
|
|
535
|
+
if (pathnameHadTrailingSlash) pattern = stripTrailingSlashForConfigMatch(pattern);
|
|
534
536
|
const catchAllAnchor = /:[\w-]+[*+]/.test(pattern);
|
|
535
537
|
const namedParamCount = (pattern.match(/:[\w-]+/g) || []).length;
|
|
536
538
|
if (pattern.includes("(") || pattern.includes("\\") || /:[\w-]+[*+][^/]/.test(pattern) || /:[\w-]+\./.test(pattern) || /[^/]:[\w-]+/.test(pattern) || catchAllAnchor && namedParamCount > 1) try {
|
|
@@ -628,12 +630,12 @@ function matchConfigPattern(pathname, pattern) {
|
|
|
628
630
|
*/
|
|
629
631
|
function matchRedirect(pathname, redirects, ctx, basePathState = _BASEPATH_DEFAULT) {
|
|
630
632
|
if (redirects.length === 0) return null;
|
|
631
|
-
|
|
633
|
+
const normalizedPathname = stripTrailingSlashForConfigMatch(pathname);
|
|
632
634
|
const index = _getRedirectIndex(redirects);
|
|
633
635
|
let localeMatch = null;
|
|
634
636
|
let localeMatchIndex = Infinity;
|
|
635
637
|
if (index.localeStatic.size > 0) {
|
|
636
|
-
const noLocaleBucket = index.localeStatic.get(
|
|
638
|
+
const noLocaleBucket = index.localeStatic.get(normalizedPathname);
|
|
637
639
|
if (noLocaleBucket) for (const entry of noLocaleBucket) {
|
|
638
640
|
if (!entry.optional) continue;
|
|
639
641
|
if (entry.originalIndex >= localeMatchIndex) continue;
|
|
@@ -651,10 +653,10 @@ function matchRedirect(pathname, redirects, ctx, basePathState = _BASEPATH_DEFAU
|
|
|
651
653
|
localeMatchIndex = entry.originalIndex;
|
|
652
654
|
break;
|
|
653
655
|
}
|
|
654
|
-
const slashTwo =
|
|
656
|
+
const slashTwo = normalizedPathname.indexOf("/", 1);
|
|
655
657
|
if (slashTwo !== -1) {
|
|
656
|
-
const suffix =
|
|
657
|
-
const localePart =
|
|
658
|
+
const suffix = normalizedPathname.slice(slashTwo);
|
|
659
|
+
const localePart = normalizedPathname.slice(1, slashTwo);
|
|
658
660
|
const localeBucket = index.localeStatic.get(suffix);
|
|
659
661
|
if (localeBucket) for (const entry of localeBucket) {
|
|
660
662
|
if (entry.originalIndex >= localeMatchIndex) continue;
|
|
@@ -956,11 +958,13 @@ async function proxyExternalRequest(request, externalUrl) {
|
|
|
956
958
|
* when evaluating headers, so this parameter is required.
|
|
957
959
|
*/
|
|
958
960
|
function matchHeaders(pathname, headers, ctx, basePathState = _BASEPATH_DEFAULT) {
|
|
961
|
+
const pathnameHadTrailingSlash = pathname.length > 1 && pathname.endsWith("/");
|
|
959
962
|
pathname = stripTrailingSlashForConfigMatch(pathname);
|
|
960
963
|
const result = [];
|
|
961
964
|
for (const rule of headers) {
|
|
962
965
|
if (!shouldEvaluateRule(rule.basePath, basePathState)) continue;
|
|
963
|
-
const
|
|
966
|
+
const source = pathnameHadTrailingSlash ? stripTrailingSlashForConfigMatch(rule.source) : rule.source;
|
|
967
|
+
const sourceRegex = getCachedRegex(_compiledHeaderSourceCache, source, () => safeRegExp("^" + escapeHeaderSource(source) + "$"));
|
|
964
968
|
if (sourceRegex && sourceRegex.test(pathname)) {
|
|
965
969
|
if (rule.has || rule.missing) {
|
|
966
970
|
if (!checkHasConditions(rule.has, rule.missing, ctx)) continue;
|
|
@@ -107,7 +107,7 @@ type NextConfig = {
|
|
|
107
107
|
}; /** Custom response headers */
|
|
108
108
|
headers?: () => Promise<NextHeader[]> | NextHeader[]; /** Image optimization config */
|
|
109
109
|
images?: {
|
|
110
|
-
remotePatterns?: Array<{
|
|
110
|
+
remotePatterns?: Array<URL | {
|
|
111
111
|
protocol?: string;
|
|
112
112
|
hostname: string;
|
|
113
113
|
port?: string;
|
|
@@ -278,8 +278,11 @@ type ResolvedNextConfig = {
|
|
|
278
278
|
aliases: Record<string, string>; /** Extra allowed origins for dev server access (from allowedDevOrigins). */
|
|
279
279
|
allowedDevOrigins: string[]; /** Extra allowed origins for server action CSRF validation (from experimental.serverActions.allowedOrigins). */
|
|
280
280
|
serverActionsAllowedOrigins: string[]; /** Packages whose barrel imports should be optimized (from experimental.optimizePackageImports). */
|
|
281
|
-
optimizePackageImports: string[]; /**
|
|
282
|
-
|
|
281
|
+
optimizePackageImports: string[]; /** Packages explicitly requested for server/client transpilation. */
|
|
282
|
+
transpilePackages: string[]; /** Packages treated as application code by Turbopack's foreign-code condition. */
|
|
283
|
+
turbopackTranspilePackages: string[]; /** Inline app CSS into production HTML (from experimental.inlineCss). */
|
|
284
|
+
inlineCss: boolean; /** Enable standalone route-miss 404 handling (from experimental.globalNotFound). */
|
|
285
|
+
globalNotFound: boolean; /** Parsed body size limit for server actions in bytes (from experimental.serverActions.bodySizeLimit). Defaults to 1MB. */
|
|
283
286
|
serverActionsBodySizeLimit: number; /** Verbatim body size limit config value (e.g. "2mb") for the "Body exceeded {limit} limit" error. Defaults to "1 MB". */
|
|
284
287
|
serverActionsBodySizeLimitLabel: string; /** Route-level expire fallback in seconds for ISR entries with numeric revalidate. */
|
|
285
288
|
expireTime: number;
|
|
@@ -72,6 +72,7 @@ const CONFIG_FILES = [
|
|
|
72
72
|
"next.config.cjs"
|
|
73
73
|
];
|
|
74
74
|
const DEFAULT_EXPIRE_TIME = 31536e3;
|
|
75
|
+
const DEFAULT_TRANSPILED_PACKAGES = ["geist"];
|
|
75
76
|
/**
|
|
76
77
|
* Default cap for the App Router preload `Link` header length, matching the
|
|
77
78
|
* Next.js `defaultConfig.reactMaxHeadersLength`.
|
|
@@ -252,6 +253,31 @@ function findNextConfigPath(root) {
|
|
|
252
253
|
}
|
|
253
254
|
return null;
|
|
254
255
|
}
|
|
256
|
+
function hasConfigProperty(config, propertyPath) {
|
|
257
|
+
let current = config;
|
|
258
|
+
for (const property of propertyPath.split(".")) {
|
|
259
|
+
if (!isUnknownRecord(current) || current[property] === void 0) return false;
|
|
260
|
+
current = current[property];
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
const emittedConfigWarnings = /* @__PURE__ */ new Set();
|
|
265
|
+
function warnConfigOnce(message) {
|
|
266
|
+
if (emittedConfigWarnings.has(message)) return;
|
|
267
|
+
emittedConfigWarnings.add(message);
|
|
268
|
+
console.warn(message);
|
|
269
|
+
}
|
|
270
|
+
function warnDeprecatedConfigOptions(config, root) {
|
|
271
|
+
const configFileName = path.basename(findNextConfigPath(root) ?? "next.config.js");
|
|
272
|
+
const warnings = [
|
|
273
|
+
["experimental.middlewarePrefetch", `\`experimental.middlewarePrefetch\` is deprecated. Please use \`experimental.proxyPrefetch\` instead in ${configFileName}.`],
|
|
274
|
+
["experimental.middlewareClientMaxBodySize", `\`experimental.middlewareClientMaxBodySize\` is deprecated. Please use \`experimental.proxyClientMaxBodySize\` instead in ${configFileName}.`],
|
|
275
|
+
["experimental.externalMiddlewareRewritesResolve", `\`experimental.externalMiddlewareRewritesResolve\` is deprecated. Please use \`experimental.externalProxyRewritesResolve\` instead in ${configFileName}.`],
|
|
276
|
+
["skipMiddlewareUrlNormalize", `\`skipMiddlewareUrlNormalize\` is deprecated. Please use \`skipProxyUrlNormalize\` instead in ${configFileName}.`],
|
|
277
|
+
["experimental.instrumentationHook", `\`experimental.instrumentationHook\` is no longer needed, because \`instrumentation.js\` is available by default. You can remove it from ${configFileName}.`]
|
|
278
|
+
];
|
|
279
|
+
for (const [propertyPath, warning] of warnings) if (hasConfigProperty(config, propertyPath)) warnConfigOnce(warning);
|
|
280
|
+
}
|
|
255
281
|
async function resolveNextConfigInput(config, phase = PHASE_DEVELOPMENT_SERVER) {
|
|
256
282
|
return await resolveConfigValue(config, phase);
|
|
257
283
|
}
|
|
@@ -585,7 +611,10 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
|
|
|
585
611
|
allowedDevOrigins: [],
|
|
586
612
|
serverActionsAllowedOrigins: [],
|
|
587
613
|
optimizePackageImports: [],
|
|
614
|
+
transpilePackages: [],
|
|
615
|
+
turbopackTranspilePackages: [...DEFAULT_TRANSPILED_PACKAGES],
|
|
588
616
|
inlineCss: false,
|
|
617
|
+
globalNotFound: false,
|
|
589
618
|
serverActionsBodySizeLimit: 1 * 1024 * 1024,
|
|
590
619
|
serverActionsBodySizeLimitLabel: "1 MB",
|
|
591
620
|
expireTime: DEFAULT_EXPIRE_TIME,
|
|
@@ -617,6 +646,7 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
|
|
|
617
646
|
detectNextIntlConfig(root, resolved);
|
|
618
647
|
return resolved;
|
|
619
648
|
}
|
|
649
|
+
warnDeprecatedConfigOptions(config, root);
|
|
620
650
|
let redirects = [];
|
|
621
651
|
if (config.redirects) {
|
|
622
652
|
const result = await config.redirects();
|
|
@@ -668,6 +698,7 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
|
|
|
668
698
|
const rawOptimize = experimental?.optimizePackageImports;
|
|
669
699
|
const optimizePackageImports = Array.isArray(rawOptimize) ? rawOptimize.filter((x) => typeof x === "string") : [];
|
|
670
700
|
const inlineCss = experimental?.inlineCss === true;
|
|
701
|
+
const globalNotFound = experimental?.globalNotFound === true;
|
|
671
702
|
const prefetchInlining = experimental?.prefetchInlining === true || isUnknownRecord(experimental?.prefetchInlining);
|
|
672
703
|
const appShells = experimental?.appShells === true;
|
|
673
704
|
if (appShells) {
|
|
@@ -682,6 +713,8 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
|
|
|
682
713
|
const topLevelServerExternalPackages = Array.isArray(config.serverExternalPackages) ? readStringArray(config.serverExternalPackages) : void 0;
|
|
683
714
|
const legacyServerComponentsExternal = readStringArray(experimental?.serverComponentsExternalPackages);
|
|
684
715
|
const serverExternalPackages = topLevelServerExternalPackages ?? legacyServerComponentsExternal;
|
|
716
|
+
const transpilePackages = readStringArray(config.transpilePackages);
|
|
717
|
+
const turbopackTranspilePackages = [...transpilePackages, ...DEFAULT_TRANSPILED_PACKAGES];
|
|
685
718
|
if (experimental?.swcEnvOptions !== void 0) console.warn("[vinext] next.config option \"experimental.swcEnvOptions\" is not applicable and will be ignored (vinext uses Vite, not SWC). A Vite-compatible polyfill solution may be explored in the future.");
|
|
686
719
|
if (experimental?.rootParams !== void 0) console.warn("[vinext] `experimental.rootParams` is no longer needed, because `next/root-params` is available by default. You can remove it from next.config.(js|mjs|ts).");
|
|
687
720
|
const useLightningcss = experimental?.useLightningcss === true;
|
|
@@ -720,6 +753,16 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
|
|
|
720
753
|
fallback: applyLocaleToRoutes(rewrites.fallback, i18n, "rewrite", opts)
|
|
721
754
|
};
|
|
722
755
|
}
|
|
756
|
+
const images = resolveImagesConfig(config.images ? {
|
|
757
|
+
...config.images,
|
|
758
|
+
remotePatterns: config.images.remotePatterns?.map((pattern) => pattern instanceof URL ? {
|
|
759
|
+
protocol: pattern.protocol.slice(0, -1),
|
|
760
|
+
hostname: pattern.hostname,
|
|
761
|
+
port: pattern.port,
|
|
762
|
+
pathname: pattern.pathname,
|
|
763
|
+
search: pattern.search
|
|
764
|
+
} : { ...pattern })
|
|
765
|
+
} : void 0, root);
|
|
723
766
|
const resolved = {
|
|
724
767
|
env: config.env ?? {},
|
|
725
768
|
basePath: config.basePath ?? "",
|
|
@@ -737,14 +780,17 @@ async function resolveNextConfig(config, root = process.cwd(), options = {}) {
|
|
|
737
780
|
redirects,
|
|
738
781
|
rewrites,
|
|
739
782
|
headers,
|
|
740
|
-
images
|
|
783
|
+
images,
|
|
741
784
|
i18n,
|
|
742
785
|
mdx,
|
|
743
786
|
aliases,
|
|
744
787
|
allowedDevOrigins,
|
|
745
788
|
serverActionsAllowedOrigins,
|
|
746
789
|
optimizePackageImports,
|
|
790
|
+
transpilePackages,
|
|
791
|
+
turbopackTranspilePackages,
|
|
747
792
|
inlineCss,
|
|
793
|
+
globalNotFound,
|
|
748
794
|
serverActionsBodySizeLimit,
|
|
749
795
|
serverActionsBodySizeLimitLabel,
|
|
750
796
|
expireTime: typeof config.expireTime === "number" ? config.expireTime : DEFAULT_EXPIRE_TIME,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region src/config/server-external-packages.ts
|
|
2
|
+
const DEFAULT_SERVER_EXTERNAL_PACKAGES = [
|
|
3
|
+
"@alinea/generated",
|
|
4
|
+
"@appsignal/nodejs",
|
|
5
|
+
"@aws-sdk/client-s3",
|
|
6
|
+
"@aws-sdk/s3-presigned-post",
|
|
7
|
+
"@blockfrost/blockfrost-js",
|
|
8
|
+
"@highlight-run/node",
|
|
9
|
+
"@huggingface/transformers",
|
|
10
|
+
"@jpg-store/lucid-cardano",
|
|
11
|
+
"@libsql/client",
|
|
12
|
+
"@mikro-orm/core",
|
|
13
|
+
"@mikro-orm/knex",
|
|
14
|
+
"@node-rs/argon2",
|
|
15
|
+
"@node-rs/bcrypt",
|
|
16
|
+
"@prisma/client",
|
|
17
|
+
"@react-pdf/renderer",
|
|
18
|
+
"@sentry/profiling-node",
|
|
19
|
+
"@sparticuz/chromium",
|
|
20
|
+
"@sparticuz/chromium-min",
|
|
21
|
+
"@statsig/statsig-node-core",
|
|
22
|
+
"@swc/core",
|
|
23
|
+
"@xenova/transformers",
|
|
24
|
+
"@zenstackhq/runtime",
|
|
25
|
+
"argon2",
|
|
26
|
+
"autoprefixer",
|
|
27
|
+
"aws-crt",
|
|
28
|
+
"bcrypt",
|
|
29
|
+
"better-sqlite3",
|
|
30
|
+
"canvas",
|
|
31
|
+
"chromadb-default-embed",
|
|
32
|
+
"config",
|
|
33
|
+
"cpu-features",
|
|
34
|
+
"cypress",
|
|
35
|
+
"dd-trace",
|
|
36
|
+
"eslint",
|
|
37
|
+
"express",
|
|
38
|
+
"firebase-admin",
|
|
39
|
+
"htmlrewriter",
|
|
40
|
+
"import-in-the-middle",
|
|
41
|
+
"isolated-vm",
|
|
42
|
+
"jest",
|
|
43
|
+
"jsdom",
|
|
44
|
+
"keyv",
|
|
45
|
+
"libsql",
|
|
46
|
+
"mdx-bundler",
|
|
47
|
+
"mongodb",
|
|
48
|
+
"mongoose",
|
|
49
|
+
"newrelic",
|
|
50
|
+
"next-mdx-remote",
|
|
51
|
+
"next-seo",
|
|
52
|
+
"node-cron",
|
|
53
|
+
"node-pty",
|
|
54
|
+
"node-web-audio-api",
|
|
55
|
+
"onnxruntime-node",
|
|
56
|
+
"oslo",
|
|
57
|
+
"pg",
|
|
58
|
+
"pino",
|
|
59
|
+
"pino-pretty",
|
|
60
|
+
"pino-roll",
|
|
61
|
+
"playwright",
|
|
62
|
+
"playwright-core",
|
|
63
|
+
"postcss",
|
|
64
|
+
"prettier",
|
|
65
|
+
"prisma",
|
|
66
|
+
"puppeteer",
|
|
67
|
+
"puppeteer-core",
|
|
68
|
+
"ravendb",
|
|
69
|
+
"require-in-the-middle",
|
|
70
|
+
"rimraf",
|
|
71
|
+
"sharp",
|
|
72
|
+
"shiki",
|
|
73
|
+
"sqlite3",
|
|
74
|
+
"thread-stream",
|
|
75
|
+
"ts-morph",
|
|
76
|
+
"ts-node",
|
|
77
|
+
"typescript",
|
|
78
|
+
"vscode-oniguruma",
|
|
79
|
+
"webpack",
|
|
80
|
+
"websocket",
|
|
81
|
+
"zeromq"
|
|
82
|
+
];
|
|
83
|
+
function mergeServerExternalPackages(userPackages = [], transpilePackages = []) {
|
|
84
|
+
const transpiled = new Set(transpilePackages);
|
|
85
|
+
const conflicts = userPackages.filter((name) => transpiled.has(name));
|
|
86
|
+
if (conflicts.length > 0) throw new Error(`The packages specified in the 'transpilePackages' conflict with the 'serverExternalPackages': ${conflicts.join(", ")}`);
|
|
87
|
+
const defaults = DEFAULT_SERVER_EXTERNAL_PACKAGES.filter((name) => !transpiled.has(name));
|
|
88
|
+
return [...new Set([...defaults, ...userPackages])];
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { mergeServerExternalPackages };
|