Fix import statement formatting with directories

* Prevent leading slashes in import statements if the directory array is
  empty