Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Applies per-compiler settings.options and copies settings object; Fix…

…es CommonJSCompiler.drop_path_parts; Adds todo.md
  • Loading branch information...
commit 60a163de41f8a106c2f65e8a8ad0c41646e142d9 1 parent 73ec315
David Schoonover authored
Showing with 42 additions and 9 deletions.
  1. +25 −0 TODO.md
  2. +5 −3 compiler.co
  3. +9 −5 compiler.js
  4. +3 −1 package.json
25 TODO.md
View
@@ -0,0 +1,25 @@
+# todo
+
+- Bug: compiler errors propagate to node
+- Replace `#token` in config Strings.
+- Make `setup()` a simple proxy to CompilerMiddleware class.
+- Restructure middleware responder to use events to trigger compiler phases.
+
+## todoc
+
+- examples:
+ - simple usage
+ - with plain connect
+ - with express
+ - recursive compiling (CommonJS, Uglify; @wraps)
+ - custom compilers
+ - extending an existing compiler
+- per-compiler documentation, options
+
+## New Compilers
+
+- Haml
+- Stylus
+- Bundler: cat together multiple files (recursive compiler)
+
+
8 compiler.co
View
@@ -81,7 +81,8 @@ exports = module.exports = CompilerMiddleware = (settings={}, ...custom) ->
console.log "\n#{log_prefix} (#i) Checking '#{id}'..." if settings.log_level <= LOG.DEBUG
info.compiler = C
info.id = id
- C.run info, (err, ok) ~>
+ _info = {} <<< info <<< (info.options?[id] or {})
+ C.run _info, (err, ok) ~>
if not err and ok
success := ok
info.matches++
@@ -453,7 +454,7 @@ class exports.CommonJSCompiler extends Compiler
co : 'coco'
coffee : 'coffee'
jison : 'jison'
- drop_cjs_parts : 0 # allows you to drop the mountpoint if your js files live in, say, /js
+ drop_path_parts : 0 # allows you to drop the mountpoint if your js files live in, say, /js
-> super ...
@@ -466,7 +467,8 @@ class exports.CommonJSCompiler extends Compiler
path.join(destDir, pathname).replace(@match, '.mod.js')
compileSync: (data) ->
- mod_parts = @info.url.slice(1).replace(/\.mod(\.min)?\.js$/i, '').split('/').slice(@drop_cjs_parts)
+ drop = @info.drop_path_parts ? @drop_path_parts
+ mod_parts = @info.url.slice(1).replace(/\.mod(\.min)?\.js$/i, '').split('/').slice(drop)
mod_parts.pop() if mod_parts[mod_parts.length] is 'index'
mod_id = path.normalize mod_parts.join('/')
14 compiler.js
View
@@ -73,7 +73,7 @@ exports = module.exports = CompilerMiddleware = function(settings){
}
try {
Seq(settings.enabled).seqEach(function(id, i){
- var C, _this = this;
+ var C, _ref, _info, _this = this;
C = compilers[id];
if (!(C && (!success || settings.cascade))) {
return this(null);
@@ -83,7 +83,8 @@ exports = module.exports = CompilerMiddleware = function(settings){
}
info.compiler = C;
info.id = id;
- return C.run(info, function(err, ok){
+ _info = __import(__import({}, info), ((_ref = info.options) != null ? _ref[id] : void 8) || {});
+ return C.run(_info, function(err, ok){
if (!err && ok) {
success = ok;
info.matches++;
@@ -542,7 +543,7 @@ exports.CommonJSCompiler = CommonJSCompiler = (function(superclass){
coffee: 'coffee',
jison: 'jison'
};
- prototype.drop_cjs_parts = 0;
+ prototype.drop_path_parts = 0;
function CommonJSCompiler(){
CommonJSCompiler.superclass.apply(this, arguments);
}
@@ -564,8 +565,11 @@ exports.CommonJSCompiler = CommonJSCompiler = (function(superclass){
return path.join(destDir, pathname).replace(this.match, '.mod.js');
};
prototype.compileSync = function(data){
- var mod_parts, mod_id, header;
- mod_parts = this.info.url.slice(1).replace(/\.mod(\.min)?\.js$/i, '').split('/').slice(this.drop_cjs_parts);
+ var drop, mod_parts, mod_id, header, _ref;
+ drop = (_ref = this.info.drop_path_parts) != null
+ ? _ref
+ : this.drop_path_parts;
+ mod_parts = this.info.url.slice(1).replace(/\.mod(\.min)?\.js$/i, '').split('/').slice(drop);
if (mod_parts[mod_parts.length] === 'index') {
mod_parts.pop();
}
4 package.json
View
@@ -20,9 +20,11 @@
},
"main": "compiler",
"dependencies": {
- "coco": ">= 0.6.7",
"seq": ">= 0.3.4"
},
+ "devDependencies": {
+ "coco": ">= 0.6.7"
+ },
"repository": {
"type": "git",
"url": "git://github.com/dsc/connect-compiler.git"
Please sign in to comment.
Something went wrong with that request. Please try again.