Skip to content

Comments

Add Zod wildcard import best practice for tree-shaking#128

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-zod-react-best-practice-rule
Draft

Add Zod wildcard import best practice for tree-shaking#128
Copilot wants to merge 2 commits intomainfrom
copilot/add-zod-react-best-practice-rule

Conversation

Copy link

Copilot AI commented Feb 2, 2026

Zod PR #4569 documents that wildcard imports (import * as z from "zod") enable proper tree-shaking in Webpack/Next.js and esbuild, while named imports (import { z } from "zod") prevent unused code elimination in these bundlers.

Changes

  • New rule: bundle-zod-wildcard-import.md under Bundle Size Optimization (section 2.6)
  • Updated: SKILL.md quick reference and AGENTS.md compiled documentation
  • Rule count: 57 → 58

Example

// ❌ Not tree-shakable by Webpack/esbuild
import { z } from 'zod'

// ✅ Tree-shakable across all bundlers
import * as z from 'zod'

const userSchema = z.object({
  name: z.string(),
  email: z.string().email()
})

Rollup handles both patterns, but Webpack (including Next.js) and esbuild require the wildcard pattern to properly exclude unused validators, locales, and internal utilities.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • zod.dev
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Add colinhacks/zod#4569 as a react best practice rule


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-agent-skills-ns Error Error Open in v0 Feb 2, 2026 10:35am

Co-authored-by: shuding <3676859+shuding@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Zod as a React best practice rule Add Zod wildcard import best practice for tree-shaking Feb 2, 2026
Copilot AI requested a review from shuding February 2, 2026 10:37
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.

2 participants