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

Requiring slug with browserify includes a 1.8MB file #59

Open
jshakes opened this issue Jan 27, 2016 · 8 comments
Open

Requiring slug with browserify includes a 1.8MB file #59

jshakes opened this issue Jan 27, 2016 · 8 comments

Comments

@jshakes
Copy link

jshakes commented Jan 27, 2016

After some investigation into why my Browserify output file was so huge, I found the unicode dependency in package.json (https://www.npmjs.com/package/unicode) contains a 1.8MB file called So.js. How important is this file, and is there any way we can do without it? I can't continue using slug for my front-end application if it means doubling the footprint of my Browserify file

@ralyodio
Copy link

just curious, why are you generating slugs on the client side?

@jshakes
Copy link
Author

jshakes commented Jan 27, 2016

In my case I'm just using it to make an HTML attribute value from a string,
but there are many cases where we use slug generation on the front-end,
including here on Github

screen shot 2016-01-27 at 1 19 50 pm

@ralyodio
Copy link

i would make an endpoint you can call.

@jshakes
Copy link
Author

jshakes commented Jan 27, 2016

With all due respect, that's besides the point. Nowadays npm packages are increasingly being used isomorphically, especially with platforms like Meteor.

For a precedent, see the node-slug npm package which provides a flag specifically for this scenario: https://github.com/dodo/node-slug#browser

@ralyodio
Copy link

with all due respect just because they can be used isomorphically doesn't mean they should be used that way.

@michaelfavia
Copy link

FWIW We were bit by this same issue it tripled the size of our clientside webpacked bundle. To be fair we discovered your module as a result of our previous routing work on the backend but the 1.8mb payload was a bit of a surprise. Replaced with https://github.com/pid/speakingurl

@Zertz
Copy link
Contributor

Zertz commented Apr 22, 2016

You can use const slug = require('slug/slug-browser') and add exclude: ['node_modules/unicode/category/So.js'] to Browserify's options.

We also use slugs client-side because it's far faster then calling an endpoint just to give the user a quick preview and the minified code is tiny.

@barbalex
Copy link

barbalex commented Jun 2, 2017

I ran into the same problem too. @michaelfavia thanks for mentioning https://github.com/pid/speakingurl: 12.7KB vs. 1.7MB!!!

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

5 participants