Repository navigation
feat: call composables and compile .uf.ts modules - #74
Merged
Merged
Conversation
A component imports a .uf.ts module's composables, resolved like a child,
and calls each at the top level of its setup with const { … } = useX(…),
which lowers to a Use item: each argument as its parameter's kind reads
it, each member a used* binding of the member's kind. A write of a
returned ref is UF2036, and a reactive read passed to a value parameter
UF2007.
compile() takes a .uf.ts source and calls each target's emitComposable,
optional in codegen's Target until each target's composables lane: a
target without it reports UF1002 for the composable. The resolver gives
a .uf.ts module's composables, and CompileResult.dependencies lists them.
The unplugin loads a .uf.ts file under each target's composable id.
The analyser's corpus test reads a case's .uf.ts modules, and a fixture
root proves it.
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://composable-calls-uxf-461-unframework.blue-water-0397.workers.dev (commit cdce535)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
A local function that calls a returned function the API doesn't mark pure is impure too (UF2014). A returned ref passed to watch is watched through a getter of its value, with a safe fix (UF2020). The unplugin leaves Vite's file queries on an authored .uf.ts to Vite, and fails the authored file loudly on Svelte and Angular, whose ids have a suffix. The analyser's README describes the call site. Co-authored-by: multica-agent <github@multica.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
A component can now call a composable from a
.uf.tsmodule, andcompile()takes a.uf.tssource. No target emits a composable or its call yet: each target's composables lane adds that, so every framework's output is unchanged..uf.tsmodule resolves like a child's, through the compiler's resolver.const { on, toggle } = useToggle(false)at the top level of the setup lowers to aUseitem. Each argument is read as its parameter's kind says (a value once, a getter as acomputed's, a callback as client code), and each member becomes aused*binding of the member's kind. Writing a returned ref is UF2036. A reactive read passed to a value parameter is UF2007, a warning. A template or getter that calls a returned function the API doesn't mark pure is UF2014. A call in any other form is UF1002..uf.tsmodule's API with itscomposables.compile()calls each target'semitComposable, whichcodegen'sTargetgains as an optional method. A target without it reports UF1002 for the composable.CompileResult.dependencieslists the.uf.tsmodules a source imports, andownersnames a composable's files..uf.tsfile under each target's composable id (/abs/useToggle.uf.ts, with.svelte.tsadded on Svelte and.tson Angular). It resolves an output's import of a composable's output to that id..uf.tsmodules and takes a root. Two fixture cases underpackages/analyzer/test/fixtures/casesprove both.Checklist
feat(web): sell the next framework on the homepage.pnpm format:check,pnpm lint,pnpm check-typesandpnpm testpass. The first three passed. The integration suite and the analyser, compiler, unplugin, codegen, repo, target, testing and umbrella tests passed; the wholepnpm testdid not run.pnpm changeset(see.changeset/README.md).pnpm build, thenpnpm --filter web lighthouse, still scores at least 0.95 in every category.