Skip to content

Commit 72a3bb2

Browse files
committed
fix(webapp): show the real app version instead of v0.0.0 in organization settings
The Vite SSR bundle resolves workspace packages to TS source, where the VERSION constant is the unstamped 0.0.0 placeholder; the stamping script only patches dist output, which the bundle never reads. A small Vite plugin now performs the same substitution on the source version modules of core and trigger-sdk during bundling, so the settings page and the version headers the webapp sends carry the real version again.
1 parent 1114d9d commit 72a3bb2

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)