davidmarkclements / fast-safe-stringify

Safely and quickly serialize JavaScript objects
MIT License
348 stars 27 forks source link

Fails to babelify #31

Closed binarykitchen closed 6 years ago

binarykitchen commented 6 years ago

Because you use const in your source.

Dont want to force global babelification due to bad performance.

Maybe can add this in your package.json?

{
  "browserify": {
    "transform": ["babelify"]
  }
}

See: https://github.com/babel/babelify#why-arent-files-in-node_modules-being-transformed

binarykitchen commented 6 years ago

Or have a main entry in your package.json pointing to a plain JS file for distribution that has no const

mcollina commented 6 years ago

@binarykitchen I would actually go to remove const, if it's just that. Can you send a PR?

BridgeAR commented 6 years ago

This was actually intentional. All modern browsers support const (see also https://caniuse.com/#search=const) and it is possible to pin the version to 1.x in case someone needs a older support. So I am not that sure if we should really change that.

davidmarkclements commented 6 years ago

That being said, if someone babelifies for any reason we don't want a util that may be deep in a dep tree to break transpilation. If it's just const let's change it to var - it will cause the least friction

binarykitchen commented 6 years ago

@BridgeAR yeah browsers support const, although uglify complains.

looking at index.js, it's only 7 const's to replace to make it work anywhere without the need to transpile, interpret anything. isn't that too much to ask?

BridgeAR commented 6 years ago

For me it is not really about "too much to ask" but more about getting the ecosystem to move on. The less libraries are supported, the more others will have to catch up. I know it can be a pain though as user. Due to that I am fine with changing it.

binarykitchen commented 6 years ago

ok, want a PR from me?

davidmarkclements commented 6 years ago

@binarykitchen PR would be welcome!

binarykitchen commented 6 years ago

here u go https://github.com/davidmarkclements/fast-safe-stringify/pull/33