vite-plugin-tanstack-start-zephyr 0.0.0-canary.26 → 0.0.0-canary.29
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/lib/internal/extract/load-tanstack-output.js +6 -14
- package/dist/lib/internal/extract/load-tanstack-output.js.map +1 -1
- package/dist/lib/vite-plugin-tanstack-start-zephyr.d.ts +9 -0
- package/dist/lib/vite-plugin-tanstack-start-zephyr.js +31 -11
- package/dist/lib/vite-plugin-tanstack-start-zephyr.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/lib/internal/extract/load-tanstack-output.ts +6 -15
- package/src/lib/vite-plugin-tanstack-start-zephyr.ts +47 -16
|
@@ -9,20 +9,12 @@ exports.validateTanStackOutput = validateTanStackOutput;
|
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const fs = tslib_1.__importStar(require("fs/promises"));
|
|
11
11
|
const path = tslib_1.__importStar(require("path"));
|
|
12
|
-
/** Recursively get all files in a directory */
|
|
13
|
-
async function getAllFiles(dir
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (entry.isDirectory()) {
|
|
19
|
-
return getAllFiles(fullPath, baseDir);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return [fullPath];
|
|
23
|
-
}
|
|
24
|
-
}));
|
|
25
|
-
return files.flat();
|
|
12
|
+
/** Recursively get all files in a directory using Node.js native recursive option */
|
|
13
|
+
async function getAllFiles(dir) {
|
|
14
|
+
const entries = await fs.readdir(dir, { recursive: true, withFileTypes: true });
|
|
15
|
+
return entries
|
|
16
|
+
.filter((entry) => entry.isFile())
|
|
17
|
+
.map((entry) => { var _a; return path.join((_a = entry.parentPath) !== null && _a !== void 0 ? _a : entry.path, entry.name); });
|
|
26
18
|
}
|
|
27
19
|
/** Load files from directory into Rollup OutputBundle format */
|
|
28
20
|
async function loadFilesFromDirectory(dir) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-tanstack-output.js","sourceRoot":"","sources":["../../../../src/lib/internal/extract/load-tanstack-output.ts"],"names":[],"mappings":";AAAA,+DAA+D;;
|
|
1
|
+
{"version":3,"file":"load-tanstack-output.js","sourceRoot":"","sources":["../../../../src/lib/internal/extract/load-tanstack-output.ts"],"names":[],"mappings":";AAAA,+DAA+D;;AAe/D,wDA2DC;AAOD,gDAGC;AAGD,4CAGC;AAGD,4CAGC;AAGD,wDA+BC;;AAhID,wDAAkC;AAClC,mDAA6B;AAG7B,qFAAqF;AACrF,KAAK,UAAU,WAAW,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;SACjC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,IAAI,CAAC,IAAI,CAAC,MAAA,KAAK,CAAC,UAAU,mCAAI,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA,EAAA,CAAC,CAAC;AAC3E,CAAC;AAED,gEAAgE;AACzD,KAAK,UAAU,sBAAsB,CAAC,GAAW;IACtD,MAAM,MAAM,GAAiB,EAAE,CAAC;IAEhC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;QAErC,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAClD,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC5C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CAAC;iBACjB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;iBAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC;SACtB,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC;YACjE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC;YAChE,wCAAwC;QAC1C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC1D,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -10,6 +10,15 @@ export interface TanStackStartZephyrOptions {
|
|
|
10
10
|
* (TanStack Start default)
|
|
11
11
|
*/
|
|
12
12
|
outputDir?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Server entry file path for SSR.
|
|
15
|
+
*
|
|
16
|
+
* This should be a path **relative to the TanStack Start output directory** (usually
|
|
17
|
+
* `dist/`). For example: `server/index.js`.
|
|
18
|
+
*
|
|
19
|
+
* Defaults to `server/index.js`.
|
|
20
|
+
*/
|
|
21
|
+
entrypoint?: string;
|
|
13
22
|
}
|
|
14
23
|
/**
|
|
15
24
|
* Main Vite plugin for TanStack Start Zephyr deployment
|
|
@@ -28,6 +28,7 @@ function extractBuffer(item) {
|
|
|
28
28
|
function getAssetType(item) {
|
|
29
29
|
const fileName = item.fileName || item.name || '';
|
|
30
30
|
const ext = path.extname(fileName).toLowerCase();
|
|
31
|
+
// Note: .cjs is intentionally excluded as workers don't support CommonJS
|
|
31
32
|
const typeMap = {
|
|
32
33
|
'.js': 'application/javascript',
|
|
33
34
|
'.mjs': 'application/javascript',
|
|
@@ -37,6 +38,22 @@ function getAssetType(item) {
|
|
|
37
38
|
};
|
|
38
39
|
return typeMap[ext] || 'application/octet-stream';
|
|
39
40
|
}
|
|
41
|
+
function normalizeEntrypoint(entrypoint) {
|
|
42
|
+
let normalized = entrypoint.trim();
|
|
43
|
+
// Normalize separators to match snapshot asset keys (posix-style).
|
|
44
|
+
normalized = normalized.split('\\').join('/');
|
|
45
|
+
// Remove common leading prefixes users may provide.
|
|
46
|
+
while (normalized.startsWith('./')) {
|
|
47
|
+
normalized = normalized.slice(2);
|
|
48
|
+
}
|
|
49
|
+
while (normalized.startsWith('/')) {
|
|
50
|
+
normalized = normalized.slice(1);
|
|
51
|
+
}
|
|
52
|
+
if (normalized.startsWith('dist/')) {
|
|
53
|
+
normalized = normalized.slice('dist/'.length);
|
|
54
|
+
}
|
|
55
|
+
return normalized;
|
|
56
|
+
}
|
|
40
57
|
/**
|
|
41
58
|
* Main Vite plugin for TanStack Start Zephyr deployment
|
|
42
59
|
*
|
|
@@ -50,6 +67,7 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
50
67
|
const { zephyr_engine_defer, zephyr_defer_create } = zephyr_agent_1.ZephyrEngine.defer_create();
|
|
51
68
|
let config;
|
|
52
69
|
let outputDir;
|
|
70
|
+
let entrypoint;
|
|
53
71
|
let uploadCompleted = false; // Guard to ensure we only upload once
|
|
54
72
|
return {
|
|
55
73
|
name: 'vite-plugin-tanstack-start-zephyr',
|
|
@@ -59,7 +77,7 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
59
77
|
// For TanStack Start, always use the root dist directory (contains server/ and client/)
|
|
60
78
|
// Don't use config.build.outDir as it points to dist/server/ during SSR build
|
|
61
79
|
outputDir = options.outputDir || path.join(config.root, 'dist');
|
|
62
|
-
|
|
80
|
+
entrypoint = normalizeEntrypoint(options.entrypoint || 'server/index.js');
|
|
63
81
|
},
|
|
64
82
|
async buildApp(builder) {
|
|
65
83
|
// Guard: Only process upload once, even if buildApp is called multiple times
|
|
@@ -77,17 +95,14 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
77
95
|
const zephyr_engine = await zephyr_engine_defer;
|
|
78
96
|
// Log all environments and their build status for debugging
|
|
79
97
|
const environments = Object.entries(builder.environments);
|
|
80
|
-
|
|
81
|
-
for (const [name, env] of environments) {
|
|
82
|
-
console.log(` - ${name}: isBuilt=${env.isBuilt}`);
|
|
83
|
-
}
|
|
98
|
+
zephyr_agent_1.ze_log.init(`buildApp hook called with ${environments.length} environment(s): ${environments.map(([name, env]) => `${name}(isBuilt=${env.isBuilt})`).join(', ')}`);
|
|
84
99
|
// Wait for all environments to be built (not just specific ones)
|
|
85
100
|
// This ensures we have all build outputs before uploading
|
|
86
101
|
const notBuilt = Object.entries(builder.environments)
|
|
87
102
|
.filter(([, env]) => !env.isBuilt)
|
|
88
103
|
.map(([name]) => name);
|
|
89
104
|
if (notBuilt.length > 0) {
|
|
90
|
-
|
|
105
|
+
zephyr_agent_1.ze_log.init(`Building environments that aren't built yet: ${notBuilt.join(', ')}`);
|
|
91
106
|
for (const envName of notBuilt) {
|
|
92
107
|
const env = builder.environments[envName];
|
|
93
108
|
if (env) {
|
|
@@ -105,30 +120,35 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
105
120
|
message: `Some environments are still not built: ${stillNotBuilt.join(', ')}`,
|
|
106
121
|
});
|
|
107
122
|
}
|
|
108
|
-
|
|
123
|
+
zephyr_agent_1.ze_log.upload('All environments built, processing output...');
|
|
109
124
|
try {
|
|
110
125
|
// Engine is already initialized above, and ZephyrEngine.create() automatically calls start_new_build()
|
|
111
126
|
// So we don't need to call start_new_build() again here
|
|
112
127
|
// Load ALL build output preserving directory structure
|
|
113
128
|
// This includes server/, client/, and any root files (favicon.ico, etc.)
|
|
129
|
+
// Note: We read from disk here (via loadTanStackOutput) rather than using Vite's
|
|
130
|
+
// generateBundle hook because TanStack Start uses multiple Vite environments
|
|
131
|
+
// (client, server, etc.) that build separately. The buildApp hook runs after
|
|
132
|
+
// all environments are complete, making disk reading the simplest approach
|
|
133
|
+
// that's consistent with vite-plugin-zephyr's loadStaticAssets pattern.
|
|
114
134
|
const bundle = await (0, load_tanstack_output_1.loadTanStackOutput)(outputDir);
|
|
115
135
|
const assetsMap = (0, zephyr_agent_1.buildAssetsMap)(bundle, extractBuffer, getAssetType);
|
|
116
|
-
|
|
136
|
+
zephyr_agent_1.ze_log.upload(`Uploading ${Object.keys(assetsMap).length} assets...`);
|
|
117
137
|
// Upload assets with SSR snapshot type
|
|
118
138
|
await zephyr_engine.upload_assets({
|
|
119
139
|
assetsMap,
|
|
120
140
|
buildStats: await (0, zephyr_agent_1.zeBuildDashData)(zephyr_engine),
|
|
121
141
|
snapshotType: 'ssr',
|
|
142
|
+
entrypoint,
|
|
122
143
|
});
|
|
123
144
|
// Finish build
|
|
124
145
|
await zephyr_engine.build_finished();
|
|
125
146
|
// Mark upload as completed to prevent multiple calls
|
|
126
147
|
uploadCompleted = true;
|
|
127
|
-
|
|
148
|
+
zephyr_agent_1.ze_log.upload('Deployment successful!');
|
|
128
149
|
}
|
|
129
150
|
catch (error) {
|
|
130
|
-
|
|
131
|
-
throw error;
|
|
151
|
+
(0, zephyr_agent_1.handleGlobalError)(error);
|
|
132
152
|
}
|
|
133
153
|
},
|
|
134
154
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-tanstack-start-zephyr.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-tanstack-start-zephyr.ts"],"names":[],"mappings":";AAAA,sEAAsE;;
|
|
1
|
+
{"version":3,"file":"vite-plugin-tanstack-start-zephyr.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-tanstack-start-zephyr.ts"],"names":[],"mappings":";AAAA,sEAAsE;;AAgGtE,0DA+GC;;AA5MD,mDAA6B;AAC7B,+CASsB;AACtB,kFAA6E;AAE7E,wCAAwC;AACxC,SAAS,aAAa,CAAC,IAAS;IAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;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iBACX,CAAC,CAAC;gBAEH,eAAe;gBACf,MAAM,aAAa,CAAC,cAAc,EAAE,CAAC;gBAErC,qDAAqD;gBACrD,eAAe,GAAG,IAAI,CAAC;gBAEvB,qBAAM,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;YAC1C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAA,gCAAiB,EAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-tanstack-start-zephyr",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.29",
|
|
4
4
|
"description": "Vite plugin for Zephyr with TanStack Start support",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"rollup": "^4.36.0",
|
|
20
20
|
"vite": "^7.1.11",
|
|
21
|
-
"zephyr-agent": "0.0.0-canary.
|
|
21
|
+
"zephyr-agent": "0.0.0-canary.29"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@tanstack/start": "^1.0.0"
|
|
24
|
+
"@tanstack/react-start": "^1.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^22.13.11"
|
|
@@ -4,21 +4,12 @@ import * as fs from 'fs/promises';
|
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import type { OutputBundle, OutputAsset, OutputChunk } from 'rollup';
|
|
6
6
|
|
|
7
|
-
/** Recursively get all files in a directory */
|
|
8
|
-
async function getAllFiles(dir: string
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const fullPath = path.join(dir, entry.name);
|
|
14
|
-
if (entry.isDirectory()) {
|
|
15
|
-
return getAllFiles(fullPath, baseDir);
|
|
16
|
-
} else {
|
|
17
|
-
return [fullPath];
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
);
|
|
21
|
-
return files.flat();
|
|
7
|
+
/** Recursively get all files in a directory using Node.js native recursive option */
|
|
8
|
+
async function getAllFiles(dir: string): Promise<string[]> {
|
|
9
|
+
const entries = await fs.readdir(dir, { recursive: true, withFileTypes: true });
|
|
10
|
+
return entries
|
|
11
|
+
.filter((entry) => entry.isFile())
|
|
12
|
+
.map((entry) => path.join(entry.parentPath ?? entry.path, entry.name));
|
|
22
13
|
}
|
|
23
14
|
|
|
24
15
|
/** Load files from directory into Rollup OutputBundle format */
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
buildAssetsMap,
|
|
10
10
|
ZeErrors,
|
|
11
11
|
ZephyrError,
|
|
12
|
+
ze_log,
|
|
13
|
+
handleGlobalError,
|
|
12
14
|
} from 'zephyr-agent';
|
|
13
15
|
import { loadTanStackOutput } from './internal/extract/load-tanstack-output';
|
|
14
16
|
|
|
@@ -32,6 +34,7 @@ function extractBuffer(item: any): Buffer {
|
|
|
32
34
|
function getAssetType(item: { fileName?: string; name?: string }): string {
|
|
33
35
|
const fileName = item.fileName || item.name || '';
|
|
34
36
|
const ext = path.extname(fileName).toLowerCase();
|
|
37
|
+
// Note: .cjs is intentionally excluded as workers don't support CommonJS
|
|
35
38
|
const typeMap: Record<string, string> = {
|
|
36
39
|
'.js': 'application/javascript',
|
|
37
40
|
'.mjs': 'application/javascript',
|
|
@@ -52,6 +55,34 @@ export interface TanStackStartZephyrOptions {
|
|
|
52
55
|
* (TanStack Start default)
|
|
53
56
|
*/
|
|
54
57
|
outputDir?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Server entry file path for SSR.
|
|
60
|
+
*
|
|
61
|
+
* This should be a path **relative to the TanStack Start output directory** (usually
|
|
62
|
+
* `dist/`). For example: `server/index.js`.
|
|
63
|
+
*
|
|
64
|
+
* Defaults to `server/index.js`.
|
|
65
|
+
*/
|
|
66
|
+
entrypoint?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function normalizeEntrypoint(entrypoint: string): string {
|
|
70
|
+
let normalized = entrypoint.trim();
|
|
71
|
+
// Normalize separators to match snapshot asset keys (posix-style).
|
|
72
|
+
normalized = normalized.split('\\').join('/');
|
|
73
|
+
|
|
74
|
+
// Remove common leading prefixes users may provide.
|
|
75
|
+
while (normalized.startsWith('./')) {
|
|
76
|
+
normalized = normalized.slice(2);
|
|
77
|
+
}
|
|
78
|
+
while (normalized.startsWith('/')) {
|
|
79
|
+
normalized = normalized.slice(1);
|
|
80
|
+
}
|
|
81
|
+
if (normalized.startsWith('dist/')) {
|
|
82
|
+
normalized = normalized.slice('dist/'.length);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return normalized;
|
|
55
86
|
}
|
|
56
87
|
|
|
57
88
|
/**
|
|
@@ -69,6 +100,7 @@ export function withZephyrTanstackStart(
|
|
|
69
100
|
const { zephyr_engine_defer, zephyr_defer_create } = ZephyrEngine.defer_create();
|
|
70
101
|
let config: ResolvedConfig;
|
|
71
102
|
let outputDir: string;
|
|
103
|
+
let entrypoint: string;
|
|
72
104
|
let uploadCompleted = false; // Guard to ensure we only upload once
|
|
73
105
|
|
|
74
106
|
return {
|
|
@@ -81,8 +113,7 @@ export function withZephyrTanstackStart(
|
|
|
81
113
|
// For TanStack Start, always use the root dist directory (contains server/ and client/)
|
|
82
114
|
// Don't use config.build.outDir as it points to dist/server/ during SSR build
|
|
83
115
|
outputDir = options.outputDir || path.join(config.root, 'dist');
|
|
84
|
-
|
|
85
|
-
console.log(`[TanStack Zephyr] Output directory: ${outputDir}`);
|
|
116
|
+
entrypoint = normalizeEntrypoint(options.entrypoint || 'server/index.js');
|
|
86
117
|
},
|
|
87
118
|
|
|
88
119
|
async buildApp(builder) {
|
|
@@ -102,12 +133,9 @@ export function withZephyrTanstackStart(
|
|
|
102
133
|
const zephyr_engine = await zephyr_engine_defer;
|
|
103
134
|
// Log all environments and their build status for debugging
|
|
104
135
|
const environments = Object.entries(builder.environments);
|
|
105
|
-
|
|
106
|
-
`
|
|
136
|
+
ze_log.init(
|
|
137
|
+
`buildApp hook called with ${environments.length} environment(s): ${environments.map(([name, env]) => `${name}(isBuilt=${env.isBuilt})`).join(', ')}`
|
|
107
138
|
);
|
|
108
|
-
for (const [name, env] of environments) {
|
|
109
|
-
console.log(` - ${name}: isBuilt=${env.isBuilt}`);
|
|
110
|
-
}
|
|
111
139
|
|
|
112
140
|
// Wait for all environments to be built (not just specific ones)
|
|
113
141
|
// This ensures we have all build outputs before uploading
|
|
@@ -116,8 +144,8 @@ export function withZephyrTanstackStart(
|
|
|
116
144
|
.map(([name]) => name);
|
|
117
145
|
|
|
118
146
|
if (notBuilt.length > 0) {
|
|
119
|
-
|
|
120
|
-
`
|
|
147
|
+
ze_log.init(
|
|
148
|
+
`Building environments that aren't built yet: ${notBuilt.join(', ')}`
|
|
121
149
|
);
|
|
122
150
|
for (const envName of notBuilt) {
|
|
123
151
|
const env = builder.environments[envName];
|
|
@@ -138,7 +166,7 @@ export function withZephyrTanstackStart(
|
|
|
138
166
|
});
|
|
139
167
|
}
|
|
140
168
|
|
|
141
|
-
|
|
169
|
+
ze_log.upload('All environments built, processing output...');
|
|
142
170
|
|
|
143
171
|
try {
|
|
144
172
|
// Engine is already initialized above, and ZephyrEngine.create() automatically calls start_new_build()
|
|
@@ -146,19 +174,23 @@ export function withZephyrTanstackStart(
|
|
|
146
174
|
|
|
147
175
|
// Load ALL build output preserving directory structure
|
|
148
176
|
// This includes server/, client/, and any root files (favicon.ico, etc.)
|
|
177
|
+
// Note: We read from disk here (via loadTanStackOutput) rather than using Vite's
|
|
178
|
+
// generateBundle hook because TanStack Start uses multiple Vite environments
|
|
179
|
+
// (client, server, etc.) that build separately. The buildApp hook runs after
|
|
180
|
+
// all environments are complete, making disk reading the simplest approach
|
|
181
|
+
// that's consistent with vite-plugin-zephyr's loadStaticAssets pattern.
|
|
149
182
|
const bundle = await loadTanStackOutput(outputDir);
|
|
150
183
|
|
|
151
184
|
const assetsMap = buildAssetsMap(bundle, extractBuffer, getAssetType);
|
|
152
185
|
|
|
153
|
-
|
|
154
|
-
`[TanStack Zephyr] Uploading ${Object.keys(assetsMap).length} assets...`
|
|
155
|
-
);
|
|
186
|
+
ze_log.upload(`Uploading ${Object.keys(assetsMap).length} assets...`);
|
|
156
187
|
|
|
157
188
|
// Upload assets with SSR snapshot type
|
|
158
189
|
await zephyr_engine.upload_assets({
|
|
159
190
|
assetsMap,
|
|
160
191
|
buildStats: await zeBuildDashData(zephyr_engine),
|
|
161
192
|
snapshotType: 'ssr',
|
|
193
|
+
entrypoint,
|
|
162
194
|
});
|
|
163
195
|
|
|
164
196
|
// Finish build
|
|
@@ -167,10 +199,9 @@ export function withZephyrTanstackStart(
|
|
|
167
199
|
// Mark upload as completed to prevent multiple calls
|
|
168
200
|
uploadCompleted = true;
|
|
169
201
|
|
|
170
|
-
|
|
202
|
+
ze_log.upload('Deployment successful!');
|
|
171
203
|
} catch (error) {
|
|
172
|
-
|
|
173
|
-
throw error;
|
|
204
|
+
handleGlobalError(error);
|
|
174
205
|
}
|
|
175
206
|
},
|
|
176
207
|
};
|