Skip to content
Permalink
Browse files

perf(typescript): improve watch for typescript server

  • Loading branch information
jyounce committed Sep 12, 2016
1 parent c19b698 commit 7730ad7c4dd36b57b3923949dc212792cd8a6d50
Showing with 8 additions and 5 deletions.
  1. +4 −2 src/helpers/TsProject.coffee
  2. +4 −3 src/tasks/compile/typescript-server.coffee
@@ -1,7 +1,8 @@
# TYPESCRIPT PROJECT FACTORY
# needed for watch to use same ts project
# =======================================
fs = require 'fs'
fs = require 'fs'
typescript = require 'typescript' # use build's ts version

class TsProject
# typescript instance locations
@@ -27,6 +28,7 @@ class TsProject
# ===========================================
class Typescript
constructor: (@id, @ts, @tsconfig, @opts={}) ->
@opts.typescript = typescript
return @setProject().getProject()

setProject: ->
@@ -46,7 +48,7 @@ class TsProject
if not instances[id] # create new instance
# console.log "TS INSTANCE ID: #{id}".alert
instances[id] = new Typescript id, ts, tsconfig, opts
instances[id].project
instances[id]

# Export Class!
# =============
@@ -30,9 +30,10 @@ module.exports = (config, gulp, taskOpts={}) ->
src = help.getSrc paths
fileBase = paths.src
tsProject = TsProject.get 'server', ts, paths.tsconfig
gulp.src src
.pipe(ts tsProject).js
.pipe updateFileBase fileBase
tsResult = tsProject.src(src).pipe ts tsProject
reference = if paths.watchFile then [src[0]] else undefined
tsResult.js
.pipe ts.filter tsProject, { referencedFrom: reference }
.pipe gulp.dest paths.dest
.on 'end', -> defer.resolve()
defer.promise

0 comments on commit 7730ad7

Please sign in to comment.
You can’t perform that action at this time.