alloc / alloc/saus

Add compile-time evaluation

オープン
#46 コメント 0 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。