@guren/plugin-vercel 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -8
- package/dist/index.js +25 -62
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -29,14 +29,7 @@ interface BuildVercelOutputOptions {
|
|
|
29
29
|
* fields never force another registration-shape change.
|
|
30
30
|
*/
|
|
31
31
|
interface VercelPluginConfig {}
|
|
32
|
-
/**
|
|
33
|
-
* Register the Vercel plugin.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* createApp({ providers: [vercelPlugin()] })
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
32
|
+
/** Register the Vercel plugin. */
|
|
40
33
|
declare function vercelPlugin(config?: VercelPluginConfig): ServiceProviderConstructor;
|
|
41
34
|
declare function createVercelHandler(app: VercelAppLike): Promise<VercelHandler>;
|
|
42
35
|
declare function buildVercelOutput(options?: BuildVercelOutputOptions): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cpSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { basename, extname, resolve } from "node:path";
|
|
3
3
|
import { definePlugin } from "@guren/core";
|
|
4
|
-
import { DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, MCP_SDK_SUBPATH_PREFIX, appUsesMcpPlugin, assertOutputDirOutsideRoot, clientManifestJson, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stubbableDevOnlyModules, unusedSqlClients } from "@guren/core/internal/deploy-build";
|
|
4
|
+
import { DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, MCP_SDK_SUBPATH_PREFIX, appUsesMcpPlugin, assertOutputDirOutsideRoot, clientManifestJson, removeShadowingIndex, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stubbableDevOnlyModules, unusedSqlClients } from "@guren/core/internal/deploy-build";
|
|
5
5
|
//#region src/index.ts
|
|
6
6
|
/** Prefixes every diagnostic this build emits. */
|
|
7
7
|
const LABEL = "Vercel build";
|
|
@@ -9,14 +9,7 @@ const factory = definePlugin({
|
|
|
9
9
|
name: "vercel",
|
|
10
10
|
register() {}
|
|
11
11
|
});
|
|
12
|
-
/**
|
|
13
|
-
* Register the Vercel plugin.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* createApp({ providers: [vercelPlugin()] })
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
12
|
+
/** Register the Vercel plugin. */
|
|
20
13
|
function vercelPlugin(config = {}) {
|
|
21
14
|
return factory(config);
|
|
22
15
|
}
|
|
@@ -79,38 +72,28 @@ async function buildVercelOutput(options = {}) {
|
|
|
79
72
|
if (existsSync(ssrDir)) cpSync(ssrDir, resolve(funcDir, ".guren/ssr"), { recursive: true });
|
|
80
73
|
if (existsSync(migrationsDir)) cpSync(migrationsDir, resolve(funcDir, "db/migrations"), { recursive: true });
|
|
81
74
|
if (existsSync(docsDir)) cpSync(docsDir, resolve(funcDir, "docs"), { recursive: true });
|
|
82
|
-
if (existsSync(publicDir))
|
|
75
|
+
if (existsSync(publicDir)) {
|
|
76
|
+
cpSync(publicDir, resolve(out, "static"), { recursive: true });
|
|
77
|
+
removeShadowingIndex(resolve(out, "static"));
|
|
78
|
+
}
|
|
83
79
|
}
|
|
84
80
|
/**
|
|
85
|
-
* Matches a staged path whose extension a browser would render as a document
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* Spelled with a character class per letter because Vercel compiles `src`
|
|
92
|
-
* case-sensitively: a plain extension would leave logo.SVG inline, while the
|
|
93
|
-
* framework guard lowercases before its mime lookup and catches it. An inline
|
|
94
|
-
* case-insensitive flag is not an option, because `src` is validated by
|
|
95
|
-
* constructing a JavaScript `RegExp` from it.
|
|
81
|
+
* Matches a staged path whose extension a browser would render as a document;
|
|
82
|
+
* the CDN serves `.vercel/output/static` ahead of the function, so the
|
|
83
|
+
* framework's own guard never sees these files. A character class per letter
|
|
84
|
+
* because Vercel compiles `src` case-sensitively (a plain extension leaves
|
|
85
|
+
* logo.SVG inline) and validates it as a JavaScript `RegExp`, so no inline flag.
|
|
96
86
|
*/
|
|
97
87
|
function documentAssetPattern() {
|
|
98
88
|
return `^/.*\\.(?:${DOCUMENT_ASSET_EXTENSIONS.map((extension) => [...extension].map((character) => `[${character}${character.toUpperCase()}]`).join("")).join("|")})$`;
|
|
99
89
|
}
|
|
100
90
|
const MCP_UNAVAILABLE = "The MCP endpoint is unavailable on Vercel — it generates files on disk, and the function filesystem is read-only.";
|
|
101
91
|
/**
|
|
102
|
-
* Why each dev-only module cannot run here, or `null` for one that can
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* runs on Vercel's Bun runtime, so `bun:sqlite` is a working database here —
|
|
108
|
-
* unlike on Workers and Lambda, whose tables name a replacement for it.
|
|
109
|
-
* Stubbing it would break an app that ships a read-only sqlite file beside
|
|
110
|
-
* its function.
|
|
111
|
-
*
|
|
112
|
-
* Keyed on every kind `DEV_ONLY_MODULES` contains, so a kind added there is a
|
|
113
|
-
* compile error here rather than a module that silently stubs to `undefined`.
|
|
92
|
+
* Why each dev-only module cannot run here, or `null` for one that can. `sqlite`
|
|
93
|
+
* is the `null`: the function runs on Vercel's Bun runtime, so `bun:sqlite` works
|
|
94
|
+
* and stubbing it would break an app shipping a read-only sqlite file beside its
|
|
95
|
+
* function. Keyed on every kind `DEV_ONLY_MODULES` contains, so a kind added
|
|
96
|
+
* there is a compile error here.
|
|
114
97
|
*/
|
|
115
98
|
const UNAVAILABLE_ON_VERCEL = {
|
|
116
99
|
sqlite: null,
|
|
@@ -118,25 +101,11 @@ const UNAVAILABLE_ON_VERCEL = {
|
|
|
118
101
|
mcp: MCP_UNAVAILABLE
|
|
119
102
|
};
|
|
120
103
|
/**
|
|
121
|
-
* Modules replaced with throwing stubs, in
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* - The dev-only ones. A scaffolded app could not be bundled for Vercel at
|
|
128
|
-
* all: the disabled MCP endpoint's `import("@guren/cli")` resolves, and the
|
|
129
|
-
* CLI's own `import("@guren/openapi")` behind it does not. Lambda never saw
|
|
130
|
-
* this because it has stubbed these since it shipped.
|
|
131
|
-
* - The database clients for dialects the app does not use, decided per app
|
|
132
|
-
* rather than per platform — the ones it *does* use are load-bearing here,
|
|
133
|
-
* unlike on Workers where D1 is the only database.
|
|
134
|
-
*
|
|
135
|
-
* The dev-only set is per app in one respect too: an app declaring
|
|
136
|
-
* `@guren/plugin-mcp` serves the App MCP endpoint from this function, so its
|
|
137
|
-
* transport must reach the bundle (RFC 0016 §7). The *Dev* MCP's `McpServer`
|
|
138
|
-
* and the CLI behind it stay stubbed regardless — see
|
|
139
|
-
* `stubbableDevOnlyModules`.
|
|
104
|
+
* Modules replaced with throwing stubs, in match order. One defect shape — a
|
|
105
|
+
* *literal* dynamic import of a package the app never installed, followed by a
|
|
106
|
+
* bundler regardless of branch: dev-only modules, and SQL clients of unused
|
|
107
|
+
* dialects. An app declaring `@guren/plugin-mcp` serves the App MCP endpoint here,
|
|
108
|
+
* so its transport must reach the bundle (RFC 0016 §7); the *Dev* MCP stays stubbed.
|
|
140
109
|
*/
|
|
141
110
|
function stubbedModules(root, dialects, mcpPlugin) {
|
|
142
111
|
const devOnly = stubbableDevOnlyModules({ mcpPlugin }).flatMap((module) => {
|
|
@@ -152,16 +121,10 @@ function stubbedModules(root, dialects, mcpPlugin) {
|
|
|
152
121
|
}
|
|
153
122
|
/**
|
|
154
123
|
* Fallback for an MCP SDK subpath `DEV_ONLY_MODULES` does not name. It cannot
|
|
155
|
-
* know which names the importer destructures, so it throws on evaluation
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* Reachable only for an app that does *not* declare `@guren/plugin-mcp`. For
|
|
161
|
-
* one that does, the SDK is a dependency it deliberately ships, and this
|
|
162
|
-
* fallback would stub `server/index.js` and `types.js` — which
|
|
163
|
-
* `@guren/plugin-mcp` imports statically — leaving the endpoint just as
|
|
164
|
-
* compiled shut as the transport stub did.
|
|
124
|
+
* know which names the importer destructures, so it throws on evaluation rather
|
|
125
|
+
* than resolving to an empty module. Reachable only for an app that does *not*
|
|
126
|
+
* declare `@guren/plugin-mcp`, whose statically imported `server/index.js` and
|
|
127
|
+
* `types.js` this would otherwise leave compiled shut.
|
|
165
128
|
*/
|
|
166
129
|
const unlistedMcpStub = `throw new Error(${JSON.stringify(MCP_UNAVAILABLE)})\n`;
|
|
167
130
|
function escapeRegExp(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/plugin-vercel",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"typecheck": "tsc --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@guren/core": "^1.13.
|
|
38
|
+
"@guren/core": "^1.13.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^20.14.10",
|