@guren/plugin-vercel 0.7.1 → 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.
Files changed (2) hide show
  1. package/dist/index.js +28 -16
  2. 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 { 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";
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(root, dialects) {
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 = unusedSqlClients({
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,18 +133,20 @@ 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 stubs = stubbedModules(input.root, input.dialects);
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],
143
145
  throw: false,
144
146
  outdir: input.funcDir,
145
147
  target: "bun",
146
- minify: {
147
- whitespace: true,
148
- syntax: true,
149
- identifiers: false
150
- },
148
+ minify: BUN_DEPLOY_MINIFY,
149
+ metafile: true,
151
150
  define: {
152
151
  "process.env.NODE_ENV": "\"production\"",
153
152
  ...Object.fromEntries(Object.entries(input.bundledEnv).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]))
@@ -157,11 +156,11 @@ async function bundleFunction(input) {
157
156
  setup(build) {
158
157
  build.onResolve({ filter }, (args) => ({
159
158
  path: args.path,
160
- namespace: "guren-vercel-stub"
159
+ namespace: STUB_NAMESPACE
161
160
  }));
162
161
  build.onLoad({
163
162
  filter: /.*/,
164
- namespace: "guren-vercel-stub"
163
+ namespace: STUB_NAMESPACE
165
164
  }, (args) => ({
166
165
  contents: stubs[args.path],
167
166
  loader: "js"
@@ -169,7 +168,20 @@ async function bundleFunction(input) {
169
168
  }
170
169
  }]
171
170
  });
172
- if (!result.success) throw new Error(`${LABEL}: bun build failed.\n${result.logs.map((log) => String(log)).join("\n")}`);
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
+ }
181
+ await reportRenamedNameKeyedClasses(result, {
182
+ root: input.root,
183
+ label: LABEL
184
+ });
173
185
  }
174
186
  function buildVercelEnvironment(publicDir, ssrDir) {
175
187
  const env = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/plugin-vercel",
3
- "version": "0.7.1",
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.20.1"
49
+ "@guren/core": "^1.28.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/node": "^20.14.10",