Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid constructor.name . fix for #65 #177

Closed
wants to merge 1 commit into from
Closed

Conversation

ya7ya
Copy link

@ya7ya ya7ya commented Mar 8, 2018

this avoids using constructor.name so uglify can mangle and compress js-ipfs properly.

this should close #65

cc @diasdavid

@@ -129,7 +130,7 @@ class Node extends EventEmitter {
this.switch.transport.add(
transport.tag || transport.constructor.name, transport)
} else if (transport.constructor &&
transport.constructor.name === 'WebSockets') {
transport instanceof WebSockets) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diasdavid hey,

solution 1 : What if we add a name property to the WebSockets class which isn't gonna be mangled by uglify like so

class WebSockets {
 constructor (opts) {
   this.name = 'WebSockets'
 }
}

Solution 2 : use both instanceOf and constructor,name like so
if (transport.constructor.name === 'WebSockets' || transport instanceOf WebSockets)

What do you think.??

Copy link
Member

@daviddias daviddias Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solution 1 is closer to a real solution. Even better would be just to have a isWebSockets method that checks multiple things

@daviddias
Copy link
Member

See @pgte proposal ipfs/js-ipfs#1131 (comment)

@daviddias daviddias added help wanted Seeking public contribution on this issue exp/expert Having worked on the specific codebase is important P1 High: Likely tackled by core team if no one steps up labels Mar 21, 2018
@fsdiogo
Copy link
Member

fsdiogo commented Apr 6, 2018

PR #182 fixes this.

@daviddias
Copy link
Member

This has been fixed in all the js-ipfs deps thanks to @fsdiogo. @ya7ya thanks for helping us diagnose and provide solutions. Check ipfs/js-ipfs#1321 for more info.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P1 High: Likely tackled by core team if no one steps up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checking for WebSockets constructor name fails under uglification
3 participants