Before 5.14 (either after or after) you can do:
package Foo;
BEGIN {
use warnings 'FATAL' => 'all';
eval 'INIT{} 1' or die "Module must be loaded during global compilation\n";
}
but this (and ${^GLOBAL_PHASE}) does not quite check what you want to know, namely, the code containing the use / require statement is compiled or run.