Skip to content

Commit

Permalink
BREAKING: add preset name mandatory key (#2372)
Browse files Browse the repository at this point in the history
* BREAKING: add preset `name` mandatory key

* chore: add implicit name to panda.config & fix tests

* refactor: simplify mergeConfigs
it now follows a left-to-right order just like in the config.presets, making it much easier to reason about

* chore: add name to playground preset

* chore: update playground resolve config logic

* chore: tsc & lint

* fix: rebase conflict
  • Loading branch information
astahmer authored Jul 22, 2024
1 parent a8c0cde commit c99cb75
Show file tree
Hide file tree
Showing 20 changed files with 790 additions and 315 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-crews-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandacss/types': minor
---

Add a `name` mandatory key in `Preset` to make it easy to target one specifically
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type {
* -----------------------------------------------------------------------------*/

export function defineConfig(config: Config) {
return config
return Object.assign(config, { name: '__panda.config__' })
}

export function defineRecipe<T extends RecipeVariantRecord>(config: RecipeConfig<T>): RecipeConfig {
Expand Down
11 changes: 11 additions & 0 deletions packages/config/__tests__/bundle-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down Expand Up @@ -58,6 +59,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down Expand Up @@ -98,10 +100,12 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
{
"name": "ts-import-preset",
"theme": {
"extend": {
"semanticTokens": {
Expand All @@ -127,6 +131,7 @@ describe('bundle config', () => {
},
{
"requiredPreset": {
"name": "required-preset",
"theme": {
"extend": {
"semanticTokens": {
Expand Down Expand Up @@ -184,6 +189,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down Expand Up @@ -224,6 +230,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down Expand Up @@ -264,6 +271,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down Expand Up @@ -304,6 +312,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down Expand Up @@ -344,6 +353,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down Expand Up @@ -384,6 +394,7 @@ describe('bundle config', () => {
"./src/**/*.{ts,tsx,jsx}",
],
"jsxFramework": "react",
"name": "__panda.config__",
"preflight": true,
"presets": [
"@pandacss/dev/presets",
Expand Down
Loading

0 comments on commit c99cb75

Please sign in to comment.