apify / got-scraping

HTTP client made for scraping based on got.
423 stars 32 forks source link

ESM got or CJS got in the future? #56

Closed longnguyen2004 closed 9 months ago

longnguyen2004 commented 2 years ago

I'm trying to use ESM everywhere in my project, so I want my dependencies to be ESM. I happened to use both got and got-scraping in a project, but I noticed got-scraping depends on got-cjs, while got is now ESM, which means there are 2 different got versions installed. Will got-scraping eventually switch to ESM got, when v12 is out of beta?

szmarczak commented 2 years ago

Probably we'll stay with CJS for now. It's good to see that you're into ESM :) However there is still others that need to switch, and the number of them is yet to increase.

/cc @B4nan

B4nan commented 2 years ago

Yes, this package will stay CJS for now as we need it to be CJS. We will probably make it part of the Apify SDK monorepo in upcoming months, where we plan to ship hybrid ESM support via gen-esm-wrapper. Let's hope the ESM support will get better soon and we will be able to use ESM version of got directly, until then, we will depend on the CJS fork.

shishkin commented 2 years ago

Any particular reason this package can't target both ESM and CJS?

I'm working with AWS lambdas, which started to support native ESM and Node16 recently. To get benefits of dead code elimination it doesn't help to just wrap CJS code, it needs to use static imports and exports instead.

longnguyen2004 commented 1 year ago

It's been 2023, and ESM support in Node is pretty solid by now. When will we switch to ESM?

JaneJeon commented 1 year ago

Want to throw a +1 vote for ESM as well. While there are still rough spots in tooling (e.g. eslint-plugin-import notably has numerous issues w.r.t ESM and package.json exports, and the lead maintainer there is quite stubborn in his refusal to support it), the "base" tooling (node/package management/IDE/typescript/jest/etc) is good enough that I've been able to migrate over my codebase to ESM piece by piece.

Furthermore, it's clear that having to maintain got-cjs, keeping it up to date with baseline got (i.e. it's now a major version behind), and keeping the imports of got-scraping's dependencies "kosher" (some of the non-got dependencies are now ESM-only as well), is only going to further increase the "resistance" of keeping things up to date, so to speak:

CleanShot 2023-07-01 at 00 08 02@2x
B4nan commented 1 year ago

FYI we will be moving this package to ESM in the following months, it just wasn't a priority but we were planning it for quite some time now.

JaneJeon commented 1 year ago

Really great to see it, I'll be looking forward to it!

B4nan commented 9 months ago

Closing in favor of #108