Skip to content

Commit c6dff5a

Browse files
committed
Clarify built-in CSSX caching docs
1 parent b241636 commit c6dff5a

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

packages/babel-plugin-rn-stylename-to-style/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ so these files shouldn't frequently change.
131131

132132
**Default:** `undefined`
133133

134-
Whether to use integration with some caching library. Currently supported ones:
135-
- `"teamplay"`
134+
Legacy compatibility option. `"teamplay"` is still accepted for older configs,
135+
but style caching is owned by CSSX internally and does not require Teamplay or
136+
`observer()`.
136137

137138
#### `platform`
138139

packages/babel-plugin-rn-stylename-to-style/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ module.exports = function (babel) {
140140
const partStyle = styleHash[ROOT_STYLE_PROP_NAME]?.partStyle
141141
const inlineStyles = []
142142

143-
// Always process if 'observer' import is found in the file
144-
// which is needed for styles caching.
145-
// Otherwise, if no 'observer' found and no 'styleName' or 'part' found then skip
143+
// Keep old observer-triggered behavior for files that relied on cached
144+
// inline style prop normalization without styleName/part attributes.
145+
// Normal styleName handling does not require observer().
146146
if (!(hasObserver || styleName || partStyle)) return
147147

148148
// Check if styleName exists and if it can be processed
@@ -521,7 +521,8 @@ function buildDynamicPart (expr, part) {
521521
}
522522
}
523523

524-
// if cache is 'teamplay'
524+
// Legacy cache compatibility: observer imports still select the old
525+
// cssxjs/runtime/*-teamplay entrypoints, which now wrap the unified runtime.
525526
function checkObserverImport ($import, state) {
526527
const observerImports = state.opts.observerImports || DEFAULT_OBSERVER_IMPORTS
527528
const observerName = state.opts.observerName || DEFAULT_OBSERVER_NAME
@@ -587,8 +588,8 @@ function getRuntimePath ($node, state, hasObserver) {
587588
`Invalid cache option value: "${cache}". Supported values: ${OPTIONS_CACHE.join(', ')}`
588589
)
589590
}
590-
// If observer() is used in this file then we force cache to 'teamplay'
591-
// TODO: this is a bit of a hack, think of a better way to do this
591+
// Preserve the old import path shape for codebases that still use observer().
592+
// The runtime behind that path no longer imports Teamplay.
592593
if (!cache && hasObserver) cache = 'teamplay'
593594
const reactType = state.opts.reactType
594595
if (reactType && !OPTIONS_REACT_TYPES.includes(reactType)) {

packages/babel-preset-cssxjs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// On React Native this should be passed.
33
// reactType - force the React target platform (e.g. 'react-native', 'web'). Default: undefined.
44
// This shouldn't be needed in most cases since it will be automatically detected.
5-
// cache - force the CSS caching library instance (e.g. 'teamplay'). Default: undefined
6-
// This shouldn't be needed in most cases since it will be automatically detected.
5+
// cache - legacy compatibility option. 'teamplay' is still accepted but caching
6+
// is owned by cssxjs internally.
77
module.exports = (api, {
88
platform,
99
reactType,

0 commit comments

Comments
 (0)