gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

Support running Node tools in the Configuration Phase, and multiple tools per task by providing ValueSource implementations

Open adam-enko opened this issue 6 months ago • 4 comments

Feature Request: Provide ValueSource implementations for running Node tools

Summary

Currently Gradle Plugin for Node has a 'task based' approach for running Node tools. One task can run one Node tool a single time. This is good for simple projects.

However, I would like to use Node tools in more advanced use cases:

  1. Use Node tools before task execution, during the configuration phase.

    As part of #81 I proposed a way to make npm install cacheable, but this would require running npm in the configuration phase (to manually add dependencies to the cache). Using a ValueSource would make this trivial.

  2. Support executing the same tool multiple times with different arguments or running different tools sequentially in the same task.

Proposal

Provide implementations of ValueSource so users can run node tools on-demand.

The existing task-based execution approach would still work as-is, but to avoid duplication it would be best to re-write the internal implementation to use a 'ValueSource first' approach. The existing tasks will have the same API surface (so there is no change for users), but internally they will use ValueSources.

We can break up the implementation into smaller steps by migrating each Node tool individually.

I'd be happy to make a PR.

adam-enko avatar May 22 '25 08:05 adam-enko