node.js - coffeescript + nodejs: caching the compiled server-side javascript using require -
i'm running node web server via "coffee my_server.coffee", , load dependencies via
require './my_library.coffee'
my codebase pretty big, , it's starting take significant amount of time server start up, believe due coffeescript compilation... when convert entire thing javascript, loads faster.
what's least painful way of caching compiled javascript, when restart server compiles files i've edited since last started it? ideally totally transparent... keep on requiring coffeescript , gets cached behind scenes.
alternatively, run "node my_server.js", , have watcher on directory recompiles coffeescript whenever edit it, don't idea because clutters directory bunch of js files, makes gitignore more complicated, , means have manage watcher function. there way me have cake (running "coffee" executable , requiring coffee files) , eat (fast load times)?
well if don't want "clutter directory bunch of .js files", think you're sol. if don't store .js files on disk ever, need compile .coffee javascript on fly every time. coffee
command knowledge not comparison of mtime between .js
, .coffee
files, although in theory could, in case leaving .js
files around situation. given preferences, thing can suggest is:
- run watcher builds .coffee files separate
build
subdirectory tree - start app
node build/app.js
instead of coffee - ignore
build
directory in.gitignore
you'll have give on running things via coffee
though. curious see if others have better suggestions. projects don't suffer startup time issue. ssds , small projects keep short , not annoying.
Comments
Post a Comment