refactor(loader): tighten the disabled gate and rehome the note

Address review: the gate module docstring now states the actual evaluation
contexts (config after injections against the plugin context, disabled at
every mount decision against the loader context); metadataExpressionErrors
rejects expressions nested below disabled and syntax-checks the disabled
expression itself so an unparseable gate fails at the gate instead of the
boot. The tutorial's !!js claims follow, and the loader note moves to
implemented/architecture with its inbound links retargeted.
This commit is contained in:
Huanqi Cao
2026-08-11 18:52:52 +08:00
parent 25329fcb79
commit e56b1ccab2
17 changed files with 75 additions and 25 deletions

View File

@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/cordis-tutorial/05-config.md
05-config.md: 2357f663135d6fc78a65f9d0952e0bc3f5eefae4
05-config.zh.md: fbd94d179494ad0b6f73baff2ca525c786cc9e33
05-config.md: 17cccce2ec43be65477ce527800ee6a636ee5d96
05-config.zh.md: 87f1cb465d5f3e52a6f8e449cfb29818ba86dcb8

View File

@@ -77,7 +77,7 @@ The loader used in this repo supports a `!!js` tag for config values that must b
greeting: !!js process.env.DEMO_GREETING ?? 'Hello'
```
`!!js` works **only inside `config`**. Entry metadata (`name`, `id`, `disabled`, `inject`, ...) is static; `disabled: !!js ...` produces a truthy expression object that always disables the entry. See [loader configuration](../cordis-primer.md#loader-configuration).
`!!js` works only inside `config` and in an entry's `disabled` field. `disabled: !!js ...` evaluates against the loader context at every mount decision (this repo's extension), so a row can gate itself on platform or environment; the other metadata (`name`, `id`, `inject`, ...) stays static, where an expression is ordinary truthy data. See [loader configuration](../cordis-primer.md#loader-configuration).
Next: [Composition and HMR](06-composition-and-hmr.md) — treating `cordis.yml` as the application.

View File

@@ -77,7 +77,7 @@ ValidationError: invalid config:
greeting: !!js process.env.DEMO_GREETING ?? 'Hello'
```
`!!js` **仅在 `config` 内有效**。Cordis 配置项的元数据(`name``id``disabled``inject` 等)是静态的;`disabled: !!js ...` 会生成一个真值表达式对象,始终禁用该 Cordis 配置项。详见 [loader 配置](../cordis-primer.md#loader-configuration)。
`!!js` 仅在 `config` 与条目 `disabled` 字段内有效。`disabled: !!js ...` 在每次挂载决策时基于 loader 上下文求值(本仓库的扩展),可以按平台或环境门控一行;其余元数据(`name``id``inject` 等)保持静态,其中的表达式是普通真值数据。详见 [loader 配置](../cordis-primer.md#loader-configuration)。
下一章:[组合与 HMR热模块替换](06-composition-and-hmr.md):将 `cordis.yml` 视为应用。