Closed yutak23 closed 1 year ago
@mindhells
To avoid increased maintenance costs I have changed the content of the PR from https://github.com/softonic/axios-retry/pull/230.
I would appreciate it if you could review and respond to the content of the PR so that it can be made available to ES Module projects.
LGTM and don't expect any impact on CommonJS either, but I'll publish as a new minor just in case.
Published as 3.7.0 Thanks a lot @yutak23
This ought to fix https://github.com/softonic/axios-retry/issues/228
ESM seems incompatible in CommonJS PJs with default export (see https://github.com/microsoft/TypeScript/issues/52086). I think there are two solutions to make TypeScript types compatible with both CommonJS and ESM.
Case
1
, I would make a copy of the currentindex.d.ts
, rename the file toindex.d.mts
, and change package.json as follows.However, I think this is redundant and low-maintainability because we have to manage two type definitions, so I tried to modify it in the second way(Case
2
).Explanation of this modification
export =
, both CommonJS and ESM are supported. I do not expect any impact on existing CommonJS implementations of TypeScript developers. Originally, when usingexport default
, as described in Default Exports, theesModuleInterop
option must be used, and testing has confirmed that it can be compiled with this setting. Also, testing confirms that the project can be compiled with the project in the ESM configuration.For this change, I refer to the following