Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
feat: support dynamic config (#17)
Browse files Browse the repository at this point in the history
* feat: support dynamic config

* chore: changeset
  • Loading branch information
sor4chi authored Apr 16, 2024
1 parent fd1a521 commit 8b35704
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .changeset/cold-camels-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"twrangler": patch
---

dynamic config supports.

```ts
export default defineConfig(() => {
return {
name: "sumple-worker",
// ...
};
});
```
4 changes: 2 additions & 2 deletions packages/schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export const configSchema = nonInheritableKeysSchema

export type Config = z.infer<typeof configSchema>;

export function defineConfig(config: Config): Config {
return config;
export function defineConfig(config: Config | (() => Config)): Config {
return typeof config === "function" ? config() : config;
}

0 comments on commit 8b35704

Please sign in to comment.