-
-
Notifications
You must be signed in to change notification settings - Fork 3
fix: cleanup build #104
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
base: master
Are you sure you want to change the base?
fix: cleanup build #104
Conversation
src/index.ts
Outdated
| ); | ||
|
|
||
| const defaultParse = <$Body>(response: Response): Promise<$Body> => | ||
| const defaultParse = (response: Response): Promise<any> => |
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.
Hi @dword-design what was the reason to remove these types?
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.
Reason was that the typing in the current TypeScript reason leads to errors. response.json() returns just any (but which is not optimal imho), and response.text() returns a string. The problem is that response.text() contradicts with $Body. If that special handling wouldn't be there, Promise<$Body> would work. Setting Promise<$Body | string> leads to TypeScript errors when building.
Setting it to Promise<any> is not good though, so better have the types clean.
| "scripts": { | ||
| "test": "jest", | ||
| "build": "webpack && tsc", | ||
| "build": "tsc", |
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.
Hey @dword-design thanks for the contribution! We're able to remove Webpack because we no longer need to transpile now that we're on ESM?
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.
Yeah. I'd say Node.js runs right away and for the browser it should be possible to either use a bundler for the end-user project or import ESM. I tried it for defaults which only has an ESM export (and 29M downloads) and it works:
<!-- index.html -->
<script type="module">
import defaults from "https://esm.sh/defaults";
console.log(defaults({ a: 2 }, { a: 1, b: 2 }));
</script>| @@ -1,2 +0,0 @@ | |||
| declare module 'parse-link-header'; | |||
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.
Hi @dword-design what's the reason this type isn't needed anymore?
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.
Why would we need it? It's imported in src/index.ts.
I got this error the last time I used the lib in a project:
So I decided to clean up the build and to migrate to ESM.