-
Notifications
You must be signed in to change notification settings - Fork 53
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
Browser Usage? #37
Comments
Yes, this package is definitely safe for use in a browser environment! It even gets tested in browsers! The package name is already A note in the readme about browser usage would be good to have. |
@parshap thanks for the response. Yeah, it was just the repo name that threw me off. Seeing as changing the repo name wouldn't be much of a breaking change, you may want to consider that. But yeah a note in the readme would be nice as well. |
When I try to use it in browser, I get the error
But, Buffer is a node library. FWIW, I'm using rollup w/ the resolve and CJS plugins:
|
@jslick: You'll need some implementation of the node core modules. Browserify and Webpack do this, I'm not sure what the right solution for Rollup is. |
Thanks parshap. I found the solution. It turns out, truncate-utf8-bytes specifies pkg.browser, which specifies a file that omits Node dependencies. I just had to add |
Is this package safe to use in a browser environment? By the name I was a bit worried (node-sanitize-filename) but it doesn't seem any of the deps are node dependent and, after double checking my webpack bundles, it doesn't seem like library size is an issue (minimized it added only about 2kb to my output). I also read through the code and don't see it using any node built-ins like
path
orfs
.Just wanted to check before using in a SPA so I don't run into any surprises. Also, if it's not node dependent, and you don't foresee it being so in the future, maybe it's worth renaming the package to just "sanitize-filename" so other folks don't get tripped up by that? I could see this package being useful in a variety of applications both front-end and back-end. There's a lot of questions on stack overflow pertaining to this (which is fact how I came here) and it would be nice to depend on a small package like this that's actively maintained instead of just copying and pasting regexes.
The text was updated successfully, but these errors were encountered: