(#22744) Static compiler doesn't filter resources

Copied filter method from compiler.rb and spec tests from compiler