alloc / alloc/saus

[RFC] Option-driven tree-shaking toggles

オープン
#74 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
proposal roadmap
主要言語
TypeScript
スター
38
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

## The Problem

There's no simple way to include code in client/server bundle only when a specific plugin/framework option has a specific value at build time.

### Example

In any Vite-compiled module:

```ts
// @toggle foo
callSomeFunction(...args)
```

The `foo` toggle should be registered with Saus **at build time:**

```ts
export function MySausPlugin(options) {
return {
name: 'my-saus-plugin',
saus({ toggles }) {
// The `foo` option of my plugin decides if "foo" toggle is removed.
if (options.foo) {
toggles.use("foo")
}
}
}
}
```

In the above example, if the `foo` option of `MySausPlugin` is falsy, the `callSomeFunction` line is removed at build time.

Ideally, plugins would use namespaces in their toggle IDs:

```ts
// @toggle my-saus-plugin.foo
callSomeFunction(...args)
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。