Adding logic in compiler to deal with plugins

tested in phpunit