   write: =>
     console.log 'Writing files', JSON.stringify @destFiles, null, 2
     async.forEach @destFiles, (destFile, next) =>
-      data = (sourceFile.data for sourceFile in destFile.sourceFiles).join ''
       # TODO.
       destPath = path.join 'build', destFile.path
+      destIsJS = /\.js$/.test destPath
+      data = ''
+      data += requireDefinition if destIsJS
+      data += destFile.sourceFiles
+        .map (sourceFile) ->
+          if destIsJS and not (/^vendor/.test sourceFile.path)
+            wrap sourceFile.path, sourceFile.data
+          else
+            sourceFile.data
+        .join ''
       fs.writeFile destPath, data, (error) =>
         next error, {path: destPath, data}
     , (error, results) =>

    unless sourceFile
      sourceFile = changedFile
      concatenated = destFile.sourceFiles.concat [sourceFile]
      destFile.sourceFiles = exports.sort concatenated, @config.files[changedFile.destinationPath].order
      delete changedFile.destinationPath
    sourceFile.data = changedFile.data


async = require 'async'
{EventEmitter} = require 'events'
fs = require 'fs'
path = require 'path'

# Function that sorts array.
# array - array to be sorted.
