Status: Proposed for v1.3.x
The current runtime compiler injects policy-derived config into auditable edge
templates with explicit marker comments such as // {{INJECT_CONFIG}}. The
compiler validates marker cardinality and parses generated output after
injection. That contract is stable and should remain the default for v1.3.0.
The next architecture question is how to support future plugin-provided runtime logic, for example custom auth gates, without turning generated edge code into unreviewable string concatenation.
Pros:
- Generated files remain close to source templates and easy to diff.
- CloudFront Function size and syntax constraints stay visible.
- No bundling step is required for the current CLI path.
Cons:
- It is a poor foundation for merging user-provided runtime modules.
- Config is injected as rendered source text, even with parse validation.
- It cannot perform module graph checks for plugin code.
Pros:
- Policy config can be exposed as a generated virtual module.
- Plugin/runtime code can import typed bindings rather than relying on global marker replacement.
- The bundle step catches syntax and module graph failures before deployment.
Cons:
- Output shape can change, including
constbecomingvarafter bundling. - Bundled code may be harder to audit than current templates.
- CloudFront Function size and compatibility need target-specific checks.
Pros:
- Can preserve more of the template output shape.
- Allows precise insertion of top-level declarations.
Cons:
- Adds AST manipulation complexity.
- Still needs separate module graph handling if plugins import dependencies.
Keep marker-based injection as the production default for v1.3.0.
Add an isolated esbuild virtual-module prototype to validate a future plugin-safe path. The prototype must not change CLI output. It exists to test these invariants:
- generated output parses
- config bindings appear exactly once at top level
- template/plugin source cannot shadow config bindings
- failures are surfaced before runtime deployment
The prototype specifically addresses:
- malformed generated edge runtime syntax
- duplicate generated config declarations
- plugin or template code shadowing generated config bindings
- accidental module graph failures before deployment
It does not yet address:
- malicious plugin package supply-chain risk
- semantic safety of arbitrary user code
- runtime resource exhaustion caused by plugin logic
- final CloudFront Function bundle-size enforcement
Those require a separate plugin permission and packaging model.
- Keep the current template injection contract.
- Maintain the isolated bundler prototype and tests.
- If custom runtime plugins become a product requirement, promote the prototype into a target-gated experimental emitter.
- Only replace marker injection for a target after output compatibility, auditability, size, and deployment behavior are proven.