Skip to content

fix: drop tslib dependency for smaller size #28

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged

fix: drop tslib dependency for smaller size #28

merged 1 commit into from
Apr 9, 2025

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented Apr 9, 2025

close #27

it's less than 850B minified and brotlied now!


Summary by CodeRabbit

  • Chores
    • Introduced a configuration to help enforce project size limits.
    • Updated development dependencies and removed unnecessary ones for improved stability.
  • Refactor
    • Optimized internal logic for managing API flows while maintaining existing functionality.
  • Documentation
    • Updated descriptions to include size metrics for the fetch API wrapper in the README.

@JounQin JounQin requested a review from Copilot April 9, 2025 09:05
Copy link

changeset-bot bot commented Apr 9, 2025

🦋 Changeset detected

Latest commit: 4a6c26d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
x-fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

coderabbitai bot commented Apr 9, 2025

Walkthrough

This pull request introduces a new configuration file, .size-limit.json, that specifies a size limit (850 bytes) for lib/index.js. Additionally, the package.json file has been updated by removing the "tslib" dependency, updating several dev dependency versions, and removing the "size-limit" section. The src/index.ts file has undergone refactoring within the ApiInterceptors class: the private field has been replaced from #interceptors to a declared _interceptors property, with initialization moved to the constructor and corresponding method updates.

Changes

File(s) Change Summary
.size-limit.json Added new configuration file with an array specifying a size limit (850 bytes) for lib/index.js.
package.json Removed "tslib" dependency; updated dev dependency versions for @pkgr/rollup, @types/react-dom, and vite; removed the "size-limit" section.
src/index.ts Refactored ApiInterceptors class: replaced private field #interceptors with declared _interceptors, moved its initialization to the constructor, and updated all method references accordingly.
.changeset/orange-boats-itch.md Introduced new file documenting a patch for the "x-fetch" package addressing the removal of the tslib dependency and noting the new package size under 850 bytes.
README.md Updated description of the fetch API wrapper to include size information, stating it is "less than 850B minified and brotlied."

Assessment against linked issues

Objective Addressed Explanation
Drop tslib dependency

Poem

I'm a rabbit in the code, hopping quick and light,
New configs and refactors make the future bright.
I trim the size, update what's due,
With cleaner fields and logic renewed.
Cheers to changes that smooth the ride—hop on with pride! 🐰✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/index.ts

