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

Bundle size #42

Closed
kilinkis opened this issue Jun 19, 2019 · 2 comments
Closed

Bundle size #42

kilinkis opened this issue Jun 19, 2019 · 2 comments

Comments

@kilinkis
Copy link

kilinkis commented Jun 19, 2019

Hi guys,

I did a very basic integration using this API but the size of the bundle is too big, I think because of the dependencies.
See the following screenshot and below it, my package.json file:

Screenshot 2019-06-19 at 14 56 10

{
  "name": "webpack-starter",
  "version": "1.0.0",
  "description": "A light foundation for your next frontend project based on webpack.",
  "scripts": {
    "build": "webpack --config webpack/webpack.config.prod.js  --colors",
    "start": "webpack-dev-server --open --config webpack/webpack.config.dev.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/wbkd/webpack-starter.git"
  },
  "keywords": [
    "webpack",
    "startkit",
    "frontend",
    "es6",
    "javascript",
    "webdev"
  ],
  "author": "webkid.io",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/wbkd/webpack-starter/issues"
  },
  "devDependencies": {
    "@babel/core": "^7.4.0",
    "@babel/plugin-proposal-class-properties": "^7.4.0",
    "@babel/plugin-syntax-dynamic-import": "^7.2.0",
    "@babel/preset-env": "^7.4.2",
    "babel-loader": "^8.0.5",
    "clean-webpack-plugin": "^2.0.2",
    "copy-webpack-plugin": "^5.0.3",
    "css-loader": "^3.0.0",
    "eslint": "^5.16.0",
    "eslint-loader": "^2.1.2",
    "file-loader": "^4.0.0",
    "html-webpack-plugin": "^4.0.0-beta.5",
    "mini-css-extract-plugin": "^0.7.0",
    "node-sass": "^4.12.0",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "webpack": "^4.29.6",
    "webpack-bundle-analyzer": "^3.3.2",
    "webpack-cli": "^3.3.0",
    "webpack-dev-server": "^3.2.1",
    "webpack-merge": "^4.2.1"
  },
  "dependencies": {
    "@babel/polyfill": "^7.4.0",
    "clearbit": "^1.3.4",
    "core-js": "^3.0.1"
  }
}

is there anything I can do to decrease the size?

my script is just a js with this example from the docs:

var clearbit = require('clearbit')('sk_<redacted>');

clearbit.Enrichment.find({email: 'alex@clearbit.com', stream: true})
  .then(function (response) {
    var person  = response.person;
    var company = response.company;

    console.log('Name: ', person && person.name.fullName);
  })
  .catch(function (err) {
    console.error(err);
  });

I guess this is because it's meant to be used in node and not in the front end. But it can probably be optimised a little. Like it's only using three methods of lodash and still imports *

@t-richards
Copy link

Hi @kilinkis,

I guess this is because it's meant to be used in node and not in the front end. But it can probably be optimised a little. Like it's only using three methods of lodash and still imports *

You're correct here on both counts.

  1. This library was not designed to be used in the browser. Especially because placing your secret key in your JS bundle would expose it to everyone! This is not good.

    var clearbit = require('clearbit')('sk_<redacted>'); // Don't do this
    
  2. It wouldn't be a bad idea to trim down the giant lodash import and prune other unnecessary dependencies from this library.

@kilinkis
Copy link
Author

You're right, for a moment I thought that was a public key.

Thanks for your answer @t-richards :)
I guess you can close this issue now.

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

No branches or pull requests

2 participants