Skip to content

Commit d4fcc15

Browse files
authored
Merge branch 'v1' into draft_arkenv_tanstack_blog
2 parents 6cd7ca9 + 212554e commit d4fcc15

189 files changed

Lines changed: 10528 additions & 9511 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
"@arkenv/core": major
3+
"@arkenv/standard": major
4+
---
5+
6+
#### Move issue helpers and safe parsing off the default import
7+
8+
The default `@arkenv/core` and `@arkenv/standard` imports are now the throw
9+
path only. `formatIssues`, `getSchemaKeys`, and the `EnvIssue` types moved
10+
to `@arkenv/core/issues` (core). `{ safe: true }` is no longer accepted on
11+
either package's main `arkenv()`; import `arkenv` from `/safe` instead.
12+
13+
```ts
14+
import arkenv from "@arkenv/core";
15+
import { formatIssues } from "@arkenv/core/issues";
16+
import arkenvSafe from "@arkenv/core/safe";
17+
18+
export const env = arkenv({
19+
PORT: "number.port = 3000",
20+
});
21+
22+
const result = arkenvSafe(
23+
{ PORT: "number.port" },
24+
{ env: { PORT: "invalid" } },
25+
);
26+
27+
if (!result.success) {
28+
console.error(formatIssues(result.issues));
29+
}
30+
```
31+
32+
`@arkenv/standard` mirrors the same shape:
33+
34+
```ts
35+
import arkenv from "@arkenv/standard";
36+
import arkenvSafe from "@arkenv/standard/safe";
37+
```
38+
39+
`@arkenv/core` now sets `"sideEffects": false` so bundlers can tree-shake
40+
unused subpaths. Framework packages (Next.js, Nuxt, Vite, Bun) do **not**
41+
ship a `/safe` subpath.
42+
43+
**BREAKING CHANGE**: Issue helpers moved to `@arkenv/core/issues`.
44+
`{ safe: true }` on `arkenv()` is replaced by `arkenv` from
45+
`@arkenv/core/safe` / `@arkenv/standard/safe`.
46+
47+
```diff
48+
- import arkenv, { formatIssues } from "@arkenv/core";
49+
- const result = arkenv(schema, { safe: true });
50+
+ import arkenv from "@arkenv/core";
51+
+ import { formatIssues } from "@arkenv/core/issues";
52+
+ import arkenvSafe from "@arkenv/core/safe";
53+
+ const result = arkenvSafe(schema);
54+
```
55+
56+
```diff
57+
- import arkenv from "@arkenv/standard";
58+
- const result = arkenv(schema, { safe: true });
59+
+ import arkenv from "@arkenv/standard/safe";
60+
+ const result = arkenv(schema);
61+
```

.changeset/pre/rsbuild-plugin.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
"@arkenv/rsbuild-plugin": minor
3+
---
4+
5+
#### Add `@arkenv/rsbuild-plugin` for Rsbuild and TanStack Start
6+
7+
The new `@arkenv/rsbuild-plugin` brings the same server/client env path as `@arkenv/vite-plugin` to Rsbuild projects, including TanStack Start apps built with Rsbuild:
8+
9+
- **Client rewrite**: in `web` and `web-worker` environments, the `env.ts` module is replaced with a scrubbed client module — public/shared keys (default prefix `PUBLIC_`) are inlined as coerced literals and server-only keys become throwing getters, so secrets never reach the browser bundle.
10+
- **Server passthrough**: in `node` environments the real `env.ts` runs unchanged against the deployment environment.
11+
- **Build-time validation**: the schema is validated via `@arkenv/build` before each environment compiles; missing or invalid required variables fail the build before assets are emitted.
12+
- **Dev reload**: the schema and `.env*` files are registered as build dependencies, so edits re-validate and refresh inlined values during `rsbuild dev`.
13+
- **Standard Schema**: an `@arkenv/rsbuild-plugin/standard` entry mirrors the ArkType-free path of `@arkenv/vite-plugin/standard`.
14+
15+
Usage:
16+
17+
```ts
18+
// rsbuild.config.ts
19+
import { defineConfig } from "@rsbuild/core";
20+
import { arkenvPlugin } from "@arkenv/rsbuild-plugin";
21+
22+
export default defineConfig({
23+
plugins: [arkenvPlugin({ schemaPath: "src/env.ts" })],
24+
});
25+
```
26+
27+
Install with `npm install @arkenv/rsbuild-plugin arktype`.
File renamed without changes.

apps/playgrounds/solid-start/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ dist
33
.output
44
.vercel
55
.netlify
6-
.vinxi
7-
app.config.timestamp_*.js
86

97
# Environment
108
.env

apps/playgrounds/solid-start/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ export const env = arkenv({
2020
});
2121
```
2222

23-
```ts title="app.config.ts"
23+
```ts title="vite.config.ts"
2424
import arkenvVitePlugin from "@arkenv/vite-plugin";
25-
import { defineConfig } from "@solidjs/start/config";
25+
import { solidStart } from "@solidjs/start/config";
26+
import { nitro } from "nitro/vite";
27+
import { defineConfig } from "vite";
2628

2729
export default defineConfig({
28-
vite: {
29-
plugins: [arkenvVitePlugin()],
30-
},
30+
plugins: [solidStart(), nitro(), arkenvVitePlugin()],
3131
});
3232
```
3333

@@ -52,8 +52,8 @@ pnpm dev
5252
# Build for production
5353
pnpm build
5454

55-
# Start production server
56-
pnpm start
55+
# Locally preview production build
56+
pnpm preview
5757
```
5858

5959
## Documentation

apps/playgrounds/solid-start/app.config.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

apps/playgrounds/solid-start/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
"type": "module",
44
"private": true,
55
"scripts": {
6-
"dev": "vinxi dev",
7-
"build": "vinxi build",
8-
"start": "vinxi start"
6+
"dev": "vite dev",
7+
"build": "vite build",
8+
"preview": "vite preview"
99
},
1010
"dependencies": {
1111
"@arkenv/core": "workspace:*",
1212
"@arkenv/vite-plugin": "workspace:*",
13-
"@solidjs/start": "1.3.2",
13+
"@solidjs/start": "^2.0.4",
1414
"arktype": "catalog:",
15+
"nitro": "3.0.260903-beta",
1516
"solid-js": "1.9.12",
16-
"vinxi": "0.5.11"
17+
"vite": "8.0.10"
1718
},
1819
"engines": {
19-
"node": ">=22"
20+
"node": ">=24"
2021
},
2122
"arkenvExamples": [
2223
{

apps/playgrounds/solid-start/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"allowJs": true,
1111
"strict": true,
1212
"noEmit": true,
13-
"types": ["vinxi/types/client"],
13+
"types": ["@solidjs/start/env"],
1414
"isolatedModules": true,
1515
"paths": {
1616
"~/*": ["./src/*"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import arkenvVitePlugin from "@arkenv/vite-plugin";
2+
import { solidStart } from "@solidjs/start/config";
3+
import { nitro } from "nitro/vite";
4+
import { defineConfig } from "vite";
5+
6+
export default defineConfig({
7+
plugins: [solidStart(), nitro(), arkenvVitePlugin()],
8+
});

0 commit comments

Comments
 (0)