Skip to content

Commit

Permalink
process rules with unoptimizedPlugins only if available (#849)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinweser authored Jan 19, 2021
1 parent 0b0a203 commit 7278536
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/fela-utils/src/processStyleWithPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ export default function processStyleWithPlugins(
renderer: DOMRenderer | NativeRenderer,
style: Object,
type: StyleType,
props: Object = {}
props: Object = {},
plugins: Array<Function> = renderer.plugins
) {
if (renderer.plugins.length > 0) {
if (plugins.length > 0) {
return arrayReduce(
renderer.plugins,
plugins,
(processedStyle, plugin) => plugin(processedStyle, type, renderer, props),
style
)
Expand Down
7 changes: 5 additions & 2 deletions packages/fela/src/createRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ export default function createRenderer(
renderer,
style,
RULE_TYPE,
props
props,
renderer.unoptimizedPlugins || renderer.plugins
)

return renderer._renderStyleToClassNames(processedStyle).slice(1)
Expand Down Expand Up @@ -392,8 +393,10 @@ Check http://fela.js.org/docs/basics/Rules.html#styleobject for more information

// only enable the cache map if we have optimized plugins
if (renderer.optimizedPlugins.length > 0) {
renderer.plugins = renderer.plugins.filter((plugin) => !plugin.optimized)
renderer.cacheMap = {}
renderer.unoptimizedPlugins = renderer.plugins.filter(
(plugin) => !plugin.optimized
)
}
}

Expand Down

1 comment on commit 7278536

@vercel
Copy link

@vercel vercel bot commented on 7278536 Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.