Comments (21)
I really don't agree that it hurts more than it helps; "more bytes than needed" is barely an inconvenience.
The proper approach is for packages - which can make no assumptions about their target environments - to be maximally backwards-compatible and safe, and for apps - where target environments are known and bundlers/build tools are in use - to do whatever patches are needed.
For example, if you only support environments where Function.prototype.bind
exists, you can tell your bundler to replace require('function-bind')
with Function.bind
, and remove the package entirely. You can similarly replace has
with Object.hasOwn
if that's always available.
from qs.
I am saying this hurts us more than it helps. I respect your goals to provide maximum backwards compatibility but our goals are different and I would like to see if we can come to some kind of compromise that doesn't involve telling our users to futz with bundler configuration.
from qs.
Maintaining support for old versions of phantomjs, Internet Explorer < 9, and node < 0.6 doesn't make any kind of business sense for us when it complicates the happy path for our users, none of whom are using our packages in those environments.
from qs.
Understood.
I'm not sure it's a viable compromise to add additional weight - and a redundant implementation, forcing all future changes to be made in two places - versus you making a bundler config/plugin that has all the tweaks and users can easily use?
from qs.
Especially considering that even if I did what you asked for qs, I maintain hundreds of packages that follow these same patterns - using a bundler is a holistic approach that can work for every current and future instance of this pattern, instead of just trying to fix it one npm package at a time.
from qs.
what about using an export map to override a module that exports side-channel
with a non-polyfilled implementation in more modern environments/bundlers that read the export map? For example
// stringify.js
const getSideChannel = require('qs/side-channel')
{
"name": "qs",
"exports": {
"./side-channel": {
"legacy": "./side-channel.js",
"default": "./side-channel-nopolyfill.js"
}
}
}
The minority of users who would need to support really old environments could set the legacy
exports condition in their bundler if necessary
from qs.
I think when it comes to really old environments it makes more sense for the compatibility polyfills to be opt-in. That seems to be the philosophy of most other packages I've dealt with...in general the Node ecosystem drops support for old environments too quickly IMO, so I like that you care about maintaining more backwards compatibility, but supporting old versions of phantomjs, Internet Explorer < 9, and node < 0.6 without manual configuration in this day and age seems extreme in the opposite direction. I think most devs would expect to need to manually configure polyfills for many packages to work in such old environments now.
from qs.
I'm not always opposed to configuration, but this is the only package that's currently an obstacle to a zero-config solution for us, and if all packages in the ecosystem provided backwards compatibility in this way, I can imagine a scenario where I'd have to configure dozens of overrides in my bundler just to get it to build.
from qs.
I guess another question is - is there truly no way for side-channel
to work without doing a .bind
for some reason?
from qs.
To be clear, call-binding has nothing to do with old implementations - it's about robustness. The only part that's for old impls is the function-bind
package - but the actual binding is critical.
could set the legacy exports condition in their bundler if necessary
That doesn't work for node, where bundlers are usually not used.
I think when it comes to really old environments it makes more sense for the compatibility polyfills to be opt-in.
Age doesn't factor in for me.
For side-channel
, if you only support envs with WeakMap, some amount of the code could be removed, but call-bind
depends on function-bind
as mentioned, and call-bind itself is necessary. object-inspect
, similarly, uses call-binding all over the place to be robust against builtin modification.
from qs.
Related Issues (20)
- Websites that are using `qs` HOT 2
- Keeping nesting with custom decoder ? HOT 1
- qs.parse decoder option doesn't work on IOS web view environment HOT 1
- Unable to parse back a stringified object when too nested HOT 3
- `stringify` with `arrayFormat: 'comma'` does not encode commas in strings. HOT 13
- [spam]
- ESM & CJS - Built HOT 9
- Stringify null values HOT 9
- None. HOT 1
- Serialization for `Date` is not working when using `filter` option. HOT 3
- Issue using qs while using Express@5 HOT 7
- qs.stringify(json) and qs.parse(json) Results are inconsistent with expectations HOT 4
- Parsing the stringify result would lead to a different object HOT 1
- qs parse is not letting app load on production when imported from index.tsx HOT 1
- Does not work in NextJS edge middleware HOT 3
- Stringify method with format: "RFC1738" does not encode parentheses -> ( ) HOT 3
- I'm appreciate with this library, however my new project use python. Are there any same packages in Python? HOT 1
- How can you keep the square brackets when using arrayFormat: comma HOT 4
- Add required key and type checking HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qs.