Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add preprocessors #1043

Merged
merged 1 commit into from
Nov 28, 2023
Merged

feat: add preprocessors #1043

merged 1 commit into from
Nov 28, 2023

Conversation

jorenbroekema
Copy link
Collaborator

@jorenbroekema jorenbroekema commented Nov 2, 2023

Sometimes it makes sense to process the dictionary after it has been created from merging the parsed input files together into one JS object.
For example, when more complicated and broad transformations have to be done in order for things like references to work, metadata to be deleted, etc.

In the past, I've used custom parsers to parse design token files from Tokens Studio, but we ran into issues with cross-file references, which at the parser lifecycle cannot be resolved and transformed, because the parsers work on single input files one by one. I think that totally makes sense for parsers, I wouldn't change that, but instead I think it makes sense to introduce this preprocessor lifecycle hook to deal with use cases like this.

TODO:

  • tests
  • example (one under advanced to delete metadata or something, should do)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Member

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

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

Just one small thing, but overall looks good!

types/index.d.ts Outdated Show resolved Hide resolved
@jorenbroekema jorenbroekema changed the base branch from v4 to fix-tests November 27, 2023 10:54
@jorenbroekema jorenbroekema force-pushed the preprocessors branch 3 times, most recently from b60a442 to c222e47 Compare November 27, 2023 12:11
@jorenbroekema
Copy link
Collaborator Author

jorenbroekema commented Nov 27, 2023

@dbanksdesign this needs another review, I've rebased to the branch that has all tests fixed (and also contains some refactors and API changes that affect this PR). I also changed the API of preprocessors to be aligned with formats, transforms, fileheader etc. which just means you register it with a name property, I think this is better API design, helps with indexing and debugging preprocessors if multiple are used.

I'm also going to add a task to the v4 project board for aligning every registerWhatever API, there are some inconsistencies that I think could do with fixing. See: #1049

@jorenbroekema jorenbroekema merged commit 82e4975 into fix-tests Nov 28, 2023
2 checks passed
@jorenbroekema jorenbroekema deleted the preprocessors branch November 28, 2023 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants