Skip to content

feat(dev): add a bundleable define entry point [Panda v2] - #3811

Merged
segunadebayo merged 5 commits into
chakra-ui:v2from
castrog:feat/dev-define-entrypoint-v2
Sep 15, 2026
Merged

segunadebayo merged 5 commits into
chakra-ui:v2from
castrog:feat/dev-define-entrypoint-v2

Conversation

@castrog

@castrog castrog commented Sep 10, 2026 •

Copy link
Copy Markdown

Summary

  • Add @pandacss/dev/define, a runtime-dependency-free entry point for config definition helpers.
  • Keep the existing @pandacss/dev exports unchanged.
  • Preserve flat and namespaced token helpers, including defineTokens.colors() and defineSemanticTokens.colors().
  • Mark token proxy initialization as pure so unused helpers can be removed when /define is bundled.
  • Document the publishing setup for v2 design-system packages.

Why

I use Panda definitions in a published design-system package. Importing helpers such as definePattern from @pandacss/dev can leave a runtime import when the package is externalized. Production SSR deployments that omit build-time tooling then fail with ERR_MODULE_NOT_FOUND.

Bundlers externalize modules rather than individual exports. The dedicated subpath gives library authors a stable module they can include with noExternal while leaving the rest of @pandacss/dev external.

This is the v2 companion to #3810. I kept it additive and limited to the package boundary; it does not change extraction or CSS output.

Verification

  • pnpm --filter @pandacss/dev build
  • pnpm test packages/dev
  • Prettier and git diff --check
  • Built a tsup consumer with noExternal: ['@pandacss/dev/define']; the 243-byte output had no remaining Panda imports and ran successfully in Node.

The tests also load the built package export through Node, rather than relying only on Vitest source aliases.

RetriggerConfidence Score: 4/5

The implementation appears safe to merge, with a non-blocking test-reliability issue around its dependency on pre-existing build output.

Fix All in Claude CodeFindings

  1. P2 Test Depends on Build Output ▶
Fix with agent prompt
### Issue 1
packages/dev/__tests__/define.test.ts:33-48
`pnpm test packages/dev` can fail on a clean checkout or validate stale output. This subprocess bypasses Vitest's source alias and resolves `@pandacss/dev/define` to the gitignored `dist/define.js`, but the test command does not build that file first. Build the entry during test setup or test an explicitly generated temporary package so this assertion always covers the current source.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

  • Preserves the existing root helper API through the new entry.
  • Adds package-export and token-helper coverage.
  • Marks token proxy initialization as removable when unused.
  • Documents the publishing configuration for bundled design-system definitions.
  • The built-export test should generate its own current output rather than depend on pre-existing dist files.

Reviews (1) · Last reviewed commit: "feat(dev): add a bundleable define entry..."

Allow published design systems to bundle configuration helpers without retaining a runtime dependency on @pandacss/dev.
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
panda-docs Ignored Ignored Preview Sep 15, 2026 10:24pm UTC

Request Review

@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

@castrog is attempting to deploy a commit to the Chakra UI Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 153f720

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@pandacss/dev Minor
@pandacss/spec-studio Minor
@pandacss/language-server Minor
@pandacss/typescript-plugin Minor
@pandacss/bun Minor
@pandacss/cli Minor
@pandacss/compiler-shared Minor
@pandacss/compiler-wasm Minor
@pandacss/compiler Minor
@pandacss/config Minor
@pandacss/eslint-plugin Minor
@pandacss/mcp Minor
@pandacss/postcss Minor
@pandacss/preset-base Minor
@pandacss/preset-panda Minor
@pandacss/preset-typography Minor
@pandacss/rollup Minor
@pandacss/transformer Minor
@pandacss/types Minor
@pandacss/vite Minor
@pandacss/webpack Minor
playground Patch
website Patch

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

@castrog castrog changed the title feat(dev): add a bundleable define entry point feat(dev): add a bundleable define entry point [Panda v2] Sep 10, 2026
Comment thread packages/dev/__tests__/define.test.ts Outdated
castrog and others added 4 commits September 10, 2026 16:05
Generate the package export fixture in a temporary directory so the test cannot depend on missing or stale dist output.
Three of the four tests didn't pull their weight. `preserves root helper
exports` asserted `a === b` across `export * from './define'`, so it could
never fail. The two token tests covered `createProxy` in src/config.ts, which
this PR doesn't change, and duplicated each other's shape.

The remaining test is the one that can catch a real break: it builds
src/define.ts and loads it through the package's `exports` map in a real Node
process, so a bad export entry or a missing build target shows up.
The docs told you to bundle `@pandacss/dev/define` but never said what breaks
if you don't, or why the subpath matters over the bare package name.

Name the failure: skip the bundling step and your published JavaScript keeps
a runtime import of `@pandacss/dev`, which dies in production with
ERR_MODULE_NOT_FOUND once an app installs Panda as a dev dependency.

Say why the subpath exists: `noExternal` matches whole packages, so
`noExternal: ['@pandacss/dev']` also inlines `@pandacss/config` and
`@pandacss/compiler-shared` when the build touches `@pandacss/dev/node`.

The README entry called `/define` runtime-dependency-free, which describes
the root entry just as well — both resolve to the same dependency-free
module. The difference is that `/define` is separately addressable.
Despite its name it never loaded the published entry point. It ran its own
tsup build of src/define.ts with --format esm --no-splitting --no-config,
while the real build is --format=esm,cjs --splitting --cjsInterop --dts. A
break in the shipped artifact would not have failed it.

That bought 55 lines of mkdtemp, a synthetic package.json, two execFileSync
calls and an inline --eval, to assert two identity functions return their
argument. packages/dev goes back to having no tests, which is where it was
before this branch.
@segunadebayo
segunadebayo merged commit 49d48c2 into chakra-ui:v2 Sep 15, 2026
4 of 7 checks passed
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