Skip to content

feat(rsc): expose directive function validation - #1412

Draft
hi-ogawa wants to merge 13 commits into
mainfrom
fix/issue-1335
Draft

feat(rsc): expose directive function validation#1412
hi-ogawa wants to merge 13 commits into
mainfrom
fix/issue-1335

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

TODO

Inline and file directive transforms expose their source value through meta.valueNode, but integrations currently need to reimplement the Next.js restrictions around this, super, and arguments. Baking those checks into generic hoist and export transforms would also impose Server Function policy on unrelated consumers.

This PR exposes validateDirectiveFunction so directive owners can compose the checks through their existing runtime or generate callbacks. It wires the built-in "use server" transform and maintained custom/"use cache" examples while leaving generic transforms unchanged. Validation covers direct file exports available through current valueNode metadata; local identifier export resolution remains separate following #1380.

hi-ogawa and others added 13 commits August 6, 2026 16:14
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
@hi-ogawa hi-ogawa changed the title feat(rsc): support inline directive methods feat(rsc): expose directive function validation Aug 6, 2026
Comment on lines +15 to +20
/**
* Applies the function restrictions used by Next.js Server Functions.
* Unknown and non-function values are ignored so transform callbacks can pass
* `meta.valueNode` directly.
*/
export function validateDirectiveFunction(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: next.js reference

Comment on lines +44 to +47
const wrap = (value: string, name: string, meta: ModuleExportMeta) => {
validateDirectiveFunction(meta.valueNode, directive)
return runtime(value, name, getCacheWrapperOptions(meta))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. just unify wrap and runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant