@guren/plugin-vercel 0.6.1 → 0.7.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/dist/index.js +10 -23
- package/package.json +2 -2
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,
|
|
4
|
+
import { DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, assertOutputDirOutsideRoot, bundledRuntimeEnv, removeShadowingIndex, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, unusedSqlClients } from "@guren/core/internal/deploy-build";
|
|
5
5
|
import { reportDeployRuntimeHazards } from "@guren/core/internal/deploy-check";
|
|
6
6
|
//#region src/index.ts
|
|
7
7
|
/** Prefixes every diagnostic this build emits. */
|
|
@@ -92,7 +92,6 @@ async function buildVercelOutput(options = {}) {
|
|
|
92
92
|
function documentAssetPattern() {
|
|
93
93
|
return `^/.*\\.(?:${DOCUMENT_ASSET_EXTENSIONS.map((extension) => [...extension].map((character) => `[${character}${character.toUpperCase()}]`).join("")).join("|")})$`;
|
|
94
94
|
}
|
|
95
|
-
const MCP_UNAVAILABLE = "The MCP endpoint is unavailable on Vercel — it generates files on disk, and the function filesystem is read-only.";
|
|
96
95
|
/**
|
|
97
96
|
* Why each dev-only module cannot run here, or `null` for one that can. `sqlite`
|
|
98
97
|
* is the `null`: the function runs on Vercel's Bun runtime, so `bun:sqlite` works
|
|
@@ -103,17 +102,16 @@ const MCP_UNAVAILABLE = "The MCP endpoint is unavailable on Vercel — it genera
|
|
|
103
102
|
const UNAVAILABLE_ON_VERCEL = {
|
|
104
103
|
sqlite: null,
|
|
105
104
|
vite: "The Vite dev server is unavailable on Vercel — assets are served from the static output directory.",
|
|
106
|
-
mcp:
|
|
105
|
+
mcp: "The Dev MCP endpoint and docs viewer (@guren/cli) are unavailable on Vercel — they read and generate files on disk, and the function filesystem is read-only."
|
|
107
106
|
};
|
|
108
107
|
/**
|
|
109
108
|
* Modules replaced with throwing stubs, in match order. One defect shape — a
|
|
110
109
|
* *literal* dynamic import of a package the app never installed, followed by a
|
|
111
110
|
* bundler regardless of branch: dev-only modules, and SQL clients of unused
|
|
112
|
-
* dialects.
|
|
113
|
-
* so its transport must reach the bundle (RFC 0016 §7); the *Dev* MCP stays stubbed.
|
|
111
|
+
* dialects.
|
|
114
112
|
*/
|
|
115
|
-
function stubbedModules(root, dialects
|
|
116
|
-
const devOnly =
|
|
113
|
+
function stubbedModules(root, dialects) {
|
|
114
|
+
const devOnly = DEV_ONLY_MODULES.flatMap((module) => {
|
|
117
115
|
const message = UNAVAILABLE_ON_VERCEL[module.kind];
|
|
118
116
|
return message === null ? [] : [[module.specifier, renderDevOnlyStub(module, message)]];
|
|
119
117
|
});
|
|
@@ -124,21 +122,11 @@ function stubbedModules(root, dialects, mcpPlugin) {
|
|
|
124
122
|
}).map(({ module, message }) => [module.specifier, renderDevOnlyStub(module, message)]);
|
|
125
123
|
return Object.fromEntries([...devOnly, ...unused]);
|
|
126
124
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Fallback for an MCP SDK subpath `DEV_ONLY_MODULES` does not name. It cannot
|
|
129
|
-
* know which names the importer destructures, so it throws on evaluation rather
|
|
130
|
-
* than resolving to an empty module. Reachable only for an app that does *not*
|
|
131
|
-
* declare `@guren/plugin-mcp`, whose statically imported `server/index.js` and
|
|
132
|
-
* `types.js` this would otherwise leave compiled shut.
|
|
133
|
-
*/
|
|
134
|
-
const unlistedMcpStub = `throw new Error(${JSON.stringify(MCP_UNAVAILABLE)})\n`;
|
|
135
125
|
function escapeRegExp(value) {
|
|
136
126
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
137
127
|
}
|
|
138
|
-
function stubFilter(stubs
|
|
139
|
-
|
|
140
|
-
if (!mcpPlugin) terms.push(`${escapeRegExp(MCP_SDK_SUBPATH_PREFIX)}.+`);
|
|
141
|
-
return new RegExp(`^(?:${terms.join("|")})$`);
|
|
128
|
+
function stubFilter(stubs) {
|
|
129
|
+
return new RegExp(`^(?:${Object.keys(stubs).map(escapeRegExp).join("|")})$`);
|
|
142
130
|
}
|
|
143
131
|
/**
|
|
144
132
|
* Bundle the function with Bun's JS API rather than by spawning `bun build`.
|
|
@@ -148,9 +136,8 @@ function stubFilter(stubs, mcpPlugin) {
|
|
|
148
136
|
* all while the other two did. The API takes plugins.
|
|
149
137
|
*/
|
|
150
138
|
async function bundleFunction(input) {
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
const filter = stubFilter(stubs, mcpPlugin);
|
|
139
|
+
const stubs = stubbedModules(input.root, input.dialects);
|
|
140
|
+
const filter = stubFilter(stubs);
|
|
154
141
|
const result = await Bun.build({
|
|
155
142
|
entrypoints: [input.entrypoint],
|
|
156
143
|
throw: false,
|
|
@@ -176,7 +163,7 @@ async function bundleFunction(input) {
|
|
|
176
163
|
filter: /.*/,
|
|
177
164
|
namespace: "guren-vercel-stub"
|
|
178
165
|
}, (args) => ({
|
|
179
|
-
contents: stubs[args.path]
|
|
166
|
+
contents: stubs[args.path],
|
|
180
167
|
loader: "js"
|
|
181
168
|
}));
|
|
182
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/plugin-vercel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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.
|
|
38
|
+
"@guren/core": "^1.20.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^20.14.10",
|