Add compile-time evaluation
- 主要语言
- 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 还没有评估数据。