kadirahq / lokka

Simple JavaScript Client for GraphQL
MIT License
1.53k stars 61 forks source link

compiled build with lokka is unfortunately large #32

Open cainlevy opened 7 years ago

cainlevy commented 7 years ago

We noticed that after adding lokka and lokka-transport-http, our production build increased from ~75kb to ~500kb. I suspect it's the babel-runtime dependency.

agentcooper commented 7 years ago

I created new react app (with create-react-app), added lokka and lokka-transport-http and then ran source-map-explorer on the build: http://i.imgur.com/JvCPKff.png.

It seems that huge size comes from iconv-lite, which is a dependency of node-fetch.

I ended up switching to apollo-client core, it is much smaller.

lanwin commented 7 years ago

@kadirahq any thoughts on this issue? It seems node-fetch is also the root cause for #26 and there was the suggestion to replace node-fetch in example with isomorphic-fetch.

asci commented 7 years ago

@cainlevy @agentcooper if you use webpack you can add the following to your configuration:

{
  resolve: {
    alias: {
      'node-fetch': 'whatwg-fetch'
    }
  }
}

in this case, webpack will ignore dependency on node-fetch and will not bundle this package with all its dependencies (like huge iconv-lite).

Would be nice to add this to Readme file, what do you think? @arvitaly

lanwin commented 7 years ago

well this will not work when using react-create-app

asci commented 7 years ago

Unless you eject it. The react-create-app has its own tradeoffs — it is not flexible. Another option — get rid of node-fetch dependency at lokka-transport-http code level.

lanwin commented 7 years ago

Yes this was why I ask @kadirahq about his thoughts? If there are reasons not to switch from node-fetch to whatwg-fetch

linus-amg commented 7 years ago

thx @asci, this was super helpful, struggled with the bundle size as well