Merged in feat/sw-2871-booking-flow-envs (pull request #2483)

feat(SW-2871): Add env setup to booking-flow package

* Add env setup to booking-flow package

* Add missing dep

* Really fix it..


Approved-by: Linus Flood
This commit is contained in:
Anton Gunnarsson
2025-07-01 08:27:48 +00:00
parent c41b2314bf
commit 9426f4b1ac
4 changed files with 28 additions and 2 deletions

18
packages/booking-flow/env/server.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"
export const env = createEnv({
/**
* Due to t3-env only checking typeof window === "undefined"
* and Netlify running Deno, window is never "undefined"
* https://github.com/t3-oss/t3-env/issues/154
*/
isServer: typeof window === "undefined" || "Deno" in window,
server: {
FOO: z.string().optional(),
},
emptyStringAsUndefined: true,
runtimeEnv: {
FOO: process.env.FOO,
},
})

View File

@@ -1,9 +1,13 @@
import { Typography } from "@scandic-hotels/design-system/Typography" import { Typography } from "@scandic-hotels/design-system/Typography"
import { env } from "../env/server"
const tempEnv = env.FOO
export function Temp() { export function Temp() {
return ( return (
<Typography variant="Body/Lead text"> <Typography variant="Body/Lead text">
<p>Tjena</p> <p>Tjena {tempEnv}</p>
</Typography> </Typography>
) )
} }

View File

@@ -25,6 +25,7 @@
"@eslint/eslintrc": "^3.3.1", "@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.26.0", "@eslint/js": "^9.26.0",
"@scandic-hotels/typescript-config": "workspace:*", "@scandic-hotels/typescript-config": "workspace:*",
"@t3-oss/env-nextjs": "^0.13.4",
"@types/lodash-es": "^4", "@types/lodash-es": "^4",
"@types/react": "19.1.0", "@types/react": "19.1.0",
"@typescript-eslint/eslint-plugin": "^8.32.0", "@typescript-eslint/eslint-plugin": "^8.32.0",
@@ -34,6 +35,7 @@
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"typescript": "5.8.3", "typescript": "5.8.3",
"vitest": "^3.2.4" "vitest": "^3.2.4",
"zod": "^3.24.4"
} }
} }

View File

@@ -6776,6 +6776,7 @@ __metadata:
"@eslint/js": "npm:^9.26.0" "@eslint/js": "npm:^9.26.0"
"@scandic-hotels/common": "workspace:*" "@scandic-hotels/common": "workspace:*"
"@scandic-hotels/typescript-config": "workspace:*" "@scandic-hotels/typescript-config": "workspace:*"
"@t3-oss/env-nextjs": "npm:^0.13.4"
"@types/lodash-es": "npm:^4" "@types/lodash-es": "npm:^4"
"@types/react": "npm:19.1.0" "@types/react": "npm:19.1.0"
"@typescript-eslint/eslint-plugin": "npm:^8.32.0" "@typescript-eslint/eslint-plugin": "npm:^8.32.0"
@@ -6786,6 +6787,7 @@ __metadata:
eslint-plugin-simple-import-sort: "npm:^12.1.1" eslint-plugin-simple-import-sort: "npm:^12.1.1"
typescript: "npm:5.8.3" typescript: "npm:5.8.3"
vitest: "npm:^3.2.4" vitest: "npm:^3.2.4"
zod: "npm:^3.24.4"
peerDependencies: peerDependencies:
next: ^15 next: ^15
react: ^19 react: ^19