Repository navigation
Conversation
- Defining `__SOLID_ASYNC__` as `false` folds out the async arm of `handleAsync` and the thenable and `NotReadyError` paths of `recompute`. - Development throws when a computation returns a promise or async iterable with async off. - `scripts/size/bundle.mjs` reads `SIZE_DEFINE` to measure scenarios under an app's defines. Proof of concept for size measurements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 3de0ef5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
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.
Proof of concept: a compile-time flag,
__SOLID_ASYNC__, that lets an app's bundler drop the async arm of@solidjs/signals. Opened as a draft to get size numbers. It is not ready to merge.With
define: { __SOLID_ASYNC__: "false" }, every client size scenario loses 630 to 850 B brotli (1.8 to 2.2 KB minified). Without the define, behavior is unchanged and the bundle grows by 141 B minified.Changes
src/globals.d.tsdeclares__ASYNC__(internal) and__SOLID_ASYNC__(set by the app).rollup.config.jsreplaces__ASYNC__with(typeof __SOLID_ASYNC__ === "undefined" || __SOLID_ASYNC__). The shipped files work without a define and fold tofalsewith one.handleAsyncincore/async.tsreturns the result as a sync value when__ASYNC__is false. Its async arm becomes dead code. This covers every caller:recompute, store projections,deferred.tsandverdict.ts.recomputeincore/core.tsskips thehandleAsynccall and treats a thrownNotReadyErroras an ordinary error when__ASYNC__is false.checkAsyncDisabledincore/dev.tsthrows in development when a computation returns a promise or async iterable with async off.recomputeandhandleAsyncboth call it, so store projections are covered too.signals,diagnosticsandelementdefine__ASYNC__.SOLID_ASYNC=false pnpm testruns the signals suite with async off.scripts/size/bundle.mjsreadsSIZE_DEFINE(JSON) and passes it to Rolldown astransform.define.Measurements
node scripts/size/size.mjs --no-gateon macOS, Rolldown 1.2.11. Each value is the change frommain(caba92afb), in brotli bytes and minified bytes.mainbrotli"true""false"The other client scenarios fall in the same ranges. The
framesandserverscenarios do not change.To reproduce:
Two variants measured and not kept:
handleAsynconly. No define costs +47 B minified, and"false"saves 580 to 700 B brotli. The two guards inrecomputeadd about 150 B brotli of savings for +94 B of no-define cost.STATUS_PENDING = __ASYNC__ ? 1 : 0. It saves 0 B. Rolldown does not inline the exported constant across modules, so the roughly 140& STATUS_PENDINGtests stay.Proof
pnpm testinpackages/signalspasses (7322 tests). One run had a single failure that passed on the rerun.diagnostics(37 tests) andelement(11 tests) pass.SOLID_ASYNC=false pnpm testfails 3329 tests. Most failures are thecheckAsyncDisablederror from tests that use async. The suite has no sync-only subset yet, so the off mode has no passing proof.tsc -p tsconfig.build.jsonreports no errors.Cost
"true": 0 B.Risk
recomputeandhandleAsync, which every computation runs.main.NotReadyErrorwith async off.recomputetreats it as an error. Code that throws one by hand, outside the async paths, gets an error status instead of pending.@solidjs/routerloaders, breaks when the app defines"false".Not done
@solidjs/vite-pluginlives outside this repo. Anasync: falseoption would set the define for the client build, the SSR build andoptimizeDeps.Loading,isPending,latest,action,createOptimisticorrefresh.STATUS_PENDINGtests incore.ts,scheduler.tsandasync.tsstay. Removing them needs an__ASYNC__ &&guard at each site, or a build tier selected by an export condition.observetier, would cost 0 B by default. It doubles the prod and observe builds.🤖 Generated with Claude Code