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:
read the text of the file
check for the existence of possible files that match its dependency identifiers
read package.json files (to identify paths via main or browser fields).
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.
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:
package.json
files (to identify paths viamain
orbrowser
fields).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
andy
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.