@guren/plugin-vercel 0.7.2 → 0.7.3
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 +22 -11
- 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 { BUN_DEPLOY_MINIFY, DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, assertOutputDirOutsideRoot, bundledRuntimeEnv, removeShadowingIndex, renderDevOnlyStub, reportRenamedNameKeyedClasses, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, unusedSqlClients } from "@guren/core/internal/deploy-build";
|
|
4
|
+
import { BUN_DEPLOY_MINIFY, DEV_ONLY_MODULES, DOCUMENT_ASSET_EXTENSIONS, DOCUMENT_ASSET_HEADERS, assertOutputDirOutsideRoot, bundledRuntimeEnv, removeShadowingIndex, renderDevOnlyStub, reportRenamedNameKeyedClasses, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stubbedSqlClientHints, 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. */
|
|
@@ -110,18 +110,15 @@ const UNAVAILABLE_ON_VERCEL = {
|
|
|
110
110
|
* bundler regardless of branch: dev-only modules, and SQL clients of unused
|
|
111
111
|
* dialects.
|
|
112
112
|
*/
|
|
113
|
-
function stubbedModules(
|
|
113
|
+
function stubbedModules(unusedClients) {
|
|
114
114
|
const devOnly = DEV_ONLY_MODULES.flatMap((module) => {
|
|
115
115
|
const message = UNAVAILABLE_ON_VERCEL[module.kind];
|
|
116
116
|
return message === null ? [] : [[module.specifier, renderDevOnlyStub(module, message)]];
|
|
117
117
|
});
|
|
118
|
-
const unused =
|
|
119
|
-
root,
|
|
120
|
-
label: LABEL,
|
|
121
|
-
dialects
|
|
122
|
-
}).map(({ module, message }) => [module.specifier, renderDevOnlyStub(module, message)]);
|
|
118
|
+
const unused = unusedClients.map(({ module, message }) => [module.specifier, renderDevOnlyStub(module, message)]);
|
|
123
119
|
return Object.fromEntries([...devOnly, ...unused]);
|
|
124
120
|
}
|
|
121
|
+
const STUB_NAMESPACE = "guren-vercel-stub";
|
|
125
122
|
function escapeRegExp(value) {
|
|
126
123
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
127
124
|
}
|
|
@@ -136,7 +133,12 @@ function stubFilter(stubs) {
|
|
|
136
133
|
* all while the other two did. The API takes plugins.
|
|
137
134
|
*/
|
|
138
135
|
async function bundleFunction(input) {
|
|
139
|
-
const
|
|
136
|
+
const unused = unusedSqlClients({
|
|
137
|
+
root: input.root,
|
|
138
|
+
label: LABEL,
|
|
139
|
+
dialects: input.dialects
|
|
140
|
+
});
|
|
141
|
+
const stubs = stubbedModules(unused);
|
|
140
142
|
const filter = stubFilter(stubs);
|
|
141
143
|
const result = await Bun.build({
|
|
142
144
|
entrypoints: [input.entrypoint],
|
|
@@ -154,11 +156,11 @@ async function bundleFunction(input) {
|
|
|
154
156
|
setup(build) {
|
|
155
157
|
build.onResolve({ filter }, (args) => ({
|
|
156
158
|
path: args.path,
|
|
157
|
-
namespace:
|
|
159
|
+
namespace: STUB_NAMESPACE
|
|
158
160
|
}));
|
|
159
161
|
build.onLoad({
|
|
160
162
|
filter: /.*/,
|
|
161
|
-
namespace:
|
|
163
|
+
namespace: STUB_NAMESPACE
|
|
162
164
|
}, (args) => ({
|
|
163
165
|
contents: stubs[args.path],
|
|
164
166
|
loader: "js"
|
|
@@ -166,7 +168,16 @@ async function bundleFunction(input) {
|
|
|
166
168
|
}
|
|
167
169
|
}]
|
|
168
170
|
});
|
|
169
|
-
if (!result.success)
|
|
171
|
+
if (!result.success) {
|
|
172
|
+
const logs = result.logs.map((log) => String(log));
|
|
173
|
+
const hints = stubbedSqlClientHints({
|
|
174
|
+
logs,
|
|
175
|
+
namespace: STUB_NAMESPACE,
|
|
176
|
+
unused,
|
|
177
|
+
label: LABEL
|
|
178
|
+
});
|
|
179
|
+
throw new Error(`${LABEL}: bun build failed.\n${[...logs, ...hints].join("\n")}`);
|
|
180
|
+
}
|
|
170
181
|
await reportRenamedNameKeyedClasses(result, {
|
|
171
182
|
root: input.root,
|
|
172
183
|
label: LABEL
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/plugin-vercel",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Deploy a Guren SSR application to Vercel through the Build Output API, on Vercel's Bun runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"guren",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typecheck": "tsc --noEmit"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@guren/core": "^1.
|
|
49
|
+
"@guren/core": "^1.28.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^20.14.10",
|