8000 chore: extract reactivity by Shinigami92 · Pull Request #42 · un-ts/unuse · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: extract reactivity #42

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

Merged
merged 1 commit into from
Jun 27, 2025
Merged

chore: extract reactivity #42

merged 1 commit into from
Jun 27, 2025

Conversation

Shinigami92
Copy link
Member
@Shinigami92 Shinigami92 commented Jun 26, 2025

based on #28

extracts the reactivity signals into its own package, but does not publish it
instead it is marked as noExternal and bundled into unuse's dist

this is a preparation to enhance the reactivity system with more stuff like unEffect and dependency tracking as started and shown in #27 and #22 by @teleskop150750


Important

Extracts reactivity signals into unuse-reactivity package, bundled into unuse, preparing for future enhancements.

  • Reactivity Extraction:
    • Extracts reactivity signals into unuse-reactivity package, bundled into unuse using noExternal.
    • Prepares for future enhancements like unEffect and dependency tracking.
  • File Moves:
    • Moves unComputed, unEffect, unEffectScope, unSignal, unWatch from unuse/src to unuse-reactivity/src.
  • Package Configuration:
    • Adds package.json and tsdown.config.ts for unuse-reactivity.
    • Updates unuse/package.json to include unuse-reactivity as a dependency.
  • Import Updates:
    • Updates imports in unuse/src to use unuse-reactivity for reactivity functions.
  • Tests:
    • Updates tests in toUnSignal and unResolve to use unuse-reactivity.

This description was created by Ellipsis for cfde585. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Introduced a new internal reactivity system as part of the package distribution.
  • Documentation

    • Added a README for the new reactivity system, outlining its usage and current development status.
  • Chores

    • Updated package configurations and dependencies to integrate the internal reactivity system.
    • Adjusted build settings to include the new system as a bundled dependency.
  • Refactor

    • Consolidated imports across the codebase to use the new internal reactivity system.

@Shinigami92 Shinigami92 self-assigned this Jun 26, 2025
Copy link
changeset-bot bot commented Jun 26, 2025

⚠️ No Changeset found

Latest commit: cfde585

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
coderabbitai bot commented Jun 26, 2025

Walkthrough

A new unuse-reactivity package was introduced, encapsulating core reactivity primitives and consolidating their exports. The unuse package was refactored to import these primitives from unuse-reactivity instead of local modules. Build configurations and related imports throughout the codebase were updated to reflect this modularization.

Changes

