The problem with Javascript modules = Everyone will be forced to run a full web server to do anything (to handle CORS restrictions). We all lose the ability to simply have a local index.html file, and have it Just Work (TM): This ability is amazing for demos, fast iteration, onboarding new devs and developing without a ton of layers of js ecosystem machinery. Deno doesn't care about retaining this level of developer…
CommonJS is hurting JavaScript
41–50 of 134 posts
Re: CommonJS is hurting JavaScript
#42The problem with Javascript modules = Everyone will be forced to run a full web server to do anything (to handle CORS restrictions). We all lose the ability to simply have a local index.html file, and have it Just Work (TM): This ability is amazing for demos, fast iteration, onboarding new devs and developing without a ton of layers of js ecosystem machinery. Deno doesn't care about retaining this level of developer…
Re: CommonJS is hurting JavaScript
#43The problem with Javascript modules = Everyone will be forced to run a full web server to do anything (to handle CORS restrictions). We all lose the ability to simply have a local index.html file, and have it Just Work (TM): This ability is amazing for demos, fast iteration, onboarding new devs and developing without a ton of layers of js ecosystem machinery. Deno doesn't care about retaining this level of developer…
Shouldn't that be a relative path for it to actually work as you intend?
Re: CommonJS is hurting JavaScript
#44That's all well and good, but what about those of us that already have a mountain of Jest tests with mocks that aren't supported in ESM mode? https://github.com/jestjs/jest/issues/9430 I've definitely worked around my fair share of CommonJS issues but until ESM "just works" I'm slightly pained by how aggressive the tone of this article is.
Use vitest.
Re: CommonJS is hurting JavaScript
#45Didn't see mention of Browserify and other bundlers after it that made CommonJS the defacto standard for client/browser libraries as well. I think the biggest miss was not making mixed mode (default) for Node do it the way webpack/babel, etc did it by default in terms of interop. I get they wanted to make it more implicit to call cjs from esm, in the end it just inhibits conversion of existing libraries as dependenci…
Re: CommonJS is hurting JavaScript
#46async function esmodule(commonjsModule) { return new Promise((res, rej) => res(require(commonjsModule))) }
?
Re: CommonJS is hurting JavaScript
#47[flagged]
Every time this is mentioned, the person is heavily downvoted. But if you were here in the 2000, that's exactly what happened. In fact, this very article starts with "JavaScript, the undisputed king of web development, is being sabotaged — not by a rival language or a revolutionary new technology, but by its own baggage from the past.". That's the first sentence. Nobody wanted to work with JS, it was used to make sno…
That was 23 years ago.
It's an entire generation. A baby born after that point could now be working as a fully fledged adult.
> I've yet to met anybody who knows Python/Ruby/C#/Java/Rujst/Go and JS to chose JS outside of the web. Because there, we have the choice.
I would. Typescript is easily the best language for anything from app development to small projects and has been for years now. If you're bringing up Go/Rust, then TS has been incredibly good in that timeframe. Before that there was Pythong+Django and Ruby/RoR back when we did SSR, and Java applets or flash before that.
Re: CommonJS is hurting JavaScript
#48Does anyone have a detailed understanding of why CommonJS (and its async incarnation, AMD) were not adopted by browsers? I do much like the `import` syntax personally and its a little cleaner to read, but CommonJS and AMD were the undisputed winners of the module format until ES Modules were born. Not that I have a problem with ES Modules, I don't, however I am interested in what was so insufficient about the precedi…
To be honest, I think the AMD incarnation is a complete non-starter. It’s just such a funky, weird little thing that only makes sense because it’s a compatibility shim. Nobody wants to directly author AMD, and someone shipping a JS implementation wants to ship features that people will use directly. I mean, I guess people will directly write AMD modules, and make modules using some giant script that uses cat, but the…
Re: CommonJS is hurting JavaScript
#49[flagged]
Every time this is mentioned, the person is heavily downvoted. But if you were here in the 2000, that's exactly what happened. In fact, this very article starts with "JavaScript, the undisputed king of web development, is being sabotaged — not by a rival language or a revolutionary new technology, but by its own baggage from the past.". That's the first sentence. Nobody wanted to work with JS, it was used to make sno…
But the parent lost complaining that JS exists at all is not really productive to a discussion about what effects JS today.
The “JS should have been something else” ship sailed a VERY long time ago.
It’s like people who go into C++ threads and complain it wasn’t rust from the start. That’s nice. But rust wasn’t there at the time.
It’s not useful for discussion.
Re: CommonJS is hurting JavaScript
#50That's all well and good, but what about those of us that already have a mountain of Jest tests with mocks that aren't supported in ESM mode? https://github.com/jestjs/jest/issues/9430 I've definitely worked around my fair share of CommonJS issues but until ESM "just works" I'm slightly pained by how aggressive the tone of this article is.
That’s mostly because of how Jest absolutely brutalizes the Require stack. It’s a problem with Jest AND CommonJS, not ES Modules. In fact it’s a very illustrative example of why CommonJS should be taken out back and shot.