2 ms·
TC39 had been talking about JS modules for about decade, before CJS even existed. CJS is unsuitable on the frond end because it's synchronous and does not enabl
by wyuenho 9y ago
TC39 had been talking about JS modules for about decade, before CJS even existed. CJS is unsuitable on the frond end because it's synchronous and does not enable static analysis. CJS being more popular on the front end is a very recent phenomenon, it really started to take off when React took off. AngularJS had its own module system and everything jQuery were essentially AMD first.
I also don't know what you are talking what we already have in fetch. It you are arguing WHATWG should have just adopted superagent, I disagree. The major difference between fetch and XHR is the ability to stream content. Fetch only needs to be better than XHR. Superagent uses XHR internally, and it's extremely difficult to have XHR support streaming without turning its API to an even bigger mess. Encoding JSON yourself is a one-liner in JS. Encoding query string is also easy, there's a whole new URL object to help you now. If not, it's just a tiny function away. It's not hard to wrap fetch at all.
- nailer 9y ago> TC39 had been talking about JS modules for about decade, before CJS even existed. Yep, which explains the ignorance. None of the other modules systems are a hundred thousandth the size of npm, so don't matter. > I also don't know what you are talking what we already have in fetch. Literally POST some JSON to a resource with a query and compare the code using superagent to the fetch API. > Encoding JSON yourself is a one-liner in JS. Encoding query string is also easy. That is irrelevant. Defaults should be sane.