alloc / alloc/saus

Add compile-time evaluation

未關閉
#46 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement roadmap
主要語言
TypeScript
星號
38
分支
1
PR 合併指標
30 天內沒有已合併 PR

描述

Useful for compile-time data generation used in declaring routes, paths, etc.

```ts
// src/node/routes.ts
import { preval } from 'saus'

// Run this module at compile-time. Unwrap its default export. Top-level await is allowed.
const result = preval(import('./path/to/module'))
```

In the future, we could support inline function that references outside its scope.
```ts
// src/node/routes.ts
import { preval } from 'saus'
import fs from 'fs'

const result = preval(() => {
return fs.readdirSync('./data')
})
```

…or even a simple expression:
```ts
// src/node/routes.ts
import { preval } from 'saus'
import fs from 'fs'

const result = preval(fs.readdirSync('./data'))
```

The result would be passed through our `dataToEsm` helper.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。