Using regular expressions to hack our way towards AMDfication

And tweaks to our code styles
You could store `file.indexOf(type) === -1 ? file + type : file` in a variable, instead of doing it twice.