File(s) Change Summary
packages/unuse-reactivity/README.md, package.json, tsdown.config.ts, src/index.ts Added new unuse-reactivity package with documentation, configuration, entry point, and metadata.
packages/unuse/package.json, tsdown.config.ts Added unuse-reactivity as a dependency and updated build config to treat it as internal.
packages/unuse/src/index.ts Re-exported all from unuse-reactivity; removed direct exports of reactivity primitives.
packages/unuse/src/toUnSignal/*.spec.ts, index.ts Updated imports to source reactivity utilities from unuse-reactivity instead of local modules.
packages/unuse/src/unAccess/index.spec.ts, index.ts Changed imports of reactivity types and guards to come from unuse-reactivity.
packages/unuse/src/unResolve/*.spec.ts, index.ts Consolidated imports of reactivity types/functions to unuse-reactivity.
packages/unuse/src/useEventListener/index.ts Unified imports of unComputed and unWatch from unuse-reactivity.
packages/unuse/src/useIntervalFn/index.ts Unified imports of unSignal and unWatch from unuse-reactivity.
packages/unuse/src/useWebSocket/index.ts Unified imports of unSignal and unWatch from unuse-reactivity.

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant unuse
  participant unuse-reactivity

  Consumer->>unuse: import { unSignal, unEffect, ... }
  unuse->>unuse-reactivity: re-export primitives
  unuse-reactivity-->>unuse: provides reactivity primitives
  unuse-->>Consumer: exposes reactivity primitives
Loading

Possibly related PRs

  • feat: unEffect and unEffectScope #43: Introduces the new unuse-reactivity package and consolidates core reactive primitives, directly related to this modularization.
  • fix: reactivity #10: Modifies the toUnSignal function for reactive synchronization, which is now updated to use unuse-reactivity.

Suggested labels

feature

Suggested reviewers

  • JounQin

Poem

In the warren, code hops anew,
Reactivity bundled, fresh and true.
Imports now leap from a single source,
Keeping our modules right on course.
With every hop, our code grows light—
Modular, nimble, and bunny-bright!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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
Contributor
github-actions bot commented Jun 26, 2025

Coverage Report

Status Category Percentage Covered / Total
🔴 Lines 78.26% (🎯 90%)
⬇️ -0.16%
972 / 1242
🔴 Statements 78.26% (🎯 90%)
⬇️ -0.16%
972 / 1242
🔴 Functions 78.82% (🎯 90%)
⬇️ -0.94%
67 / 85
🔴 Branches 80.68% (🎯 85%)
⬇️ -0.25%
259 / 321
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/unuse-reactivity/src/index.ts 0% 0% 0% 0% 1-5
packages/unuse/src/index.ts 0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
1-14
packages/unuse/src/toUnSignal/index.ts 72.8%
⬇️ -0.24%
63.33%
🟰 ±0%
66.66%
🟰 ±0%
72.8%
⬇️ -0.24%
17-18, 31-32, 35-36, 43-44, 48, 50-51, 73-74, 81-87, 98-99, 105-106, 113-120, 130, 140-141
packages/unuse/src/unAccess/index.ts 63%
⬇️ -0.36%
75%
🟰 ±0%
66.66%
🟰 ±0%
63%
⬇️ -0.36%
43-44, 48-49, 62-63, 66-67, 71, 74-81, 84-93, 96-105, 114-115, 118-119, 122-123
packages/unuse/src/unResolve/index.ts 91.74%
⬇️ -0.07%
94.28%
🟰 ±0%
71.42%
🟰 ±0%
91.74%
⬇️ -0.07%
71-72, 93-94, 99, 125-128
packages/unuse/src/useEventListener/index.ts 96.34%
⬇️ -0.04%
86.66%
🟰 ±0%
100%
🟰 ±0%
96.34%
⬇️ -0.04%
192-193, 198
packages/unuse/src/useIntervalFn/index.ts 92.85%
⬇️ -0.13%
80%
🟰 ±0%
100%
🟰 ±0%
92.85%
⬇️ -0.13%
77-78, 82-83
packages/unuse/src/useWebSocket/index.ts 46.66%
⬇️ -0.27%
41.66%
🟰 ±0%
33.33%
🟰 ±0%
46.66%
⬇️ -0.27%
161-163, 203-212, 216-218, 222-224, 233-235, 244-256, 262-263, 270-275, 278-308, 311-312, 315-326, 330-355, 367-368
Unchanged Files
packages/unuse-angular/src/index.ts 94.2% 100% 83.33% 94.2% 143-146
packages/unuse-react/src/index.ts 69.86% 68.18% 100% 69.86% 49-55, 58-71, 139-143, 152
packages/unuse-reactivity/src/unComputed/index.ts 100% 100% 100% 100%
packages/unuse-reactivity/src/unEffect/index.ts 100% 100% 100% 100%
packages/unuse-reactivity/src/unEffectScope/index.ts 100% 100% 100% 100%
packages/unuse-reactivity/src/unSignal/index.ts 100% 100% 100% 100%
packages/unuse-reactivity/src/unWatch/index.ts 100% 100% 100% 100%
packages/unuse-solid/src/index.ts 83.09% 86.95% 100% 83.09% 52-59, 69, 141-145
packages/unuse-vue/src/index.ts 100% 100% 100% 100%
packages/unuse/src/_framework/index.ts 81.53% 62.5% 100% 81.53% 48-49, 67-68, 76-77, 85-86, 94-95, 102-103
packages/unuse/src/_testUtils/angular.ts 100% 100% 100% 100%
packages/unuse/src/_testUtils/react.ts 100% 100% 100% 100%
packages/unuse/src/_testUtils/solid.ts 100% 100% 100% 100%
packages/unuse/src/_testUtils/vue.ts 100% 100% 100% 100%
packages/unuse/src/isClient/index.ts 100% 0% 100% 100%
packages/unuse/src/isObject/index.ts 100% 100% 100% 100%
packages/unuse/src/isWorker/index.ts 66.66% 0% 100% 66.66% 5
packages/unuse/src/toArray/index.ts 100% 50% 100% 100%
packages/unuse/src/tryOnScopeDispose/index.ts 77.77% 78.57% 50% 77.77% 11-14, 23-24, 35-36, 40-41
packages/unuse/src/unRefElement/index.ts 75% 33.33% 100% 75% 29, 36-37
Generated in workflow #107 for commit cfde585 by the Vitest Coverage Report Action

@Shinigami92 Shinigami92 force-pushed the chore-extract-reactivity branch from 6c4d78c to 9e776ab Compare June 26, 2025 15:48
@Shinigami92 Shinigami92 requested a review from JounQin June 26, 2025 15:50
@Shinigami92
Copy link
Member Author

@JounQin please have a look into this and tell me if we are going a wrong way here or if this is fine with you.
Asking depending on your feedback in #28 (reply in thread)

After this PR would get merged, my next step would be to create unEffect and replace all current effect from alien-signals with it, resulting in that alien-signals does not need to be a dependency in the other packages anymore.

@Shinigami92 Shinigami92 force-pushed the chore-extract-reactivity branch from 9e776ab to cfde585 Compare June 26, 2025 17:37
@Shinigami92 Shinigami92 requested a review from JounQin June 26, 2025 17:44
@Shinigami92 Shinigami92 marked this pull request as ready for review June 26, 2025 17:44
Copy link
Contributor
@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to cfde585 in 1 minute and 49 seconds. Click for details.
  • Reviewed 435 lines of code in 32 files
  • Skipped 1 files when reviewing.
  • Skipped posting 17 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/unuse-reactivity/tsdown.config.ts:6
  • Draft comment:
    Confirm that 'publint' is intentional; consider adding a comment explaining its purpose as it's less common.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. packages/unuse/package.json:31
  • Draft comment:
    Dependency on 'unuse-reactivity' using workspace:* looks correct; ensure that this version resolution fits your release strategy.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
3. packages/unuse/src/index.ts:1
  • Draft comment:
    Re-exporting all reactivity APIs from 'unuse-reactivity' centralizes the interface. Verify that consumers receive the correct updated types.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. packages/unuse/src/toUnSignal/index.ts:29
  • Draft comment:
    Consider consolidating the undefined and null checks (lines 30–36). For example, using a check like 'value == null' could simplify the code.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
5. packages/unuse/src/toUnSignal/index.ts:88
  • Draft comment:
    In the React branch, the hack that mutates the state array (lines ~88–103) can break React hook invariants. Document the risks and consider a safer synchronization method.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. packages/unuse/src/unResolve/index.ts:111
  • Draft comment:
    In the Angular branch, overriding the Angular signal's 'set' and 'update' methods is risky. While marked with a HACK, consider adding additional error handling or comments clarifying the potential side effects.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. packages/unuse/src/unResolve/index.ts:135
  • Draft comment:
    In the React branch, directly mutating the result of useState (lines ~138–157) is a dangerous hack that may break React's state consistency. Ensure this workaround is well tested and documented.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
8. packages/unuse/src/unResolve/index.ts:177
  • Draft comment:
    The Solid branch similarly overrides the setter (lines ~180–208). This hack may lead to unpredictable behavior; consider reinforcing its safety with additional checks.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
9. packages/unuse/src/unResolve/index.ts:130
  • Draft comment:
    There are multiple '@ts-expect-error' comments (e.g. near lines 132 and 207). Consider revisiting these to improve type safety and reduce reliance on error suppression.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
10. packages/unuse/src/useEventListener/index.ts:170
  • Draft comment:
    The computed dependency (computedForWatch) aggregates targets, events, and listeners. Review these dependencies to ensure they do not trigger excessive re-renders or unintended re-registering of listeners.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
11. packages/unuse/src/useIntervalFn/index.ts:95
  • Draft comment:
    The condition checking if 'interval' is reactive (isUnRef(interval) || typeof interval === 'function') should be carefully reviewed to ensure it covers all edge cases.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
12. packages/unuse/src/useWebSocket/index.ts:288
  • Draft comment:
    In the auto-reconnect logic, ensure the 'checkRetires' function correctly handles both numeric and functional 'retries'. Edge cases should be considered to avoid infinite retries or premature stop.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
13. packages/unuse/src/useWebSocket/index.ts:310
  • Draft comment:
    The ws.onerror handler currently just calls the optional onError callback. Consider logging errors or adding more context to aid in debugging socket issues.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
14. packages/unuse-reactivity/README.md:7
  • Draft comment:
    Typographical suggestion: Consider changing "We just working on it." to "We are just working on it." or "We're just working on it." for improved clarity.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While the grammar correction is technically correct, our rules state we should focus on code logic issues, not minor text improvements. Documentation typos and grammar, unless severely impacting understanding, are not worth commenting on. This is a very minor grammatical issue that doesn't impact comprehension. The grammar error could make the project look unprofessional. Poor documentation quality might reflect badly on the project. While professionalism matters, this is a minor grammatical issue in a README that's explicitly marked as "UNDER CONSTRUCTION". The meaning is still clear despite the grammar mistake. Delete the comment as it's too minor and focuses on documentation style rather than code logic or functionality.
15. packages/unuse-reactivity/tsdown.config.ts:6
  • Draft comment:
    There's a potential typo in the property name on line 6: 'publint' may be a typo for 'public' or another intended word. Could you please check this?
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% Since this is a configuration file for 'tsdown', 'publint' is very likely an intentional configuration option name, not a typo. Configuration options in build tools often have specific names that might look unusual. Without strong evidence that this is actually a typo, we should not keep a comment that speculates about it. I could be wrong if 'publint' is not actually a valid configuration option for tsdown. I haven't verified the tsdown documentation. Even if I haven't verified the docs, the comment is speculative ("may be a typo") and asks for confirmation, which violates our rules about not asking authors to verify things. Delete the comment as it's speculative and asks for verification, which violates our review rules.
16. packages/unuse/src/unResolve/index.solid.spec.ts:8
  • Draft comment:
    Typographical note: The test description reads "should resolve to an Solid Signal". Consider changing "an Solid" to "a Solid" since 'Solid' begins with a consonant sound.
  • Reason this comment was not posted:
    Comment was on unchanged code.
17. packages/unuse/src/unResolve/index.vue.spec.ts:8
  • Draft comment:
    Typographical error: In the test description, it reads "should resolve to an Vue Ref". Consider changing "an Vue Ref" to "a Vue Ref".
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_VNSaFluJrBLiUQGa

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

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

♻️ Duplicate comments (11)
packages/unuse/src/toUnSignal/index.spec.ts (1)

1-1: Same module-resolution concern as noted in unAccess/index.spec.ts; please apply the chosen fix consistently.

packages/unuse/src/toUnSignal/index.vue.spec.ts (1)

1-1: Same module-resolution concern as noted in unAccess/index.spec.ts; please apply the chosen fix consistently.

packages/unuse/src/unResolve/index.solid.spec.ts (1)

2-2: Same module-resolution concern as noted in unAccess/index.spec.ts; please apply the chosen fix consistently.

packages/unuse/src/toUnSignal/index.react.spec.ts (1)

5-5: Same resolution concern for unuse-reactivity

See the remark in unResolve/index.react.spec.ts; the same applies here.

packages/unuse/src/unResolve/index.vue.spec.ts (1)

1-1: Ensure Vue test can resolve the new package

Same module-resolution note as in the React spec – configure ESLint / TS paths so unuse-reactivity is recognised.

packages/unuse/src/unResolve/index.angular.spec.ts (1)

9-9: Angular test uses the new package – verify tooling paths

Replicating the earlier comment: add/verify workspace & TS path config so unuse-reactivity resolves for ESLint and the Angular compiler.

packages/unuse/src/toUnSignal/index.solid.spec.ts (1)

2-2: Solid test – same module-resolution caveat

Confirm that unuse-reactivity is resolvable for ESLint/Vitest in the Solid suite as well.

packages/unuse/package.json (1)

30-31: Dual dependencies are justified per previous discussion.

As noted in previous comments, both dependencies serve different purposes during this transition:

  • alien-signals: Prevents external bundling while still depending on it
  • unuse-reactivity: Internal package to be inlined via noExternal configuration
packages/unuse/src/useEventListener/index.ts (1)

3-3: Unresolved import warning – see earlier comment

Same 'unuse-reactivity' resolution issue as flagged in unResolve.

packages/unuse/src/toUnSignal/index.ts (1)

3-5: Unresolved import warning – see earlier comment

Same 'unuse-reactivity' resolution issue.

packages/unuse/src/unAccess/index.ts (1)

14-15: Unresolved import warning – see earlier comment

Same 'unuse-reactivity' resolution issue.

🧹 Nitpick comments (6)
packages/unuse-reactivity/package.json (1)

5-7: Add missing build-time dependencies and clarify side-effects

tsdown is invoked in the build script yet isn’t listed in devDependencies, and the package doesn’t declare whether its modules are free of side-effects (important for tree-shaking). Consider:

   "scripts": {
     "build": "tsdown"
   },
+  "sideEffects": false,
+  "devDependencies": {
+    "tsdown": "^x.y.z"  // keep in sync with the root-level version
+  },

Including these fields eliminates “command not found” errors in CI and helps bundlers optimise consumers’ bundles.

Also applies to: 30-35

packages/unuse/src/unResolve/index.react.spec.ts (1)

4-4: Make sure the new workspace package can be resolved in all tooling

unuse-reactivity is now referenced as an external module, but ESLint reports it as unresolved.
Double-check that:

  1. packages/unuse-reactivity/package.json contains "name": "unuse-reactivity"
  2. The workspace root (or eslint-import-resolver) is configured to pick up workspaces/PNPM packages
  3. tsconfig.base.json (or the config used by Vitest) has a paths entry if strict module resolution is enabled

Otherwise IDE red squiggles and CI lint steps will keep failing even though the code runs.

packages/unuse/src/toUnSignal/index.react.spec.ts (1)

28-33: Remove profanity and clarify the TODO

The comment block contains informal/profane wording (“WHAT THE F***? IT'S BREAKING THE LAW”).
Please rephrase or remove – test code is part of the public surface and should stay professional.

-      // TODO @Shinigami92 2025-06-21: Check why this is not working
-      // WHAT THE FUCK? IT'S BREAKING THE LAW
+      // TODO(@Shinigami92): Investigate why this state-sync test fails
packages/unuse/src/unResolve/index.ts (1)

110-112: Minor: mark value-only imports to improve tree-shaking

unComputed and unEffect are runtime values, but UnComputed/UnSignal are types.
You can help modern bundlers by splitting them:

-import type { UnComputed, UnSignal } from 'unuse-reactivity';
-import { unComputed, unEffect } from 'unuse-reactivity';
+import type { UnComputed, UnSignal } from 'unuse-reactivity';
+import { unComputed, unEffect } from 'unuse-reactivity'; // keep

(Looks identical but keeps type-only import separate; some bundlers still benefit.)

packages/unuse-reactivity/README.md (2)

7-7: Fix grammatical issues in the documentation.

The tex 8000 t has grammatical errors that should be corrected for better documentation quality.

Apply this diff to fix the grammar:

-Right now there is no stable version of `unuse` available. We just working on it.
+Right now, there is no stable version of `unuse` available. We are just working on it.

9-9: Add alt text to the image for accessibility.

The image should include alt text to improve accessibility.

Apply this diff to add alt text:

-<img src="https://chronicle-brightspot.s3.amazonaws.com/6a/c4/00e4ab3143f7e0cf4d9fd33aa00b/constructocat2.jpg" width="400px" />
+<img src="https://chronicle-brightspot.s3.amazonaws.com/6a/c4/00e4ab3143f7e0cf4d9fd33aa00b/constructocat2.jpg" width="400px" alt="Construction cat illustration" />
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 18c3e78 and cfde585.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (24)
  • packages/unuse-reactivity/README.md (1 hunks)
  • packages/unuse-reactivity/package.json (1 hunks)
  • packages/unuse-reactivity/src/index.ts (1 hunks)
  • packages/unuse-reactivity/tsdown.config.ts (1 hunks)
  • packages/unuse/package.json (1 hunks)
  • packages/unuse/src/index.ts (1 hunks)
  • packages/unuse/src/toUnSignal/index.angular.spec.ts (1 hunks)
  • packages/unuse/src/toUnSignal/index.react.spec.ts (1 hunks)
  • packages/unuse/src/toUnSignal/index.solid.spec.ts (1 hunks)
  • packages/unuse/src/toUnSignal/index.spec.ts (1 hunks)
  • packages/unuse/src/toUnSignal/index.ts (1 hunks)
  • packages/unuse/src/toUnSignal/index.vue.spec.ts (1 hunks)
  • packages/unuse/src/unAccess/index.spec.ts (1 hunks)
  • packages/unuse/src/unAccess/index.ts (1 hunks)
  • packages/unuse/src/unResolve/index.angular.spec.ts (1 hunks)
  • packages/unuse/src/unResolve/index.react.spec.ts (1 hunks)
  • packages/unuse/src/unResolve/index.solid.spec.ts (1 hunks)
  • packages/unuse/src/unResolve/index.spec.ts (1 hunks)
  • packages/unuse/src/unResolve/index.ts (1 hunks)
  • packages/unuse/src/unResolve/index.vue.spec.ts (1 hunks)
  • packages/unuse/src/useEventListener/index.ts (1 hunks)
  • packages/unuse/src/useIntervalFn/index.ts (1 hunks)
  • packages/unuse/src/useWebSocket/index.ts (1 hunks)
  • packages/unuse/tsdown.config.ts (1 hunks)
🧰 Additional context used
🪛 ESLint
packages/unuse/src/unAccess/index.spec.ts

[error] 1-1: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/unResolve/index.vue.spec.ts

[error] 1-1: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/unResolve/index.react.spec.ts

[error] 4-4: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/unResolve/index.angular.spec.ts

[error] 9-9: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/toUnSignal/index.vue.spec.ts

[error] 1-1: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/unResolve/index.solid.spec.ts

[error] 2-2: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/toUnSignal/index.react.spec.ts

[error] 5-5: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/toUnSignal/index.spec.ts

[error] 1-1: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/useWebSocket/index.ts

[error] 2-2: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/toUnSignal/index.angular.spec.ts

[error] 10-10: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/toUnSignal/index.solid.spec.ts

[error] 2-2: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/unAccess/index.ts

[error] 15-15: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/useIntervalFn/index.ts

[error] 1-1: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse-reactivity/tsdown.config.ts

[error] 1-1: Unable to resolve path to module 'tsdown'.

(import-x/no-unresolved)

packages/unuse/src/useEventListener/index.ts

[error] 3-3: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/toUnSignal/index.ts

[error] 4-4: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/unResolve/index.spec.ts

[error] 1-1: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/unResolve/index.ts

[error] 11-11: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

packages/unuse/src/index.ts

[error] 1-1: Unable to resolve path to module 'unuse-reactivity'.

(import-x/no-unresolved)

🪛 LanguageTool
packages/unuse-reactivity/README.md

[typographical] ~6-~6: It appears that a comma is missing after this introductory phrase.
Context: ...ng noExternal. # UNDER CONSTRUCTION Right now there is no stable version of unuse a...

(RIGHT_NOW_PUNCTUATION_COMMA)


[grammar] ~7-~7: An auxiliary verb seems to be missing from this progressive structure. Did you mean “We're just working”, “We are just working”, or “We were just working”?
Context: ...no stable version of unuse available. We just working on it. <img src="https://chronicle-bri...

(PRP_VBG)

🪛 markdownlint-cli2 (0.17.2)
packages/unuse-reactivity/README.md

9-9: Images should have alternate text (alt text)
null

(MD045, no-alt-text)

🔇 Additional comments (11)
packages/unuse/src/unAccess/index.spec.ts (1)

1-1: Verify test-time resolution of the new package import

Vitest/TS-Node will try to load unuse-reactivity via ./dist/index.js as defined in the package’s exports.
If the package is not built before running tests, this line will throw “Cannot find module ‘unuse-reactivity’”.

Options:

  1. Pre-build the workspace packages before vitest:
    // root package.json
    { "scripts": { "test": "pnpm -r build && vitest" } }
  2. Or let Vitest compile source by adding a path alias:
    // tsconfig.base.json
    { "paths": { "unuse-reactivity": ["packages/unuse-reactivity/src/index.ts"] } }

Please ensure one of these is in place; otherwise CI will start failing.

packages/unuse/src/toUnSignal/index.angular.spec.ts (1)

9-10: LGTM - Import refactoring aligns with reactivity extraction.

The import statements have been correctly updated to use the new unuse-reactivity package instead of local modules.

However, please verify the workspace package setup to resolve the ESLint module resolution errors:

#!/bin/bash
# Verify workspace package structure and dependencies
echo "Checking workspace structure..."
fd -t d "unuse-reactivity" packages/

echo -e "\nChecking package.json files..."
fd "package.json" packages/ --exec cat {} \; --exec echo "---"

echo -e "\nChecking if unuse-reactivity is built..."
ls -la packages/unuse-reactivity/dist/ 2>/dev/null || echo "dist directory not found"
packages/unuse/src/useWebSocket/index.ts (1)

2-2: Excellent import consolidation.

The consolidation of unSignal and unWatch imports from separate local modules into a single import from unuse-reactivity improves code organization and aligns with the reactivity extraction goals.

packages/unuse/src/useIntervalFn/index.ts (1)

1-1: Clean import consolidation matches the refactoring pattern.

The consolidation of unSignal and unWatch imports aligns with the reactivity extraction across the codebase.

packages/unuse/tsdown.config.ts (1)

7-7: Essential configuration for internal package bundling.

The noExternal: ['unuse-reactivity'] configuration is crucial for the reactivity extraction architecture. It ensures that unuse-reactivity code is bundled directly into the unuse distribution rather than being treated as an external dependency, supporting the goal of keeping unuse-reactivity as an internal package.

packages/unuse/src/unResolve/index.spec.ts (1)

1-1: ESLint flags the new 'unuse-reactivity' path as unresolved – ensure Node/Vitest can actually resolve it

import { … } from 'unuse-reactivity'; is now used across all test files, but the ESLint rule import-x/no-unresolved cannot find that package.
Double-check that at least one of the following is true before CI runs the test suite:

  1. packages/unuse-reactivity/package.json is built (or ts-node-ready) and has the correct "exports"/"main" fields so that plain node resolution works.
  2. Your monorepo tooling (pnpm-workspace, Yarn workspaces, etc.) installs the package into the root node_modules.
  3. Vitest/TS config contains a paths/alias entry such as
    // vitest.config.ts or tsconfig.json
    resolve: { alias: { 'unuse-reactivity': fileURLToPath(new URL('../../unuse-reactivity/src', import.meta.url)) } }

Without one of those, runtime will fail even if the bundler setup passes.

packages/unuse/src/unResolve/index.ts (1)

10-12: Same unresolved-module issue applies to source code – set up path mapping or workspace dependency

All runtime code now imports from 'unuse-reactivity'. Make sure the package appears in
packages/unuse/package.json dependencies (not only in the root) and
tsconfig.build.json/rollup/tsup external/noExternal config is updated accordingly, otherwise:

  • tsc / ESLint will continue to yell (import-x/no-unresolved);
  • npm pack of @un-ts/unuse will ship unresolved bare imports.

If your intent is to bundle the inner package, add something like:

// tsdown.config.ts (inside unuse)
noExternal: ['unuse-reactivity'],
alias: { 'unuse-reactivity': '../unuse-reactivity/src' },

Please verify with a cold install + build.

packages/unuse-reactivity/tsdown.config.ts (1)

1-7: LGTM! Standard tsdown configuration for a TypeScript package.

The configuration appropriately sets up the build for a neutral platform library with export handling and public API linting enabled. The ESLint error about unresolved 'tsdown' is likely a false positive related to workspace dependency resolution.

packages/unuse-reactivity/src/index.ts (1)

1-5: LGTM! Clean barrel export pattern for the reactivity system.

This consolidates the core reactivity modules (unComputed, unEffect, unEffectScope, unSignal, unWatch) into a single entry point, providing a clean API surface for the extracted reactivity system. This aligns well with the PR objective to modularize the reactivity functionality.

packages/unuse-reactivity/README.md (1)

3-3: Good explanation of the package purpose.

The README clearly explains that unuse-reactivity is an internal package compiled into unuse's distribution via noExternal, which aligns with the PR objectives.

packages/unuse/src/index.ts (1)

1-1: Excellent architectural change - clean extraction of reactivity system.

This change successfully extracts the reactivity functionality into the separate unuse-reactivity package while maintaining the same public API surface. The approach aligns perfectly with the PR objectives to modularize the reactivity system and prepare for future enhancements like adding unEffect.

The ESLint error about unresolved 'unuse-reactivity' is expected during development and should resolve once the workspace dependencies are properly configured with the noExternal bundling.

@Shinigami92 Shinigami92 merged commit 718d38e into main Jun 27, 2025
15 checks passed
@Shinigami92 Shinigami92 deleted the chore-extract-reactivity branch June 27, 2025 05:24
@coderabbitai coderabbitai bot mentioned this pull request Jun 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0