Files
vercel__workflow/packages/builders/src/optional-ws-native.ts
Nathan Rajlich e1e64e3de3 docs: apply Vercel technical writing standards (#3704)
* docs: apply Vercel technical writing standards

Audit the complete documentation corpus, package READMEs, skills, and
source TSDoc/comments against the vercel-technical-writing skill and
style-rules.md. Normalize sentence-case headings without changing
published anchors, remove prose em dashes and filler wording, improve
active voice and self-contained phrasing, standardize product/brand
capitalization, American English, list punctuation, units, and code
fence languages, and preserve exact runtime strings/table placeholders.

All executable code is unchanged. Modified skills have their metadata
versions bumped.

* docs: extend writing audit to repository Markdown

Apply the same technical-writing rules to design documents, compiler
specifications, workbench guides, package changelogs, and the remaining
tracked Markdown outside the deployed docs corpus. Preserve historical
meaning, commands, output literals, table placeholders, and heading
anchors.

* docs: exclude generated package changelogs from audit
2026-08-21 14:24:31 -07:00

33 lines
1.7 KiB
TypeScript

/**
* `bufferutil` and `utf-8-validate` are optional native accelerators for the
* `ws` package, which `@workflow/world-vercel` uses for its WebSocket events
* transport. Neither is installed by default: `ws` requires each one inside a
* try/catch and falls back to a pure-JS implementation when the require throws.
*
* Marking them external keeps that fallback reachable. Two bundlers take it away
* without changing the build's outcome, so the damage only shows up at runtime,
* on the first frame big enough to reach the native masker (`ws` uses pure JS
* below 48 bytes, so small-payload smoke tests pass; CBOR event frames don't):
*
* - **webpack** bundles the JS wrapper without its native `.node` binding.
* - **Vite** resolves the absent peer to its own `optional-peer-dep` stub, so
* `ws`'s require *succeeds* and the try/catch never fires.
*
* Both end at `bufferUtil.mask is not a function`. Rollup-family setups are not
* known to break: nothing substitutes a stub, and nitro traces and externalizes
* `ws` in a production build, so the require stays a real one that fails and the
* fallback engages. Externalizing there buys determinism against a change in
* externals policy, not a fix for a known break. (Turbopack already externalizes
* Node packages.)
*
* Externalized unconditionally, unlike `WORKFLOW_OPTIONAL_OTEL_API_MODULE`,
* which is only externalized when it can't be resolved. The OTEL API has to
* load for tracing to work, so a self-contained output must bundle it when
* present; these accelerators must specifically *not* load, so a failed runtime
* require is the designed path and a half-bundled native module is not.
*/
export const WORKFLOW_OPTIONAL_WS_NATIVE_MODULES = [
'bufferutil',
'utf-8-validate',
] as const;