Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

[Question] Large client-side bundle filesize when requiring feathers client #71

Closed
petermikitsh opened this issue Jul 28, 2016 · 3 comments

Comments

@petermikitsh
Copy link

petermikitsh commented Jul 28, 2016

Hi Feathers team,

When adding the following lines to my project, my webpack bundle.js file grows from 629 kB to 2.06 MB.

const feathers = require('feathers/client');
const rest = require('feathers-rest/client');
const superagent = require('superagent');
const app = feathers().configure(
  rest(__API__).superagent(superagent)
);

Superagent is ~20kb (upon comparison webpack builds with and without it), so I suspect the majority of the increase is due to feathers and feathers-rest. Is there anyway (1) I can optimize Webpack to reduce my bundle filesize or (2) code changes to feathers to export less stuff?

@daffl
Copy link
Member

daffl commented Jul 28, 2016

The Browserified feathers-client is about 17k minified + gzipped.

The issue is probably babel-polyfill not mapped to an empty module (see https://github.com/feathersjs/feathers-client/blob/master/package.json#L48 - we might have to add this in the main feathers module) and then including your own ES6 polyfill (a babel-polyfill browser build or the core-js main distributable).

Another problem might be accidentally including feathers instead of feathers/client somewhere which will try to bundle browser builds for everything that comes with Express.

@petermikitsh
Copy link
Author

It appears to be an issue with my configuration. A sandboxed webpack build produces expected results (52.3kb) -- see petermikitsh/feathers-client-filesize.

$ npm run build

> [email protected] build /Users/pmikitsh/git/feathers-client-filesize
> webpack --config ./webpack.js

Hash: 71a7163aa1c3777646da
Version: webpack 1.13.1
Time: 1143ms
        Asset       Size  Chunks             Chunk Names
    bundle.js    53.2 kB       0  [emitted]  main
bundle.js.map  122 bytes       0  [emitted]  main
 bundle.js.gz    14.1 kB          [emitted]  
   [0] multi main 28 bytes {0} [built]
    + 38 hidden modules

I'll report back if I find a solution for my actual project's configuration.

@petermikitsh
Copy link
Author

petermikitsh commented Jul 28, 2016

Wrapping my DefinePlugin variable with JSON.stringify(...) in my webpack file fixed the problem.

With React + Redux + Feathers + Lots of other fun things, new webpack build size is 682 kB, and gzipped 160 kB.

🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants