mathiasbynens / punycode.js

A robust Punycode converter that fully complies to RFC 3492 and RFC 5891.
https://mths.be/punycode
MIT License
1.59k stars 159 forks source link

SyntaxError in Punycode.js Line 55 #57

Closed joemccann closed 7 years ago

joemccann commented 7 years ago

Not sure if this is an uglify-js bug, but when I run a webpack build that uses uglify-js I get this error in the output:

ERROR in bundle.js from UglifyJs
SyntaxError: Unexpected token: name (length) [./~/punycode/punycode.js:55,0]

Line 55 is a map function.

function map(array, fn) {
    const result = [];
    let length = array.length;
    while (length--) {
        result[length] = fn(array[length]);
    }
    return result;
}

Any ideas? Breaking my builds at the moment and I'm at a loss.

joemccann commented 7 years ago

Turns out when I dove into my bunde.js file, I found this to be breaking in Firefox 49.0.2

https://github.com/bestiejs/punycode.js/blob/master/punycode.js#L302

and elsewhere in the encode function.

Wherever there was

for (const currentValue of input)...

It was displaying this error message: SyntaxError: missing = in const declaration

So I removed const

for (currentValue of input)...

In all 3 locations and it works fine.

It still isn't explaining why uglify-js is barking, though.

I'm using uglify-js@2.7.3 and punycode@2.0.0

mathiasbynens commented 7 years ago

See the README:

The current version supports recent versions of Node.js only. For the old version that offers the same functionality with broader support, including Rhino, Ringo, Narwhal, and web browsers, see v1.4.1.

joemccann commented 7 years ago

I'm using node 6 LTS??

On Saturday, October 22, 2016, Mathias Bynens notifications@github.com wrote:

See the README https://github.com/bestiejs/punycode.js#readme:

The current version supports recent versions of Node.js only. For the old version that offers the same functionality with broader support, including Rhino, Ringo, Narwhal, and web browsers, see v1.4.1 https://github.com/bestiejs/punycode.js/releases/tag/v1.4.1.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bestiejs/punycode.js/issues/57#issuecomment-255540034, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC8agF0L620geLrgea-OjtzWKqIVC6oks5q2kBAgaJpZM4Kd5hq .

Sent from Joe In Real Life

mathiasbynens commented 7 years ago

I was responding to your comment mentioning Firefox 49.0.2. Here’s the Firefox bug you’re seeing: https://bugzilla.mozilla.org/show_bug.cgi?id=449811

The uglify-js issue you’re seeing sounds like a bug with that project :/ Sorry I can’t be of more help. Please let me know if you file an issue there!

joemccann commented 7 years ago

Cool thanks!

On Tuesday, October 25, 2016, Mathias Bynens notifications@github.com wrote:

I was responding to your comment mentioning Firefox 49.0.2. Here’s the Firefox bug you’re seeing: https://bugzilla.mozilla.org/ show_bug.cgi?id=449811

The uglify-js issue you’re seeing sounds like a bug with that project :/ Sorry I can’t be of more help. Please let me know if you file an issue there!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bestiejs/punycode.js/issues/57#issuecomment-256156498, or mute the thread https://github.com/notifications/unsubscribe-auth/AAC8apoRbgFx00pDiHloKft0y0JZJyzUks5q3l3lgaJpZM4Kd5hq .

Sent from Joe In Real Life