-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: export of type definitions, depending on whether it is ES Module or CommonJS #250
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ cat >lib/esm/package.json <<!EOF | |
"type": "module" | ||
} | ||
!EOF | ||
|
||
cp index.d.ts lib/cjs/ | ||
cp index.d.ts lib/esm/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,7 @@ | |
"files": [ | ||
"es", | ||
"lib", | ||
"index.js", | ||
"index.d.ts" | ||
"index.cjs" | ||
], | ||
"scripts": { | ||
"lint": "eslint es/**/*.mjs spec/**/*.spec.mjs", | ||
|
@@ -59,14 +58,20 @@ | |
"bugs": { | ||
"url": "https://github.com/softonic/axios-retry/issues" | ||
}, | ||
"types": "./index.d.ts", | ||
"types": "lib/esm/index.d.ts", | ||
"main": "index.js", | ||
"module": "lib/esm/index.js", | ||
"exports": { | ||
".": { | ||
"types": "./index.d.ts", | ||
"import": "./lib/esm/index.js", | ||
"require": "./index.js" | ||
"import": { | ||
"types": "./lib/esm/index.d.ts", | ||
"default": "./lib/esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./lib/cjs/index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By using Incidentally, I don't think there will be any impact on the existing use of JavaScript. Because |
||
"default": "./index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when use
=
, below error occur. So, i change todefault
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the reason for why an import like:
no longer works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yutak23 how/when did you get that error? Did it work with version of axios-retry prior to your change?
I'm thinking that we could just revert to the old code if your error was not introduced by these changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rchl
When compiling to CommonJS,
export =
is fine, but when compiling to ES Module,export =
will result in the following error Therefore, we changed it to default export.#250 (comment)
However, the modification to export
IAxiosRetryConfig
etc. for name import was omitted. Sorry about that. I have uploaded the fix in the #252.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did
export =
really create an issue and in what circumstances? I haven't seen issues after changing it in this project and building.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be very grateful if you could provide me with details of the configuration information for your TypeScript project.
The problem I am talking about happens when compiling to ES Module with ES Module configuration (set
type: module
in package.json)When
export =
, the following compile error occurs. Whenexport default
is used, no error occurs.My environment is below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question is: did this work before (before v3.9.0)?
Because if not then there is not really a need to change that now. Could do that in next major version if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is already becoming Revert's policy, but I think it would be rude not to answer your question, so I want to answer.
The type definition used to be
export default
and it worked except for the ES Module. . However, this had a problem with issue and has been modified. But then another problem arose and more changes were made.axios-retry/index.d.ts
Line 66 in 0f50dc9