Repository navigation
Import zod as a namespace everywhere and lint against the z import - #1541
Merged
Merged
Conversation
`import { z } from "zod"` binds zod's `z` namespace object, which carries
`locales`, so bundlers keep all 64 locale files. `import * as z` lets them
shake everything but the default English locale.
sidkmenon
approved these changes
Nov 12, 2026
thesiti92
enabled auto-merge (squash)
November 12, 2026 21:57
thesiti92
added a commit
that referenced
this pull request
Nov 13, 2026
…are-protocol 0.6.1 (#1542) Patch versions for the zod namespace imports in #1541, the only change to any of the three packages since 0.3.0, 0.2.0 and 0.6.0. Published builds stop pulling every zod locale into a consumer's bundle; the API is unchanged. board-protocol 0.2.1 declares whiteboard-document 0.3.1, so those two are published together. review-share-protocol is included because cloudboard's api Worker also bundles it, and one `{ z }` importer is enough to keep the locales. All three are already on npm, published from this branch.
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.
Problem
@dev.fast/whiteboard-documentand@dev.fast/board-protocolimport zod asimport { z } from "zod". In zod 4 that binds theznamespace object, which includesexport * as locales, so a consumer's bundler keeps all 64zod/v4/locales/*files. cloudboard's agents Worker carries about 267 KB of locales from these two packages alone; changing cloudboard's own imports did nothing while the packages still import{ z }.Measured with esbuild 0.28.1 (
--bundle --minify --format=esm) against zod 4.6.6, on a one-schema entry file:import { z } from "zod"import z from "zod"import * as z from "zod"enonly)import * as z from "zod/v4"object,string, ...)Change
import * as z from "zod"in every file in the repo that imported{ z }(118 files), not only the two published packages and@dev.fast/json. That includes tests, thediffrTypeScript packages,scripts/review-cli-release.mjsand the header the review-protocol generator writes for the Code OSS overlay. Import lines only; the API andz.infertypes are unchanged.A new local oxlint rule,
zod-imports/namespace(tools/oxlint/zod-imports), fails on theznamed import and the default import ofzodandzod/*. It is a custom rule because the built-inno-restricted-importscannot do this job here: withimportNamesit also rejectsimport * as z, and the four folder overrides that already setno-restricted-importsreplace a top-level entry.diffr/**is outside lint, so the rule does not cover it.AGENTS.mdnotes zod as the exception to "prefer named imports over namespace imports".Verification
Bundling each built
dist/index.jsthe same way:en)en)pnpm lintandpnpm format:checkpass, and the rule was probed in each override folder. Typecheck passes for every package exceptreview-desktopand@diffr/claude-code, which could not be checked locally (no Code OSSnode_modules, noclaude-codemodule). All test packages pass except three tests inpackages/reviewthat fail the same way onorigin/mainat 4404ef7:store-upgrade.test.ts(also the failure in this PR's first CI run),cli-install.test.tsandauthoring-capabilities.test.ts.Follow-up for consumers
Publish whiteboard-document and board-protocol together with bumped versions, then bump both pins in cloudboard (
apps/api,apps/web).