vite-plugin-tanstack-start-zephyr 0.0.0-canary.27 → 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 +6 -2
- package/dist/lib/vite-plugin-tanstack-start-zephyr.js +29 -13
- 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 +42 -20
|
@@ -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"}
|
|
@@ -11,8 +11,12 @@ export interface TanStackStartZephyrOptions {
|
|
|
11
11
|
*/
|
|
12
12
|
outputDir?: string;
|
|
13
13
|
/**
|
|
14
|
-
* Server entry file path for SSR
|
|
15
|
-
*
|
|
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`.
|
|
16
20
|
*/
|
|
17
21
|
entrypoint?: string;
|
|
18
22
|
}
|
|
@@ -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
|
*
|
|
@@ -60,9 +77,7 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
60
77
|
// For TanStack Start, always use the root dist directory (contains server/ and client/)
|
|
61
78
|
// Don't use config.build.outDir as it points to dist/server/ during SSR build
|
|
62
79
|
outputDir = options.outputDir || path.join(config.root, 'dist');
|
|
63
|
-
entrypoint = options.entrypoint || '
|
|
64
|
-
console.log(`[TanStack Zephyr] Output directory: ${outputDir}`);
|
|
65
|
-
console.log(`[TanStack Zephyr] Server entrypoint: ${entrypoint}`);
|
|
80
|
+
entrypoint = normalizeEntrypoint(options.entrypoint || 'server/index.js');
|
|
66
81
|
},
|
|
67
82
|
async buildApp(builder) {
|
|
68
83
|
// Guard: Only process upload once, even if buildApp is called multiple times
|
|
@@ -80,17 +95,14 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
80
95
|
const zephyr_engine = await zephyr_engine_defer;
|
|
81
96
|
// Log all environments and their build status for debugging
|
|
82
97
|
const environments = Object.entries(builder.environments);
|
|
83
|
-
|
|
84
|
-
for (const [name, env] of environments) {
|
|
85
|
-
console.log(` - ${name}: isBuilt=${env.isBuilt}`);
|
|
86
|
-
}
|
|
98
|
+
zephyr_agent_1.ze_log.init(`buildApp hook called with ${environments.length} environment(s): ${environments.map(([name, env]) => `${name}(isBuilt=${env.isBuilt})`).join(', ')}`);
|
|
87
99
|
// Wait for all environments to be built (not just specific ones)
|
|
88
100
|
// This ensures we have all build outputs before uploading
|
|
89
101
|
const notBuilt = Object.entries(builder.environments)
|
|
90
102
|
.filter(([, env]) => !env.isBuilt)
|
|
91
103
|
.map(([name]) => name);
|
|
92
104
|
if (notBuilt.length > 0) {
|
|
93
|
-
|
|
105
|
+
zephyr_agent_1.ze_log.init(`Building environments that aren't built yet: ${notBuilt.join(', ')}`);
|
|
94
106
|
for (const envName of notBuilt) {
|
|
95
107
|
const env = builder.environments[envName];
|
|
96
108
|
if (env) {
|
|
@@ -108,15 +120,20 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
108
120
|
message: `Some environments are still not built: ${stillNotBuilt.join(', ')}`,
|
|
109
121
|
});
|
|
110
122
|
}
|
|
111
|
-
|
|
123
|
+
zephyr_agent_1.ze_log.upload('All environments built, processing output...');
|
|
112
124
|
try {
|
|
113
125
|
// Engine is already initialized above, and ZephyrEngine.create() automatically calls start_new_build()
|
|
114
126
|
// So we don't need to call start_new_build() again here
|
|
115
127
|
// Load ALL build output preserving directory structure
|
|
116
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.
|
|
117
134
|
const bundle = await (0, load_tanstack_output_1.loadTanStackOutput)(outputDir);
|
|
118
135
|
const assetsMap = (0, zephyr_agent_1.buildAssetsMap)(bundle, extractBuffer, getAssetType);
|
|
119
|
-
|
|
136
|
+
zephyr_agent_1.ze_log.upload(`Uploading ${Object.keys(assetsMap).length} assets...`);
|
|
120
137
|
// Upload assets with SSR snapshot type
|
|
121
138
|
await zephyr_engine.upload_assets({
|
|
122
139
|
assetsMap,
|
|
@@ -128,11 +145,10 @@ function withZephyrTanstackStart(options = {}) {
|
|
|
128
145
|
await zephyr_engine.build_finished();
|
|
129
146
|
// Mark upload as completed to prevent multiple calls
|
|
130
147
|
uploadCompleted = true;
|
|
131
|
-
|
|
148
|
+
zephyr_agent_1.ze_log.upload('Deployment successful!');
|
|
132
149
|
}
|
|
133
150
|
catch (error) {
|
|
134
|
-
|
|
135
|
-
throw error;
|
|
151
|
+
(0, zephyr_agent_1.handleGlobalError)(error);
|
|
136
152
|
}
|
|
137
153
|
},
|
|
138
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;QAC1B,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;SAAM,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACjC,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QA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ACF,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',
|
|
@@ -53,12 +56,35 @@ export interface TanStackStartZephyrOptions {
|
|
|
53
56
|
*/
|
|
54
57
|
outputDir?: string;
|
|
55
58
|
/**
|
|
56
|
-
* Server entry file path for SSR
|
|
57
|
-
*
|
|
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`.
|
|
58
65
|
*/
|
|
59
66
|
entrypoint?: string;
|
|
60
67
|
}
|
|
61
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;
|
|
86
|
+
}
|
|
87
|
+
|
|
62
88
|
/**
|
|
63
89
|
* Main Vite plugin for TanStack Start Zephyr deployment
|
|
64
90
|
*
|
|
@@ -87,10 +113,7 @@ export function withZephyrTanstackStart(
|
|
|
87
113
|
// For TanStack Start, always use the root dist directory (contains server/ and client/)
|
|
88
114
|
// Don't use config.build.outDir as it points to dist/server/ during SSR build
|
|
89
115
|
outputDir = options.outputDir || path.join(config.root, 'dist');
|
|
90
|
-
entrypoint = options.entrypoint || '
|
|
91
|
-
|
|
92
|
-
console.log(`[TanStack Zephyr] Output directory: ${outputDir}`);
|
|
93
|
-
console.log(`[TanStack Zephyr] Server entrypoint: ${entrypoint}`);
|
|
116
|
+
entrypoint = normalizeEntrypoint(options.entrypoint || 'server/index.js');
|
|
94
117
|
},
|
|
95
118
|
|
|
96
119
|
async buildApp(builder) {
|
|
@@ -110,12 +133,9 @@ export function withZephyrTanstackStart(
|
|
|
110
133
|
const zephyr_engine = await zephyr_engine_defer;
|
|
111
134
|
// Log all environments and their build status for debugging
|
|
112
135
|
const environments = Object.entries(builder.environments);
|
|
113
|
-
|
|
114
|
-
`
|
|
136
|
+
ze_log.init(
|
|
137
|
+
`buildApp hook called with ${environments.length} environment(s): ${environments.map(([name, env]) => `${name}(isBuilt=${env.isBuilt})`).join(', ')}`
|
|
115
138
|
);
|
|
116
|
-
for (const [name, env] of environments) {
|
|
117
|
-
console.log(` - ${name}: isBuilt=${env.isBuilt}`);
|
|
118
|
-
}
|
|
119
139
|
|
|
120
140
|
// Wait for all environments to be built (not just specific ones)
|
|
121
141
|
// This ensures we have all build outputs before uploading
|
|
@@ -124,8 +144,8 @@ export function withZephyrTanstackStart(
|
|
|
124
144
|
.map(([name]) => name);
|
|
125
145
|
|
|
126
146
|
if (notBuilt.length > 0) {
|
|
127
|
-
|
|
128
|
-
`
|
|
147
|
+
ze_log.init(
|
|
148
|
+
`Building environments that aren't built yet: ${notBuilt.join(', ')}`
|
|
129
149
|
);
|
|
130
150
|
for (const envName of notBuilt) {
|
|
131
151
|
const env = builder.environments[envName];
|
|
@@ -146,7 +166,7 @@ export function withZephyrTanstackStart(
|
|
|
146
166
|
});
|
|
147
167
|
}
|
|
148
168
|
|
|
149
|
-
|
|
169
|
+
ze_log.upload('All environments built, processing output...');
|
|
150
170
|
|
|
151
171
|
try {
|
|
152
172
|
// Engine is already initialized above, and ZephyrEngine.create() automatically calls start_new_build()
|
|
@@ -154,13 +174,16 @@ export function withZephyrTanstackStart(
|
|
|
154
174
|
|
|
155
175
|
// Load ALL build output preserving directory structure
|
|
156
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.
|
|
157
182
|
const bundle = await loadTanStackOutput(outputDir);
|
|
158
183
|
|
|
159
184
|
const assetsMap = buildAssetsMap(bundle, extractBuffer, getAssetType);
|
|
160
185
|
|
|
161
|
-
|
|
162
|
-
`[TanStack Zephyr] Uploading ${Object.keys(assetsMap).length} assets...`
|
|
163
|
-
);
|
|
186
|
+
ze_log.upload(`Uploading ${Object.keys(assetsMap).length} assets...`);
|
|
164
187
|
|
|
165
188
|
// Upload assets with SSR snapshot type
|
|
166
189
|
await zephyr_engine.upload_assets({
|
|
@@ -176,10 +199,9 @@ export function withZephyrTanstackStart(
|
|
|
176
199
|
// Mark upload as completed to prevent multiple calls
|
|
177
200
|
uploadCompleted = true;
|
|
178
201
|
|
|
179
|
-
|
|
202
|
+
ze_log.upload('Deployment successful!');
|
|
180
203
|
} catch (error) {
|
|
181
|
-
|
|
182
|
-
throw error;
|
|
204
|
+
handleGlobalError(error);
|
|
183
205
|
}
|
|
184
206
|
},
|
|
185
207
|
};
|