brunch
brunch copied to clipboard
Undocumented requirement for `compileStatic` plugins.
I discovered an interesting edge case today and wanted to bring it up to the maintainers. I am not sure whether the solution is a code change or a documentation update, hence this post.
Description
Not accessing file.data() in compileStatic results in the file raw data being used rather than the compiled asset data.
Source of issue:
asset._wasProcessed is only set if asset.data() was called at least once.
See asset.js#83
Expected behavior
I expect that it should be sufficient that a compiler gets called on the file for it to be tracked as processed
Example
Works
compileStatic(file) {
file.data;
Promise.resolve(file);
}
Does not work:
compileStatic(file) {
Promise.resolve(file);
}