Permalink
Browse files

Merge pull request #1650 from mozilla/issue1624

restore include.js license header and links to un-minified source: issue...

r+ - this is a good fix for the include.js problem.  A separate issue was opened for the other files.

close #1624
  • Loading branch information...
2 parents 44d93a1 + ce90ddc commit 0b9bd7bf9fbf280b0ea89f09957b183d774bb275 @shane-tomlinson shane-tomlinson committed May 29, 2012
Showing with 22 additions and 2 deletions.
  1. +1 −1 resources/static/lib/jschannel.js
  2. +21 −1 scripts/compress-worker.js
@@ -1,4 +1,4 @@
-/**
+/*
* js_channel is a very lightweight abstraction on top of
* postMessage which defines message formats and semantics
* to support interactions more rich than just message passing
View
@@ -29,15 +29,35 @@ function compressResource(staticPath, name, files, cb) {
});
}
+ function extract_copyright(code) {
+ var tok = jsp.tokenizer(code), toks, ret = "";
+ toks = tok().comments_before;
+
+ if (toks.length >= 1) {
+ var c = toks[0];
+ // copyrights that we'll include MUST be before code body and have
+ // the form: /** */
+ if (c.value.substr(0, 1) === '*' && c.type === 'comment2') {
+ ret += "/*" + c.value + "*/";
+ }
+ }
+
+ return ret;
+ };
+
function compress() {
try {
var final_code;
if (/\.js$/.test(name)) {
+ // extract copyright
+ var copyright = extract_copyright(orig_code) || "";
+ if (copyright.length) copyright += "\n\n";
+
// compress javascript
var ast = jsp.parse(orig_code); // parse code and get the initial AST
ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
- final_code = pro.split_lines(pro.gen_code(ast), 32 * 1024); // compressed code here
+ final_code = copyright + pro.split_lines(pro.gen_code(ast), 32 * 1024); // compressed code here
} else if (/\.css$/.test(name)) {
// compress css
var cach_code = cachify_embedded(orig_code);

0 comments on commit 0b9bd7b

Please sign in to comment.