Skip to content

Commit

Permalink
Automatic component dependencies registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezystem committed Dec 6, 2023
1 parent a7847de commit a934a24
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/mjml-core/src/components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { kebabCase } from 'lodash'
import { registerDependencies } from "mjml-validator";

Check failure on line 2 in packages/mjml-core/src/components.js

View workflow job for this annotation

GitHub Actions / build (10.x)

Extra semicolon

Check failure on line 2 in packages/mjml-core/src/components.js

View workflow job for this annotation

GitHub Actions / build (12.x)

Extra semicolon

Check failure on line 2 in packages/mjml-core/src/components.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Extra semicolon

const components = {}

Expand All @@ -8,8 +9,12 @@ export function assignComponents(target, source) {
}
}

export function registerComponent(Component) {
export function registerComponent(Component, options = {}) {
assignComponents(components, [Component])

if (Component.dependencies && options.registerDependencies) {
registerDependencies(Component.dependencies)
}
}

export default components

0 comments on commit a934a24

Please sign in to comment.