Skip to content

Commit

Permalink
Perf: Fixed extending preset configurations repeatedly
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed May 24, 2024
1 parent 0ba8c47 commit 5e79fc6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class MasterCSS {
readonly Rules: RegisteredRule[] = []

constructor(
public customConfig: Config = defaultConfig
public customConfig?: Config
) {
if (!customConfig?.override) {
this.config = extendConfig(defaultConfig, customConfig)
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/utils/extend-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import extend from '@techor/extend'
import type { AnimationDefinitions, Config } from '../config'

export default function extendConfig(...configs: Config[]) {
export default function extendConfig(...configs: (Config | undefined)[]) {
const formatConfig = (config: Config) => {
const clonedConfig: Config = extend({}, config)
const formatDeeply = (obj: Record<string, any>) => {
Expand All @@ -28,6 +28,7 @@ export default function extendConfig(...configs: Config[]) {

const formattedConfigs: Config[] = []
for (const eachConfig of configs) {
if (!eachConfig) continue
(function getConfigsDeeply(config: Config) {
if (config.extends?.length) {
for (const eachExtend of config.extends) {
Expand Down

0 comments on commit 5e79fc6

Please sign in to comment.