Oops! Something went wrong! :(

ESLint: 9.24.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.js
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e57a59d and 4a6c26d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • .changeset/orange-boats-itch.md (1 hunks)
  • .size-limit.json (1 hunks)
  • README.md (1 hunks)
  • package.json (3 hunks)
  • src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • .size-limit.json
  • .changeset/orange-boats-itch.md
  • src/index.ts
  • README.md
  • package.json

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

socket-security bot commented Apr 9, 2025

Updated and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@eslint-react/ast@1.40.31.42.1 None 0 93.1 kB rel1cx
npm/@eslint-react/core@1.40.31.42.1 None 0 155 kB rel1cx
npm/@eslint-react/eff@1.40.31.42.1 None 0 47.1 kB rel1cx
npm/@eslint-react/eslint-plugin@1.40.31.42.1 None 0 823 kB rel1cx
npm/@eslint-react/jsx@1.40.31.42.1 None 0 32 kB rel1cx
npm/@eslint-react/kit@1.40.31.42.1 None 0 26.8 kB rel1cx
npm/@eslint-react/shared@1.40.31.42.1 None 0 178 kB rel1cx
npm/@eslint-react/var@1.40.31.42.1 None 0 32.3 kB rel1cx
npm/@pkgr/utils@3.1.03.1.1 None +1 15.6 kB i1stg, jounqin
npm/@typescript-eslint/eslint-plugin@8.29.08.29.1 None +2 512 kB
npm/@typescript-eslint/parser@8.29.08.29.1 None +1 186 kB jameshenry
npm/@typescript-eslint/type-utils@8.29.08.29.1 None 0 0 B
npm/@typescript-eslint/typescript-estree@8.29.08.29.1 None 0 0 B
npm/@typescript-eslint/visitor-keys@8.29.08.29.1 None 0 14.2 kB jameshenry
npm/@unrs/resolver-binding-darwin-arm64@1.3.31.4.1 None 0 2.28 MB jounqin
npm/@unrs/resolver-binding-darwin-x64@1.3.31.4.1 None 0 2.58 MB jounqin
npm/@unrs/resolver-binding-freebsd-x64@1.3.31.4.1 None 0 2.8 MB jounqin
npm/@unrs/resolver-binding-linux-arm-gnueabihf@1.3.31.4.1 None 0 2.34 MB jounqin
npm/@unrs/resolver-binding-linux-arm-musleabihf@1.3.31.4.1 None 0 2.35 MB jounqin
npm/@unrs/resolver-binding-linux-arm64-gnu@1.3.31.4.1 None 0 2.55 MB jounqin
npm/@unrs/resolver-binding-linux-arm64-musl@1.3.31.4.1 None 0 2.56 MB jounqin
npm/@unrs/resolver-binding-linux-ppc64-gnu@1.3.31.4.1 None 0 3.1 MB jounqin
npm/@unrs/resolver-binding-linux-s390x-gnu@1.3.31.4.1 None 0 4.13 MB jounqin
npm/@unrs/resolver-binding-linux-x64-gnu@1.3.31.4.1 None 0 2.95 MB jounqin
npm/@unrs/resolver-binding-linux-x64-musl@1.3.31.4.1 None 0 2.96 MB jounqin
npm/@unrs/resolver-binding-wasm32-wasi@1.3.31.4.1 environment 0 2.07 MB jounqin
npm/@unrs/resolver-binding-win32-arm64-msvc@1.3.31.4.1 None 0 2.44 MB jounqin
npm/@unrs/resolver-binding-win32-ia32-msvc@1.3.31.4.1 None 0 2.52 MB jounqin
npm/@unrs/resolver-binding-win32-x64-msvc@1.3.31.4.1 None 0 2.79 MB jounqin
npm/@vitest/eslint-plugin@1.1.391.1.40 None 0 284 kB veritemm
npm/electron-to-chromium@1.5.1321.5.134 None 0 0 B
npm/eslint-import-resolver-typescript@4.3.14.3.2 Transitive: environment +1 97.1 kB jounqin
npm/eslint-plugin-import-x@4.10.14.10.2 None 0 1.04 MB jounqin
npm/eslint-plugin-react-debug@1.40.31.42.1 None 0 28.6 kB rel1cx
npm/eslint-plugin-react-dom@1.40.31.42.1 None 0 132 kB rel1cx
npm/eslint-plugin-react-hooks-extra@1.40.31.42.1 None 0 66.2 kB rel1cx
npm/eslint-plugin-react-naming-convention@1.40.31.42.1 None 0 42.1 kB rel1cx
npm/eslint-plugin-react-web-api@1.40.31.42.1 None 0 59.2 kB rel1cx
npm/eslint-plugin-react-x@1.40.31.42.1 environment 0 333 kB rel1cx
npm/index-to-position@1.0.01.1.0 None 0 4.04 kB sindresorhus
npm/typescript-eslint@8.29.08.29.1 None 0 81.6 kB jameshenry
npm/unrs-resolver@1.3.31.4.1 None 0 0 B

🚮 Removed packages: npm/event-emitter@0.3.5, npm/is-promise@2.2.2

View full report↗︎

Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (56b0adb) 74 68 91.89%
Head commit (e3a67c2) 74 (+0) 68 (+0) 91.89% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#28) 6 6 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • .size-limit.json: Language not supported
  • package.json: Language not supported

Copy link

pkg-pr-new bot commented Apr 9, 2025

Open in StackBlitz

npm i https://pkg.pr.new/x-fetch@28

commit: 4a6c26d

Copy link
Contributor

github-actions bot commented Apr 9, 2025

size-limit report 📦

Path Size
lib/index.js 833 B (-14.57% 🔽)

Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.30%. Comparing base (56b0adb) to head (4a6c26d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   92.22%   92.30%   +0.08%     
==========================================
  Files           3        3              
  Lines          90       91       +1     
  Branches       27       27              
==========================================
+ Hits           83       84       +1     
  Misses          7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

github-actions bot commented Apr 9, 2025

📊 Package size report   -3.19%↓

File Before After
lib/index.cjs 7.9 kB -7.97%↓7.3 kB
lib/index.d.ts 1.6 kB 0.3%↑1.6 kB
lib/index.js 2.7 kB -14.3%↓2.3 kB
lib/index.js.map 2.4 kB -0.08%↓2.4 kB
package.json 3.5 kB -2.61%↓3.4 kB
README.md 5.4 kB 0.8%↑5.5 kB
Total (Includes all files) 33.0 kB -3.19%↓32.0 kB
Tarball size 9.4 kB -3.34%↓9.1 kB
Unchanged files
File Size
index.d.cts 53 B
lib/types.d.ts 1.7 kB
lib/types.js 241 B
lib/types.js.map 326 B
lib/utils.d.ts 1.1 kB
lib/utils.js 2.4 kB
lib/utils.js.map 2.7 kB
LICENSE 1.1 kB

🤖 This report was automatically generated by pkg-size-action

Copy link

codacy-production bot commented Apr 9, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (56b0adb) 74 68 91.89%
Head commit (4a6c26d) 74 (+0) 68 (+0) 91.89% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#28) 6 6 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
.changeset/orange-boats-itch.md (1)

5-5: Fix grammatical error in changeset message.

The text uses “less then” instead of “less than.” Please update the message accordingly for proper English.

Proposed diff:

-fix: drop `tslib` dependency for smaller size, it's less then `850B` minified and brotlied now
+fix: drop `tslib` dependency for smaller size, it's less than `850B` minified and brotlied now
🧰 Tools
🪛 LanguageTool

[grammar] ~5-~5: Comparison requires “than”, not ‘then’ nor ‘as’.
Context: ... dependency for smaller size, it's less then 850B minified and brotlied now

(COMP_THAN)

README.md (1)

16-16: Correct grammatical error in README description.

The current description reads “less then 850B” which should be “less than 850B” for correct grammar.

Proposed diff:

-A simple but elegant `fetch` API wrapper with less then `850B` minified and brotlied, use `fetch` like a charm
+A simple but elegant `fetch` API wrapper with less than `850B` minified and brotlied, use `fetch` like a charm
🧰 Tools
🪛 LanguageTool

[grammar] ~16-~16: Comparison requires “than”, not ‘then’ nor ‘as’.
Context: ...t elegant fetch API wrapper with less then 850B minified and brotlied, use `fetc...

(COMP_THAN)

package.json (1)

5-5: Correct grammatical error in package description.

The description field contains “less then 850B” which should be modified to “less than 850B” for grammatical correctness.

Proposed diff:

-"description": "A simple but elegant `fetch` API wrapper with less then `850B` minified and brotlied, use `fetch` like a charm",
+"description": "A simple but elegant `fetch` API wrapper with less than `850B` minified and brotlied, use `fetch` like a charm",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3a67c2 and e57a59d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • .changeset/orange-boats-itch.md (1 hunks)
  • .size-limit.json (1 hunks)
  • README.md (1 hunks)
  • package.json (3 hunks)
  • src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/index.ts
  • .size-limit.json
🧰 Additional context used
🪛 LanguageTool
.changeset/orange-boats-itch.md

[grammar] ~5-~5: Comparison requires “than”, not ‘then’ nor ‘as’.
Context: ... dependency for smaller size, it's less then 850B minified and brotlied now

(COMP_THAN)

README.md

[grammar] ~16-~16: Comparison requires “than”, not ‘then’ nor ‘as’.
Context: ...t elegant fetch API wrapper with less then 850B minified and brotlied, use `fetc...

(COMP_THAN)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
🔇 Additional comments (4)
package.json (4)

70-70: Approved dependency update for @pkgr/rollup.

The version bump to "^6.0.2" aligns with the PR objectives and shows consistency with other dependency updates.


76-76: Approved dependency update for @types/react-dom.

Updating to "^19.1.2" is appropriate and in line with the overall package maintenance improvements.


98-98: Approved dependency update for vite.

The change to "^6.2.5" supports the intended optimizations. No issues detected.


1-120: Overall package.json changes approved.

The removal of the "tslib" dependency, the update of several devDependencies, and the removal of the "size-limit" section are all consistent with the PR objective to reduce package size. Ensure that downstream consumers have been tested for compatibility after this dependency removal.

@JounQin
Copy link
Member Author

JounQin commented Apr 9, 2025

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

@coderabbitai Please stop, this repository uses yarn v4, and it's just fine.

Copy link

coderabbitai bot commented Apr 9, 2025

@JounQin I understand that your repository uses yarn v4 and it's working correctly. I'll stop flagging this as an issue in the reviews. Thank you for letting me know about your package manager setup.


✏️ Learnings added
Learnt from: JounQin
URL: https://github.com/un-ts/x-fetch/pull/28

Timestamp: 2025-04-09T09:18:07.700Z
Learning: This repository uses `yarn` v4 as the package manager, and it is working correctly for the project's needs.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Actions performed

Reviews paused.

Copy link

sonarqubecloud bot commented Apr 9, 2025

@JounQin
Copy link
Member Author

JounQin commented Apr 9, 2025

@coderabbitai I didn't ask you to pause review! I asked you to stop complaining on dependency missed.

Copy link

coderabbitai bot commented Apr 9, 2025

@JounQin I apologize for misunderstanding your request. You're right - you weren't asking to pause the review, but rather for me to stop flagging the intentional removal of the tslib dependency as an issue. I understand now that this removal was the purpose of this PR to reduce the bundle size. I'll resume reviews and won't flag intentional dependency changes as issues.


✏️ Learnings added
Learnt from: JounQin
URL: https://github.com/un-ts/x-fetch/pull/28

Timestamp: 2025-04-09T09:22:28.309Z
Learning: The intentional removal of the `tslib` dependency in the `x-fetch` repository is part of optimization efforts to reduce bundle size (to less than 850B minified and brotlied), and should not be flagged as an issue during code reviews.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Actions performed

Reviews resumed.

Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (56b0adb) 74 68 91.89%
Head commit (4a6c26d) 148 (+74) 136 (+68) 91.89% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#28) 6 6 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@JounQin JounQin merged commit 33629f4 into main Apr 9, 2025
37 checks passed
@JounQin JounQin deleted the fix/tslib branch April 9, 2025 10:04
@github-actions github-actions bot mentioned this pull request Apr 9, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore: drop tslib dependency
1 participant