googleapis / gaxios

An HTTP request client that provides an axios like interface over top of node-fetch. Super lightweight. Supports proxies and all sorts of other stuff.
Apache License 2.0
797 stars 60 forks source link

feat!: Dual-Support ESM & CJS #662

Closed danielbankhead closed 3 weeks ago

danielbankhead commented 4 weeks ago

Notable Changes

🦕

sofisl commented 4 weeks ago

I think my only concern with not using babel is that we have some unique plugins we wrote for additional functionality. I'm also concerned that if there's an error during compilation (or installation or whatever), the post-compile script won't run and then the library would fail. Seems safer to just convert those files to .cjs but I'm curious why you're interested in getting rid of babel.

danielbankhead commented 4 weeks ago

@sofisl With this strategy we can avoid babel and its added complexity of maintaining it. Are there specific features we need here that are not present?

that if there's an error during compilation (or installation or whatever), the post-compile script won't run and then the library would fail

I'm not sure I understand - if the compilation fails then library is already broken

Seems safer to just convert those files to .cjs

Unfortunately there are some gotchas with this approach; notably with renaming imports referencing these files. npm natively supports nested package.jsons and node respects the nearest package.json's type field, as outlined here:

Between the time the original doc was written and today the space has improved and simplified a ton.

generated-files-bot[bot] commented 4 weeks ago

Warning: This pull request is touching the following templated files:

sofisl commented 3 weeks ago

I'm down to try it once we move the node step into compilation (vs. postcompile).