Skip to content
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

refactor: combine react and core packages into one #448

Merged
merged 4 commits into from
Jan 17, 2025
Merged

Conversation

AndyTWF
Copy link
Collaborator

@AndyTWF AndyTWF commented Jan 10, 2025

Context

CHADR-083

Docs PR: ably/docs#2385

Description

This change combines the core and react packages into one - so that one import is required to use the full suite of functionality.

Before users would do:

import {import1} from '@ably/chat'
import {reactImport} from '@ably/chat/react'

Now it is:

import {import1, reactImport} from '@ably/chat'

The build is updated as follows:

  • dist/core is the core libraries only, which are used for the CDN upload.
  • dist/chat is the entire library - both react and chat, for Node, React, React-native and bundled-core users.

Also included are:

  • A small fix to remove an incompatible method, that allows Chat to be used and built in Node 18.
  • Node 22 is now supported and the default version we use for development.
  • eslint-plugin-node to help us with Node things.
  • A "global" index.ts for the combined package, which imports / exports the core/react indexes.
  • Updating ably/chat imports in React to use relative paths.

Checklist

  • QA'd by the author.
  • Unit tests created (if applicable).
  • Integration tests created (if applicable).
  • Follow coding style guidelines found here.
  • TypeDoc updated (if applicable).
  • (Optional) Update documentation for new features.
  • Browser tests created (if applicable).
  • In repo demo app updated (if applicable).

Testing Instructions (Optional)

Please give the demo app a good test run to ensure that everything works as before.

Copy link

coderabbitai bot commented Jan 10, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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. (Beta)
  • @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

github-actions bot commented Jan 10, 2025

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 93.67% (🎯 92%) 3183 / 3398
🟢 Statements 93.67% (🎯 92%) 3183 / 3398
🟢 Functions 95.76% (🎯 92%) 249 / 260
🟢 Branches 94.23% (🎯 93%) 850 / 902
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/vite.config.ts 0% 0% 0% 0% 1-23
src/core/room.ts 100% 100% 100% 100%
src/core/vite.config.ts 0% 0% 0% 0% 1-23
src/react/contexts/chat-client-context.tsx 100% 50% 100% 100%
src/react/contexts/chat-room-context.tsx 100% 100% 100% 100%
src/react/helper/room-promise.ts 97.72% 100% 100% 97.72% 67
src/react/helper/use-eventual-room.ts 85.71% 80% 100% 85.71% 28-30, 36, 70-72, 78
src/react/helper/use-room-status.ts 100% 100% 100% 100%
src/react/hooks/use-chat-client.ts 100% 100% 100% 100%
src/react/hooks/use-chat-connection.ts 100% 100% 100% 100%
src/react/hooks/use-logger.ts 100% 100% 100% 100%
src/react/hooks/use-messages.ts 95.78% 92.59% 100% 95.78% 145-146, 153-154
src/react/hooks/use-occupancy.ts 100% 100% 100% 100%
src/react/hooks/use-presence-listener.ts 90.04% 87.8% 100% 90.04% 122-125, 142-145, 168-173, 177-181, 203
src/react/hooks/use-presence.ts 98.16% 100% 100% 98.16% 148-149
src/react/hooks/use-room-reactions.ts 100% 100% 100% 100%
src/react/hooks/use-room.ts 100% 100% 100% 100%
src/react/hooks/use-typing.ts 99.1% 91.42% 100% 99.1% 90
src/react/providers/chat-client-provider.tsx 100% 100% 100% 100%
src/react/providers/chat-room-provider.tsx 90.82% 84.61% 100% 90.82% 92-94, 110-112, 158-159, 184-185
src/react/types/chat-status-response.ts 0% 0% 0% 0% 1
src/react/types/status-params.ts 0% 0% 0% 0% 1
Generated in workflow #1942 for commit 9b704b0 by the Vitest Coverage Report Action

@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 10, 2025 17:20 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 12, 2025 16:47 Inactive
@AndyTWF AndyTWF force-pushed the combine-packages branch 2 times, most recently from 0ff8063 to 4ef9c39 Compare January 12, 2025 18:22
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 12, 2025 18:22 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 12, 2025 18:26 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 13, 2025 13:27 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 13, 2025 13:29 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 13, 2025 13:35 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 14, 2025 17:16 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 15, 2025 09:24 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 15, 2025 09:29 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 15, 2025 09:35 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/448/typedoc January 15, 2025 09:58 Inactive
@AndyTWF AndyTWF marked this pull request as ready for review January 15, 2025 12:27
This change combines the core and react packages into one - so that one import is required to use the full suite of functionality.

It also updates the build:

dist/core is the core libraries only, which are used for the CDN upload.
dist/chat is the entire library - both react and chat.
Adds the node engine version to package.json, which ensures we enforce the correct engine version.
This change allows the SDK to be tested and run against node 18.
@splindsay-92
Copy link
Contributor

Do we need to update the package.json to show the new node engine?

@@ -63,8 +56,21 @@
"url": "https://github.com/ably/ably-chat-js/issues"
},
"homepage": "https://github.com/ably/ably-chat-js#readme",
"engines": {
"node": ">=18.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

This need to be updated?

Copy link
Collaborator Author

@AndyTWF AndyTWF Jan 17, 2025

Choose a reason for hiding this comment

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

I just added this one as we didn't have it before - this should be ok as we are supporting Node 18+

@AndyTWF
Copy link
Collaborator Author

AndyTWF commented Jan 17, 2025

Forcing this merge as new checks aren't in main yet

@AndyTWF AndyTWF merged commit 208c96b into main Jan 17, 2025
12 checks passed
@AndyTWF AndyTWF deleted the combine-packages branch January 17, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants