guybedford / chomp

'JS Make' - parallel task runner for the frontend ecosystem with a JS extension system.
https://chompbuild.com
Apache License 2.0
138 stars 7 forks source link

feat: templates as JS scripts #47

Closed guybedford closed 2 years ago

guybedford commented 2 years ago

This rewrites the template system to be based entirely on JS scripting environment, and converts all the internal templates from .toml files into .js files.

Before:

[[template]]
name = "my-template"
definition = """() => {}"""

After:

Chomp.registerTemplate('my-template', function () { ... })

In addition this also adds support for a new extensions array in the Chompfile, which allows referencing extensions from local JS files:

version = 0.1

extensions = ["./extension.js"]

where the extension files can define any custom templates. URL support incoming as well.

guybedford commented 2 years ago

URL extensions are now supported and cached in this PR as well, allowing for very flexible extensions now:

version = 0.1

extensions = ["https://custom.com/chomp-extensions.js"]

URLs are cached indefinitely with a chomp --clear-cache. Unique versioned URLs are the recommended pattern.