gruntjs / gruntjs/grunt

Make task file compilation more intelligent.

Open
#927 9 comments 0 reactions 0 assignees View on GitHub
needs discussion needs research (help?)
Dominant language
JavaScript
Stars
12.2k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

_This might be a duplicate._

This is how I see it working. When Grunt runs a task:
1. Grunt gives the task an array of known src/dest pairs and just src files (what it already does with `this.files` and `this.filesSrc`).
2. The task gives Grunt back an object that tells Grunt about additional dependencies any src file might have. (:star:)
3. Grunt checks their (and their dependencies') mtimes in its index-of-files-to-mtimes, and updates the `this.files` and `this.filesSrc` to remove files that don't need to be compiled due to mtimes.
4. The task does its thing, keeping track of what files were successfully compiled/linted/whatever.
5. The task gives Grunt an array of successfully compiled/linted/whatever src files.
6. Grunt updates the mtimes in its index-of-files-to-mtimes.

Steps 2-3 could be skipped by plugins that won't have additional dependencies. Also, for plugins that might create their list of dependencies as-they-go, and not up-front, we could possibly expose the mtime-checking method behind step 3 to the task.

Steps 4-6 could be skipped by plugins that don't compile/lint or don't operate on src files.

:star: Assuming Grunt passes in src files `src/simple.css` and `src/has-imports.css`:

``` js
// This object could look something like:
{
"src/simple.css": ["src/simple.css"],
"src/has-imports.css": ["src/has-imports.css", "src/import1.css", "src/import2.css"]
}

// Although maybe specifying the "key" src filename in the
// array is redundant. Maybe it could be more like:
{
"src/simple.css": [],
"src/has-imports.css": ["src/import1.css", "src/import2.css"]
}

// Or even just this, and Grunt can assume it has to check
// src/simple.css since it was in the original src list:
{
"src/has-imports.css": ["src/import1.css", "src/import2.css"]
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing Grunt's existing this.files and this.filesSrc task API, along with the mtime index described in the issue. Trace how tasks receive source files and how mtimes are currently checked. Done would require an agreed dependency-reporting and successful-file API, including behavior for plugins that do not use additional dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.