Skip to content

Custom extractors and transformers #9

@k0d13

Description

@k0d13

Currently the supported syntaxs are JS/TS and JSX/TSX, cool and all, but if support for others (vue, svelte, ripple) is wanted, they have to be added directly to the babel plugin, and there is no way for consumers to create their own extractors/transformers.

The idea is the create the concept of "factories" (undecided on term). These factories follow a similar model to formatters, in that they provide a set of functions that can be called by the cli while extracting/compiling messages. Something like:

type Factory = { match(filename): boolean, extract(content: string): Message[], transform(content: string): string }

The extracting and transforming from the babel plugin would be split into two packages @saykit/factory-js and @saykit/factory-jsx, that can then be passed into the saykit config buckets. This allows for in the future @saykit/factory-vue and @saykit/factory-svelte. With this change, this means in order for the plugins to know how to transform the code, they will need to be able to access the config from saykit.config.ts (currently only the cli cares about the config).

With this, I wonder if the number of packages should be reduced, e.g. combine saykit and @saykit/config every project that uses saykit would need its config and cli. I then do also wonder if every package should just become an export of saykit (saykit/react, saykit/carbon, saykit/format/po), I believe effect.ts did this recently, something to thing about. Todo, make another issue for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: babel-pluginRelated to babel-plugin-saykitpackage: configRelated to @saykit/config and the CLIrequestA request for a new feature or a change in behaviour

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions