       mangle      : yes
       'screw-ie8' : yes
 
+  asReadable = (src) ->
+    rs = new Readable
+    rs._read = ->
+      rs.push src
+      rs.push null
+    return rs
 
   bant = build b, globals: opts.globals
     .on 'bundle', (bundle) ->
-      outfile = path.join opts.outdir, "#{bundle.name}.js"
-      fs.writeFile outfile, bundle.source, (err, res) ->
-        debug "could not write #{outfile}"  if err
-        debug "#{pretty bundle.source.length} written to #{path.basename outfile}"
+      basename = "#{bundle.name}.js"
+      outfile = path.join opts.outdir, basename
+      s = fs.createWriteStream outfile
+      asReadable(bundle.source).pipe(exorcist("#{outfile}.map")).pipe(s)
+      s.once 'finish', ->
+        debug "#{pretty bundle.source.length} written to #{basename}"
 
   b.require(require.resolve('kd.js'), { expose: 'kd' })  unless watchMode
 

  rev: null
  browserify:
    extensions: ['.coffee', '.js', '.json']
    # debug: true
  globals:
    config: {}
    appClasses: {}


  mapping = {}
  modules.forEach (name) -> mapping[name] = "../#{name}/lib"

  if devMode then opts.browserify.debug = true

  if watchMode
    b = watchify(browserify(xtend(opts.browserify, watchify.args)))
