aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-04-15 05:52:29 +0800
committerGitHub <noreply@github.com>2017-04-15 05:52:29 +0800
commit32deb365d500f22f3215fe0edb094b38dba5b61a (patch)
tree742fd8c31092f9e7716df08d5f5dc0321e012c4c /lib/compress.js
parent2244743545e8e5a75b4cce219605588cd29581b1 (diff)
downloadtracifyjs-32deb365d500f22f3215fe0edb094b38dba5b61a.tar.gz
tracifyjs-32deb365d500f22f3215fe0edb094b38dba5b61a.zip
drop `angular` (#1812)
Remove support for `@ngInject` as there are proper alternatives anyway.
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js78
1 files changed, 0 insertions, 78 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 8c254573..5128abb2 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -48,7 +48,6 @@ function Compressor(options, false_by_default) {
return new Compressor(options, false_by_default);
TreeTransformer.call(this, this.before, this.after);
this.options = defaults(options, {
- angular : false,
booleans : !false_by_default,
cascade : !false_by_default,
collapse_vars : !false_by_default,
@@ -536,9 +535,6 @@ merge(Compressor.prototype, {
var CHANGED, max_iter = 10;
do {
CHANGED = false;
- if (compressor.option("angular")) {
- statements = process_for_angular(statements);
- }
statements = eliminate_spurious_blocks(statements);
if (compressor.option("dead_code")) {
statements = eliminate_dead_code(statements, compressor);
@@ -731,80 +727,6 @@ merge(Compressor.prototype, {
}
}
- function process_for_angular(statements) {
- function has_inject(comment) {
- return /@ngInject/.test(comment.value);
- }
- function make_arguments_names_list(func) {
- return func.argnames.map(function(sym){
- return make_node(AST_String, sym, { value: sym.name });
- });
- }
- function make_array(orig, elements) {
- return make_node(AST_Array, orig, { elements: elements });
- }
- function make_injector(func, name) {
- return make_node(AST_SimpleStatement, func, {
- body: make_node(AST_Assign, func, {
- operator: "=",
- left: make_node(AST_Dot, name, {
- expression: make_node(AST_SymbolRef, name, name),
- property: "$inject"
- }),
- right: make_array(func, make_arguments_names_list(func))
- })
- });
- }
- function check_expression(body) {
- if (body && body.args) {
- // if this is a function call check all of arguments passed
- body.args.forEach(function(argument, index, array) {
- var comments = argument.start.comments_before;
- // if the argument is function preceded by @ngInject
- if (argument instanceof AST_Lambda && comments.length && has_inject(comments[0])) {
- // replace the function with an array of names of its parameters and function at the end
- array[index] = make_array(argument, make_arguments_names_list(argument).concat(argument));
- }
- });
- // if this is chained call check previous one recursively
- if (body.expression && body.expression.expression) {
- check_expression(body.expression.expression);
- }
- }
- }
- return statements.reduce(function(a, stat){
- a.push(stat);
-
- if (stat.body && stat.body.args) {
- check_expression(stat.body);
- } else {
- var token = stat.start;
- var comments = token.comments_before;
- if (comments && comments.length > 0) {
- var last = comments.pop();
- if (has_inject(last)) {
- // case 1: defun
- if (stat instanceof AST_Defun) {
- a.push(make_injector(stat, stat.name));
- }
- else if (stat instanceof AST_Definitions) {
- stat.definitions.forEach(function(def) {
- if (def.value && def.value instanceof AST_Lambda) {
- a.push(make_injector(def.value, def.name));
- }
- });
- }
- else {
- compressor.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]", token);
- }
- }
- }
- }
-
- return a;
- }, []);
- }
-
function eliminate_spurious_blocks(statements) {
var seen_dirs = [];
return statements.reduce(function(a, stat){