-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
I'm seeing a possible bug when minifying the wayfarer project, as it behaves differently after minification. I've created a branch of the project that demonstrates the issue by running tests on a minified version of walk.js. The tests produce 4 failures against walk.min.js, whereas the original (walk.js) tests without failures. I've included the unminified walk.js (with some irrelevant lines removed) and the minified version below.
- Bug report or feature request?
Bug uglify-jsversion (uglifyjs -V)
2.8.4- JavaScript input - ideally as small as possible.
function walk (router, transform) {
var trie = router._trie
;(function walk (route, trie) {
if (trie.cb) {
trie.cb = transform(route, trie.cb)
}
if (trie.nodes) {
var nodes = trie.nodes
Object.keys(nodes).forEach(function (key) {
var node = nodes[key]
var newRoute = (key === '$$')
? route + '/:' + trie.name
: route + '/' + key
walk(newRoute, node)
})
}
})('', trie.trie)
}
- The
uglifyjsCLI command executed orminify()options used.
./node_modules/.bin/uglifyjs -c -m -o walk.min.js -- walk.js - An example of JavaScript output produced and/or the error or warning.
function walk(n,c){var e=n._trie;!function n(e,a){if(a.cb&&(a.cb=c("",a.cb)),a.nodes){var i=a.nodes;Object.keys(i).forEach(function(c){var e=i[c];n("$$"===c?"/:"+a.name:"/"+c,e)})}}("",e.trie)}
This also produces a warning, although I don't know the significance of this: WARN: Replacing variable newRoute [walk.js:15,13]
Test failures from minification:
# should walk partials
not ok 55 no partials
---
operator: equal
expected: '/foo'
actual: ''
at: Test.<anonymous> (/Users/arve/Projects/wayfarer/test/walk.js:60:7)
...
not ok 56 one partial
---
operator: equal
expected: |-
'/:foo'
actual: |-
''
at: Test.<anonymous> (/Users/arve/Projects/wayfarer/test/walk.js:61:7)
...
not ok 57 partial and normal
---
operator: equal
expected: |-
'/:foo/bar'
actual: |-
''
at: Test.<anonymous> (/Users/arve/Projects/wayfarer/test/walk.js:62:7)
...
not ok 58 two partials
---
operator: equal
expected: |-
'/:foo/:bar'
actual: |-
''
at: Test.<anonymous> (/Users/arve/Projects/wayfarer/test/walk.js:63:7)
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels