ljharb / qs

A querystring parser with nesting support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESM & CJS - Built

tada5hi opened this issue · comments

commented

@ljharb if you are fine with it, i would create a pull request, to support different bundles for cjs and esm with rollup ( + terser for minification ? )

Why? Packages shouldn't ever bundle, only apps should - and CJS already works with ESM, and with a non-broken node module bundler. What's needed?

commented

Why? Packages shouldn't ever bundle, only apps should - and CJS already works with ESM, and with a non-broken node module bundler. What's needed?

You got a point there, but I would just use rollup for its build /transformation pipeline instead of bundling any dependencies in the output. CJS modules only work in server side (node) applications but not in the browser e.g.

CJS modules work perfectly fine in the browser via a bundler. Nobody should be deploying any JS to a browser except via a bundler.

Rollup makes a bunch of assumptions about which code it can delete that have historically caused lots of bugs, so I wouldn't ever use rollup.

commented

CJS modules work perfectly fine in the browser via a bundler. Nobody should be deploying any JS to a browser except via a bundler.

You are completely right, I just thought it would be great, if the end user can directly use this library without using a bundler.

Rollup makes a bunch of assumptions about which code it can delete that have historically caused lots of bugs, so I wouldn't ever use rollup.

Really ? I was not aware of that and had not any problems with it yet. What bundler do you recommend ? What do you think about esbuild and turobopack ?

For packages, never any bundler - for apps, browserify or webpack 4 (not 5, since it’s broken by design).

commented

Thank you for your assessment 😊. What do you recommend when you write code in TypeScript?
In that case you don't get around using something like tsc, esbuild or babel to transpile your code to JS.

Yes, you would use tsc, or preferably babel, to transpile your code (not bundle it) prepublish.

@tada5hi im not sure what you mean “affected” - certainly qs could publish a dual package, but there’d be zero benefit in doing so since CJS is the universal format.