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

Loosen dependency on jstransformers #179

Open
webketje opened this issue Dec 11, 2021 · 2 comments
Open

Loosen dependency on jstransformers #179

webketje opened this issue Dec 11, 2021 · 2 comments

Comments

@webketje
Copy link
Member

webketje commented Dec 11, 2021

Some of the JS transformers are severely outdated and due to the update mechanism (jstransformer-boilerplate -> test-jstransformer -> jstransformer-*) this is probably going to keep being an issue in the future.

For example:

  • jstransformer-marked uses [email protected] while the latest version is 4.0.7 (4 years ahead)
  • jstransformer-handlebars uses [email protected] while the latest version is 4.7.7 (6 years ahead)

Furthermore the renderAsync method used in layouts is not guaranteed to be present on all jstransformers.

There are a few options:

  1. Fork & republish a selection of the most commonly used jstransformers.
  2. Narrow the selection of supported templating languages (eg markdown, handlebars, nunjucks, twig) by bundling adapters in metalsmith-layouts, and specifying peerDependencies and peerDependenciesMeta: optional
  3. Keep using jstransformers, but provide an option transformers: ['path/to/transformer.js', 'path/to/other/transformer.js]` that will be added to the cache with the node_modules transformers, update the docs explaining how to create your own jstransformer.

In favor of option 3

@webketje
Copy link
Member Author

webketje commented May 2, 2022

I've become member of the jstransformer's org and have updated the 2 jstransformers mentioned.
I still think providing a transformers option has several advantages:

  1. It has to be explicitly passed with require('jstransformer-nunjucks') -> explicit is better than implicit
  2. It makes inputformat-to-jstransformer obsolete, which does a dictionary - key lookup of rendering engines matching an ext. 3. Instead, the transformer's inputFormat properties can be used, this allows custom matching & custom transformers
  3. No need for caching the rendering engine

Disadvantages:

  • Major semver breaking change
  • Might need to do changes to in-place too to keep it consistent, and sync release between both

@webketje
Copy link
Member Author

webketje commented Feb 7, 2024

To be aligned with @metalsmith/in-place 5.x transform option

webketje added a commit that referenced this issue Feb 14, 2024
Adds required transform option, as aligned with metalsmith/in-place
webketje added a commit that referenced this issue Feb 14, 2024
…ired transform option to support custom transformers, no longer supports multiple transformers per instantiation

This change is breaking because layouts now requires at least the transform option, and multi-transformer instantiations including mixed engineOptions must now be split over multiple instantiations
This is aligned with metalsmith/in-place
Also refactors tests to use async/await
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

No branches or pull requests

1 participant