Skip to content

Commit 95cbb1c

Browse files
authored
fix: generate global variables for published sites (#4932)
Another placed missed global variables support.
1 parent 9f23296 commit 95cbb1c

File tree

5 files changed

+49
-11
lines changed

5 files changed

+49
-11
lines changed

fixtures/webstudio-features/.webstudio/data.json

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"build": {
3-
"id": "3173a7d8-1af3-4e23-87fd-94c3b0cb1018",
3+
"id": "fce42d58-8a67-4f4b-8427-ea7500132e28",
44
"projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",
5-
"version": 474,
6-
"createdAt": "2025-01-22T17:59:53.714+00:00",
7-
"updatedAt": "2025-01-22T17:59:53.714+00:00",
5+
"version": 477,
6+
"createdAt": "2025-02-28T14:52:36.082+00:00",
7+
"updatedAt": "2025-02-28T14:52:36.082+00:00",
88
"pages": {
99
"meta": {
1010
"siteName": "KittyGuardedZone",
@@ -3214,6 +3214,19 @@
32143214
"scopeInstanceId": "1NipO5NmaHukA_dxzfVRF",
32153215
"name": "system"
32163216
}
3217+
],
3218+
[
3219+
"rKNaaGjEYnq4XPiTrSlfe",
3220+
{
3221+
"type": "variable",
3222+
"id": "rKNaaGjEYnq4XPiTrSlfe",
3223+
"scopeInstanceId": ":root",
3224+
"name": "globalVariable",
3225+
"value": {
3226+
"type": "string",
3227+
"value": "globalValue"
3228+
}
3229+
}
32173230
]
32183231
],
32193232
"resources": [
@@ -4294,6 +4307,10 @@
42944307
{
42954308
"type": "id",
42964309
"value": "sHn4Mh7DJ5X0RiETB-zVc"
4310+
},
4311+
{
4312+
"type": "id",
4313+
"value": "ABEvi07-c3_3dU6v4w-MS"
42974314
}
42984315
]
42994316
}
@@ -5136,6 +5153,20 @@
51365153
"label": "Link",
51375154
"children": []
51385155
}
5156+
],
5157+
[
5158+
"ABEvi07-c3_3dU6v4w-MS",
5159+
{
5160+
"type": "instance",
5161+
"id": "ABEvi07-c3_3dU6v4w-MS",
5162+
"component": "Box",
5163+
"children": [
5164+
{
5165+
"type": "expression",
5166+
"value": "$ws$dataSource$rKNaaGjEYnq4XPiTrSlfe"
5167+
}
5168+
]
5169+
}
51395170
]
51405171
],
51415172
"deployment": {

fixtures/webstudio-features/app/__generated__/$resources.sitemap.xml.ts

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-features/app/__generated__/[expressions]._index.tsx

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/webstudio-features/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dev": "react-router dev",
77
"cli": "NODE_OPTIONS='--conditions=webstudio --import=tsx' webstudio",
88
"fixtures:link": "pnpm cli link --link https://p-cddc1d44-af37-4cb6-a430-d300cf6f932d-dot-${BUILDER_HOST:-main.development.webstudio.is}'?authToken=1cdc6026-dd5b-4624-b89b-9bd45e9bcc3d'",
9-
"fixtures:sync": "pnpm cli sync --buildId 3173a7d8-1af3-4e23-87fd-94c3b0cb1018 && pnpm prettier --write ./.webstudio/",
9+
"fixtures:sync": "pnpm cli sync --buildId fce42d58-8a67-4f4b-8427-ea7500132e28 && pnpm prettier --write ./.webstudio/",
1010
"fixtures:build": "pnpm cli build --template react-router --template ./.template && pnpm prettier --write ./app/ ./package.json ./tsconfig.json"
1111
},
1212
"private": true,

packages/cli/src/prebuild.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
coreMetas,
4949
SYSTEM_VARIABLE_ID,
5050
generateCss,
51+
ROOT_INSTANCE_ID,
5152
} from "@webstudio-is/sdk";
5253
import type { Data } from "@webstudio-is/http-client";
5354
import { LOCAL_DATA_FILE } from "./config";
@@ -314,6 +315,8 @@ export const prebuild = async (options: {
314315
instanceMap,
315316
page.rootInstanceId
316317
);
318+
// support global data variables
319+
pageInstanceSet.add(ROOT_INSTANCE_ID);
317320
const instances: [Instance["id"], Instance][] =
318321
siteData.build.instances.filter(([id]) => pageInstanceSet.has(id));
319322
const dataSources: [DataSource["id"], DataSource][] = [];

0 commit comments

Comments
 (0)