Skip to content

Commit

Permalink
Added full uglify for es6
Browse files Browse the repository at this point in the history
  • Loading branch information
gunins committed Mar 23, 2017
1 parent e8fd165 commit 164741d
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 3,903 deletions.
5 changes: 3 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ module.exports = function(grunt) {
clean: ['target', 'dist', 'examples/**/target'],
exec: {
npmpack: 'npm pack dist',
publish: 'npm publish dist'
publish: 'npm publish dist',
uglifyEs6:'./node_modules/.bin/uglifyjs target/es6/prod/widget/App.js -o target/es6/prod/widget/App.js -c -m -r done'
},
requirejs: {
prod: {
Expand Down Expand Up @@ -590,7 +591,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-bump');

grunt.registerTask('test', ['connect', 'mocha_phantomjs']);
grunt.registerTask('default', ['clean', 'requirejs', 'concat', 'babel', 'uglify', 'copy', 'test', 'docco']);
grunt.registerTask('default', ['clean', 'requirejs', 'concat', 'babel', 'uglify', 'exec:uglifyEs6', 'copy', 'test', 'docco']);
grunt.registerTask('publish', ['default', 'bump', 'exec:publish']);

};
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bootstrap": "latest",
"watch": "latest",
"d3": "3.5.16",
"urlmanager": "0.4.2",
"urlmanager": "0.4.3",
"three.js": "*"
},
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion dist/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"bootstrap": "latest",
"watch": "latest",
"d3": "3.5.16",
"urlmanager": "0.4.2",
"urlmanager": "0.4.3",
"three.js": "*"
},
"ignore": [
Expand Down
119 changes: 66 additions & 53 deletions dist/docs/setRoutes.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h1>setRoutes.js</h1>
<span class="hljs-keyword">let</span> fnStr = func.toString().replace(STRIP_COMMENTS, <span class="hljs-string">''</span>),
argsList = fnStr.slice(fnStr.indexOf(<span class="hljs-string">'('</span>) + <span class="hljs-number">1</span>, fnStr.indexOf(<span class="hljs-string">')'</span>)),
result = argsList.match(ARGUMENT_NAMES);
<span class="hljs-keyword">return</span> (result === <span class="hljs-literal">null</span>) ? [] : result.map(item=&gt;item.replace(<span class="hljs-regexp">/[\s,]/g</span>, <span class="hljs-string">''</span>));
<span class="hljs-keyword">return</span> (result === <span class="hljs-literal">null</span>) ? [] : result.map(item =&gt; item.replace(<span class="hljs-regexp">/[\s,]/g</span>, <span class="hljs-string">''</span>));
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">destroyComponent</span>(<span class="hljs-params">cp</span>) </span>{
Expand All @@ -132,7 +132,7 @@ <h1>setRoutes.js</h1>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">applyToChildren</span>(<span class="hljs-params">children, cb</span>) </span>{
<span class="hljs-keyword">if</span> (children !== <span class="hljs-literal">undefined</span>) {
<span class="hljs-built_in">Object</span>.keys(children).forEach((name)=&gt; {
<span class="hljs-built_in">Object</span>.keys(children).forEach((name) =&gt; {
<span class="hljs-keyword">let</span> instance = children[name];
<span class="hljs-keyword">if</span> (!applyToGroup(instance, cb)) {
cb(instance);
Expand All @@ -143,7 +143,7 @@ <h1>setRoutes.js</h1>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">applyToGroup</span>(<span class="hljs-params">child, cb</span>) </span>{
<span class="hljs-keyword">if</span> (child.elGroup &amp;&amp; child.elGroup.size &gt; <span class="hljs-number">0</span>) {
child.elGroup.forEach((childInstance)=&gt; {
child.elGroup.forEach((childInstance) =&gt; {
cb(childInstance);
});
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
Expand All @@ -163,89 +163,102 @@ <h1>setRoutes.js</h1>
active = context.active,
matches = match(route);

matches.to((...args)=&gt; {
matches.to((...args) =&gt; {
<span class="hljs-keyword">let</span> params = args.pop();
id = (args.length &gt; <span class="hljs-number">0</span>) ? params.getLocation() + <span class="hljs-string">'_'</span> + args.join(<span class="hljs-string">'_'</span>) : <span class="hljs-literal">undefined</span>;

<span class="hljs-keyword">if</span> (!applyToGroup(child, instance=&gt;dom.attach(instance))) {
<span class="hljs-keyword">if</span> (!applyToGroup(child, instance =&gt; dom.attach(instance))) {
<span class="hljs-keyword">let</span> childInstance = child.run(<span class="hljs-literal">true</span>);
applyToChildren(childInstance.children, instance=&gt; {
applyToChildren(childInstance.children, instance =&gt; {
<span class="hljs-keyword">if</span> (instance) {
match(route, match=&gt; matchRoute(instance, {match, active}));
match(route, match =&gt; matchRoute(instance, {match, active}));
}
});
}
applyToGroup(child, (childInstance)=&gt; {
applyToChildren(childInstance.children, instance=&gt; {
applyToGroup(child, (childInstance) =&gt; {
applyToChildren(childInstance.children, instance =&gt; {
<span class="hljs-keyword">if</span> (instance &amp;&amp; instance.to) {
instance.to(...args.concat(params));
}
});
});
});
matches.leave((done)=&gt; {
<span class="hljs-keyword">let</span> items = <span class="hljs-number">0</span>,
stopped = <span class="hljs-literal">false</span>;
applyToGroup(child, (childInstance)=&gt; {
<span class="hljs-keyword">let</span> finish = ()=&gt; {
<span class="hljs-keyword">if</span> (!id) {
dom.detach(childInstance);
} <span class="hljs-keyword">else</span> {
destroyComponent(childInstance);
}
},
close = (close = <span class="hljs-literal">true</span>)=&gt; {
<span class="hljs-keyword">if</span> (close) {
items--;
} <span class="hljs-keyword">else</span> {
stopped = <span class="hljs-literal">true</span>;
done(<span class="hljs-literal">false</span>);
}

<span class="hljs-keyword">if</span> (items === <span class="hljs-number">0</span> &amp;&amp; !stopped) {
active.set(childInstance, finish);
done(<span class="hljs-literal">true</span>);
}
});</pre></div></div>

</li>


<li id="section-2">
<div class="annotation">

<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>TODO: strange bug done=&gt; causing error (done)=&gt; not</p>

};
</div>

<div class="content"><div class='highlight'><pre> matches.leave(done=&gt; {
<span class="hljs-keyword">let</span> items = <span class="hljs-number">0</span>,
stopped = <span class="hljs-literal">false</span>;
applyToGroup(child, (childInstance) =&gt; {
<span class="hljs-keyword">let</span> finish = () =&gt; {
<span class="hljs-keyword">if</span> (!id) {
dom.detach(childInstance);
} <span class="hljs-keyword">else</span> {
destroyComponent(childInstance);
}
},
close = (close = <span class="hljs-literal">true</span>) =&gt; {
<span class="hljs-keyword">if</span> (close) {
items--;
} <span class="hljs-keyword">else</span> {
stopped = <span class="hljs-literal">true</span>;
done(<span class="hljs-literal">false</span>);
}

applyToChildren(childInstance.children, instance=&gt; {
<span class="hljs-keyword">if</span> (instance &amp;&amp; instance.leave !== <span class="hljs-literal">undefined</span>) {
<span class="hljs-keyword">let</span> args = getArgs(instance.leave);
<span class="hljs-keyword">if</span> (args.length &gt; <span class="hljs-number">0</span>) {
items++
}
instance.leave(close);
<span class="hljs-keyword">if</span> (items === <span class="hljs-number">0</span> &amp;&amp; !stopped) {
active.set(childInstance, finish);
done(<span class="hljs-literal">true</span>);
}
});

<span class="hljs-keyword">if</span> (items === <span class="hljs-number">0</span>) {
active.set(childInstance, finish);
done(<span class="hljs-literal">true</span>);
};

applyToChildren(childInstance.children, instance =&gt; {
<span class="hljs-keyword">if</span> (instance &amp;&amp; instance.leave !== <span class="hljs-literal">undefined</span>) {
<span class="hljs-keyword">let</span> args = getArgs(instance.leave);
<span class="hljs-keyword">if</span> (args.length &gt; <span class="hljs-number">0</span>) {
items++
}
instance.leave(close);
}
});
}
);

matches.query((params)=&gt; {
applyToGroup(child, (childInstance)=&gt; {
applyToChildren(childInstance.children, (instance)=&gt; {
<span class="hljs-keyword">if</span> (items === <span class="hljs-number">0</span>) {
active.set(childInstance, finish);
done(<span class="hljs-literal">true</span>);
}
});
});

matches.query((params) =&gt; {
applyToGroup(child, (childInstance) =&gt; {
applyToChildren(childInstance.children, (instance) =&gt; {
<span class="hljs-keyword">if</span> (instance &amp;&amp; instance.query !== <span class="hljs-literal">undefined</span>) {
instance.query(params);
}
});
});
});
applyToGroup(child, instance=&gt;instance._activeRoute = matches);
applyToGroup(child, instance =&gt; instance._activeRoute = matches);

} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (child.children !== <span class="hljs-literal">undefined</span> &amp;&amp; [<span class="hljs-string">'cp'</span>].indexOf(child.data.type) === <span class="hljs-number">-1</span>) {
applyToChildren(child.children, instance=&gt; matchRoute(instance, context));
applyToChildren(child.children, instance =&gt; matchRoute(instance, context));
}
}
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">setRoutes</span>(<span class="hljs-params">children, context</span>) </span>{
applyToChildren(children, child=&gt; matchRoute(child, context));
applyToChildren(children, child =&gt; matchRoute(child, context));

};

Expand Down
19 changes: 17 additions & 2 deletions dist/es5/dev/widget/App.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/es5/dev/widget/App.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/es5/dev/widget/Constructor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/es5/dev/widget/Constructor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/es5/prod/babel/polyfill.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/es5/prod/widget/App.js

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions dist/es6/dev/widget/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@

function iterateQueryString(queryString, callback) {
let keyValues = queryString.split('&');
keyValues.forEach((keyValue)=> {
keyValues.forEach((keyValue) => {
let arr = keyValue.split('=');
callback(arr.shift(), arr.join('='));
});
Expand All @@ -345,7 +345,7 @@
function setQuery(parts) {
let query = {};
if (parts) {
iterateQueryString(parts, (name, value)=> {
iterateQueryString(parts, (name, value) => {
value = parseParams(value);
if (!query[name]) {
query[name] = value;
Expand Down Expand Up @@ -421,10 +421,15 @@
ARGUMENT_NAMES = /(?:^|,)\s*([^\s,=]+)/g;

function getArgs(func) {
let fnStr = func.toString().replace(STRIP_COMMENTS, ''),
argsList = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')),
let oneOf = (...patterns) => (string, pos) => patterns
.map(pattern => string.indexOf(pattern))
.filter(index => index === pos).length > 0,
fnStr = func.toString().replace(STRIP_COMMENTS, ''),
first = oneOf('(', 'function (', 'function(')(fnStr, 0) ? fnStr.indexOf('(') + 1 : 0,
last = !oneOf('=>')(fnStr, -1) ? fnStr.indexOf('=>') : fnStr.indexOf(')'),
argsList = fnStr.slice(first, last).trim(),
result = argsList.match(ARGUMENT_NAMES);
return (result === null) ? [] : result.map(item=>item.replace(/[\s,]/g, ''));
return (result === null) ? [] : result.map(item => item.replace(/[\s,]/g, ''));
}

return {
Expand Down
Loading

0 comments on commit 164741d

Please sign in to comment.