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

fix: only require http api client if it has not been specified #450

Merged
merged 17 commits into from
Jan 31, 2020

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Jan 29, 2020

If we configure which http api module to use, don't try to require ipfs-http-client, because that then means the containing project needs to specify a dependency on ipfs-http-client when the containing project might actually be ipfs-http-client...

@achingbrain achingbrain force-pushed the only-require-http-client-if-not-specified branch 2 times, most recently from 2a6f984 to d4082db Compare January 29, 2020 16:36
If we configure which http api module to use, don't try to require
`ipfs-http-client`, because that then means the containing project
needs to specify a dependency on `ipfs-http-client` when the
containing project might actually be `ipfs-http-client`...
@achingbrain achingbrain force-pushed the only-require-http-client-if-not-specified branch from d4082db to 3a0f870 Compare January 29, 2020 16:37
@hugomrdias
Copy link
Member

hummm why did this jumped +9kb in size

@achingbrain
Copy link
Member Author

Transitive dependencies changed?

No idea why this is necessary
@hugomrdias
Copy link
Member

its 9kb gziped would need a lot random stuff from deps, can you run the aegir build analize please ? just to double check theses changes dont make us include http-client twice

@achingbrain
Copy link
Member Author

We shouldn't really be including ipfs-http-client at all since it's a peer dep.

I ran the analyser - it's quite hard to make out what's going on, they're definitely in there though only once that I can see.

Before:

image

After:

image

I've added them to webpack's externals list so they don't get added to the bundle. Not sure if that's going to make the browser version explode at runtime or not.

@achingbrain
Copy link
Member Author

Lol:

image

@hugomrdias
Copy link
Member

its gonna break browser tests
i had a look and we have 3 node-forges plus a package.json in there so its not our fault.

please remove the last commit and lets merge/release this.

tip: use chrome to see the analyser, for some reason brave is broken.

.aegir.js Outdated Show resolved Hide resolved
@achingbrain achingbrain force-pushed the only-require-http-client-if-not-specified branch from 9970cf7 to 43e01d8 Compare January 29, 2020 23:28
src/factory.js Outdated Show resolved Hide resolved
@alanshaw
Copy link
Member

Screenshot 2020-01-30 at 12 43 51

WAT! 🚀🐭

.aegir.js Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/factory.js Outdated
Comment on lines 85 to 105
if (options.ipfsModule) {
delete opts.ipfsModule

if (options.ipfsModule.path) {
opts.ipfsModule = {
path: options.ipfsModule.path
// n.b. no ref property - do not send code refs over http
}
}
}

if (options.ipfsHttpModule) {
delete opts.ipfsHttpModule

if (options.ipfsHttpModule.path) {
opts.ipfsHttpModule = {
path: options.ipfsHttpModule.path
// n.b. no ref property - do not send code refs over http
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

why do we need all this haven't we already done this below? we just need to remove refs like in the previous version of this block.

Plus its deleting and setting opts.ipfsModule where it should be opts.json.ipfsModule and same for opts.ipfsHttpModule, so if this code made some use case work it wasn't because of this logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was resulting in ipfsModule: {} being sent over the http api which was then getting fleshed out to ipfsModule: { path: require.resolve('ipfs'), ref: require('ipfs') } which breaks under js-ipfs

Copy link
Member

Choose a reason for hiding this comment

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

these if clauses are very hard to track and error prone because of all the combinations available in ctl

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point about the deletion of the wrong property though.

Copy link
Member Author

Choose a reason for hiding this comment

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

these if clauses are very hard to track and error prone because of all the combinations available in ctl

You are quite right. Here, look - I've removed them: #454

@hugomrdias hugomrdias merged commit 6b21d5b into master Jan 31, 2020
@hugomrdias hugomrdias deleted the only-require-http-client-if-not-specified branch January 31, 2020 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants