Closed tada5hi closed 1 year ago
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?
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.
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).
Thank you for your assessment :blush:. 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.
@ljharb isn't qs also affected by this ? https://antfu.me/posts/publish-esm-and-cjs#tsup
@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.
cjs is universal, what is esm? Everything move to esm, it has a reason.
Can't use qs in vite (other one opened the same issue, it is closed, so i not open a new one).
@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 ? )