brunch icon indicating copy to clipboard operation
brunch copied to clipboard

Undocumented requirement for `compileStatic` plugins.

Open rminderhoud opened this issue 8 years ago • 0 comments

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);
}

rminderhoud avatar Nov 14 '17 08:11 rminderhoud