markfinger / unfort

Development-oriented build tool for the web
MIT License
74 stars 1 forks source link

Detection of implicit file dependencies via pipeline interfaces #122

Open markfinger opened 8 years ago

markfinger commented 8 years ago

Caveat: this is quite possibly a terrible idea, but it's amusing me enough to jot it down

Given that compiling a single file, with dependencies, will involve FS calls to:

We could use an abstraction over the FS (#88) that detects those calls and annotates the compilation with the dependencies of the outcomes of each FS call (eg: mtime, isFile, etc).

If the system was aware of the implicit file dependencies that are used to produce a compiled asset, we could replace a massive amount of complex cache invalidation logic with simple diffs. Eg: if the compilation of a file relied on fs calls that had x and y outcomes, we can simply check for equality before validating or discarding cached data.

Currently, we cache everything except for path-based dependency identifiers which originate from files within the source root (eg: project files, rather than package files). The reason why we don't cache is down to the implicit ambiguity of ./foo mapping to either ./foo.js or ./foo/index.js. That ambiguity is removed if we can diff against the fs state used for the compilation.