guybedford / chomp

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

feat: template options refinements #31

Closed guybedford closed 2 years ago

guybedford commented 2 years ago

This PR implements a number of renamings and adjustments to the template system, fixing a number of issues in the process.

This PR also adopts a manual chaining of template options within the template definitions themselves, although that is mostly an implementation detail.

This PR also includes various template fixes including fixing https://github.com/guybedford/chomp/issues/29 and some normalization in the JSPM generator and Babel plugins.

TLDR; here's a before after configuration example:

BEFORE:

version = 0.1

[env]
  PKG_MANAGER = "pnpm"

[[task]]
  template = "jspm"
  [task.args]
    autoInstall = true
    env = ["browser", "production"]

AFTER:

version = 0.1

[default-template-opts.npm]
  auto-install = true
  pkg-manager = 'pnpm'

[[task]]
  template = "jspm"
  [task.template-opts]
    env = ["browser", "production"]

While this is strictly a breaking change, since no release has yet been made there is no version bump.

canadaduane commented 2 years ago

What is the .npm suffix on [default-template-opts.npm]?

Edit to add: And how would I know to add it?

guybedford commented 2 years ago

This means these are the default options for the npm template.

On Tue, Jan 11, 2022 at 06:44 Duane Johnson @.***> wrote:

What is the .npm suffix on [default-template-opts.npm]?

— Reply to this email directly, view it on GitHub https://github.com/guybedford/chomp/pull/31#issuecomment-1010032345, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESFSTKMIDRCMNFPUNFM5DUVQ64RANCNFSM5LVTU3WQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>

canadaduane commented 2 years ago

But I'm not using the npm template? Or am I? And if I am, how do I know?

canadaduane commented 2 years ago

To be clear: I think it's confusing that it says template = "jspm" right below, but we are configuring npm template.

Edit to add: and we've chosen the pnpm package manager in the example, too.

guybedford commented 2 years ago

Templates are functions that output a list of tasks, where those tasks in turn can use templates. The jspm template will output the call to the necessary npm template for JSPM to work, with the global option making auto install configurable.

Would calling it global-options.npm seem clearer? It can be useful to eg configure a global Babel config this way for all Babel templates to avoid repetition so that’s why I was making sure that connection was clear first and foremost.

On Tue, Jan 11, 2022 at 09:31 Duane Johnson @.***> wrote:

To be clear: I think it's confusing that it says template = "jspm" right below, but we are configuring npm template.

— Reply to this email directly, view it on GitHub https://github.com/guybedford/chomp/pull/31#issuecomment-1010196369, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAESFSWOALV6RGACPLWGHA3UVRSNNANCNFSM5LVTU3WQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>