ljharb / qs

A querystring parser with nesting support
BSD 3-Clause "New" or "Revised" License
8.5k stars 729 forks source link

Remove node builtin dependency #407

Closed PFight closed 3 years ago

PFight commented 3 years ago

Using qs I have troubles in browser bundling:

Rollup: "Creating a browser bundle that depends on Node.js built-in module ('util'). You might need to include https://github.com/ionic-team/rollup-plugin-node-polyfills"

Reason is that you use side-channel package in lib\stringify.js file. Then side-channel use object-inspect package, wich requires util package in util.inspect.js file.

It is not good to depend on node builtins, so it would be better to remove side-channel dependecy.

Related https://github.com/inspect-js/object-inspect/issues/38, https://github.com/ljharb/side-channel/issues/10

ljharb commented 3 years ago

A non-broken node module bundler must polyfill node builtins. They will never be removed.

quarkus commented 2 months ago

As we tend to stumble over this issue again every other year .. importing the dist bundle in our rollup es build did the job for us.

import qs from 'qs/dist/qs';

ljharb commented 2 months ago

@quarkus just be aware that if i ever do a v7, that file will no longer be provided.

Either way, the browser field in object-inspect should automatically be handled by bundlers, and not attempt to include util.inspect, so it's definitely a bug in your bundler if this is a problem.