Skip to content

Commit 949e9cf

Browse files
authored
fix(webapp): show the real app version instead of v0.0.0 in organization settings (#4611)
## Summary Since the move from the Remix compiler to Vite ([#4188](#4188)), the "App version" on the organization settings page shows `v0.0.0` unless the image was built from a semver release tag (which bakes in `BUILD_APP_VERSION`). Self-hosted builds and any image built from `main` are affected. This restores the real version. ## Root cause The Vite SSR bundle resolves workspace packages to TS source via the `@triggerdotdev/source` condition, so `@trigger.dev/core`'s `VERSION` constant is bundled as its raw `"0.0.0"` placeholder. `scripts/updateVersion.ts` still stamps the real version at build time, but only into the packages' dist output, which the bundle no longer reads. The old Remix compiler bundled the stamped dist, which is why this used to work. The fix is a small Vite plugin that applies the same substitution to the source version modules of `@trigger.dev/core` and `@trigger.dev/sdk` during bundling. Beyond the settings page, this also restores real values in the `trigger-version` request header and the version attributes the bundled packages emit. Verified by building the server bundle and confirming the VERSION constants carry the package versions, with no `"0.0.0"` occurrences left in the build output.
1 parent 3e7964e commit 949e9cf

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: fix
4+
---
5+
6+
The app version shown on the organization settings page now reports the real version instead of v0.0.0.

apps/webapp/vite.config.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
1+
import { readFileSync } from "node:fs";
12
import { vitePlugin as remix } from "@remix-run/dev";
2-
import { defaultClientConditions, defaultServerConditions, defineConfig } from "vite";
3+
import { defaultClientConditions, defaultServerConditions, defineConfig, type Plugin } from "vite";
34
import tsconfigPaths from "vite-tsconfig-paths";
45

6+
const packageVersions: Record<string, string> = Object.fromEntries(
7+
["core", "trigger-sdk"].map((pkg) => [
8+
pkg,
9+
(
10+
JSON.parse(
11+
readFileSync(new URL(`../../packages/${pkg}/package.json`, import.meta.url), "utf-8")
12+
) as { version: string }
13+
).version,
14+
])
15+
);
16+
17+
/**
18+
* The `@triggerdotdev/source` condition resolves workspace packages to TS source, where
19+
* each VERSION constant is the "0.0.0" placeholder (scripts/updateVersion.ts stamps the
20+
* real version, but only in dist output, which this bundle never reads). Stamp the version
21+
* modules during bundling so VERSION carries the real package version everywhere it's used.
22+
*/
23+
function stampPackageVersions(): Plugin {
24+
return {
25+
name: "stamp-package-versions",
26+
transform(code, id) {
27+
const match = id
28+
.split("?")[0]
29+
.match(/packages[/\\](core|trigger-sdk)[/\\]src[/\\]version\.ts$/);
30+
if (match) {
31+
return {
32+
code: code.replace('"0.0.0"', JSON.stringify(packageVersions[match[1]])),
33+
map: null,
34+
};
35+
}
36+
},
37+
};
38+
}
39+
540
export default defineConfig({
641
plugins: [
742
remix({
@@ -10,6 +45,7 @@ export default defineConfig({
1045
serverBuildFile: "index.mjs",
1146
}),
1247
tsconfigPaths(),
48+
stampPackageVersions(),
1349
],
1450
resolve: {
1551
// Resolve workspace packages to TS source (same condition the CLI uses)

0 commit comments

Comments
 (0)