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

Add Push plugin to cdn #1861

Merged
merged 4 commits into from
Sep 11, 2024
Merged

Add Push plugin to cdn #1861

merged 4 commits into from
Sep 11, 2024

Conversation

VeskeR
Copy link
Contributor

@VeskeR VeskeR commented Sep 11, 2024

See internal slack discussion: https://ably-real-time.slack.com/archives/CURL4U2FP/p1723454752656739.

We can't use existing push plugin build output as it has ulid as external and it tries to import it as a commonjs module. Found the reasoning for this here, with ref to the esbuild docs:

External ... Instead of being bundled, the import will be preserved (using require for the iife and cjs formats and using import for the esm format) and will be evaluated at run time instead.

This means that for the use of push plugin via script tag from CDN, we would need to either polyfill the require call, or add some wrapper/replace require('ulid') call with window.ulid (potentially doable with https://github.com/yanm1ng/esbuild-plugin-external-global#readme, but quick test locally didn't produce expected result - it end up calling require anyway).

All of the above would mean having a separate file for push plugin for CDN use anyway, so at this point it's just easier to bundle ulid together with push plugin for CDN specifically, and publish that.
This way CDN users get easy use of the Push plugin (no need to also include ulid via CDN), and users that use npm still have access to the push plugin file without extra code (saves ~1kb gzipped).

Summary by CodeRabbit

  • New Features

    • Introduced a new CDN configuration for the push plugin, enhancing the build process.
    • Expanded the file matching criteria for S3 uploads to include "push" files.
    • Added documentation for loading the Push plugin directly in HTML and instantiating it with the Ably client.
  • Bug Fixes

    • Corrected a comment for clarity in the S3 upload configuration.
  • Performance Improvements

    • Enhanced build efficiency by allowing concurrent execution of multiple build operations.

Copy link

coderabbitai bot commented Sep 11, 2024

Walkthrough

The changes involve modifications to the build process within the Gruntfile.js, the introduction of new configurations for the CDN build in grunt/esbuild/build.js, and updates to the S3 upload configuration in scripts/cdn_deploy.js. The build task now executes three operations concurrently, enhancing efficiency. Additionally, the CDN configurations allow for both standard and minified outputs for the push plugin, while the deployment script broadens the criteria for file uploads.

Changes

File Change Summary
Gruntfile.js Modified the build:push task to use Promise.all for concurrent execution of three esbuild operations, improving build efficiency.
grunt/esbuild/build.js Added two new configuration objects, pushPluginCdnConfig and minifiedPushPluginCdnConfig, for the CDN build of the push plugin, specifying entry points and output files.
scripts/cdn_deploy.js Updated fileRegex to include files prefixed with "push" for S3 uploads, expanding the scope of eligible files while correcting a comment for clarity.
README.md Added documentation for loading the Push plugin in HTML, instantiating the Ably client with the Push plugin, and semantic versioning rules for the Push plugin.

Poem

🐰 In the land of code, where builds do play,
Three tasks now dance in a parallel sway.
With plugins and configs, oh what a sight,
A push to the CDN, all done just right!
Hopping along, we celebrate with cheer,
For every new change brings us closer, my dear! 🌟


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f8bdf9d and a80ff5f.

Files selected for processing (4)
  • Gruntfile.js (1 hunks)
  • README.md (2 hunks)
  • grunt/esbuild/build.js (1 hunks)
  • scripts/cdn_deploy.js (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • Gruntfile.js
  • grunt/esbuild/build.js
  • scripts/cdn_deploy.js
Additional context used
LanguageTool
README.md

[grammar] ~77-~77: You used an adverb (‘Ably’) instead of an adjective, or a noun (‘client’) instead of another adjective.
Context: ...m/lib/ably.min-1.js"></script> ``` The Ably client library follows [Semantic Versioning](h...

(A_RB_NN)

Markdownlint
README.md

77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


572-572: Expected: indented; Actual: fenced
Code block style

(MD046, code-block-style)


578-578: Expected: indented; Actual: fenced
Code block style

(MD046, code-block-style)

Additional comments not posted (4)
README.md (4)

77-77: LGTM!

The code segment provides clear examples of how to lock into specific versions of the Ably client library using semantic versioning. The use of bare URLs is appropriate here.

Tools
LanguageTool

[grammar] ~77-~77: You used an adverb (‘Ably’) instead of an adjective, or a noun (‘client’) instead of another adjective.
Context: ...m/lib/ably.min-1.js"></script> ``` The Ably client library follows [Semantic Versioning](h...

(A_RB_NN)

Markdownlint

77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Bare URL used

(MD034, no-bare-urls)


77-77: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


572-574: LGTM!

The HTML example for loading the Push plugin directly using a script tag is helpful for users who can't use a package manager. Using a fenced code block to embed the HTML is acceptable here.

Tools
Markdownlint

572-572: Expected: indented; Actual: fenced
Code block style

(MD046, code-block-style)


578-583: LGTM!

The JavaScript example nicely complements the previous HTML one, demonstrating how to pass the Push plugin to the Ably instance when it's loaded via a script tag. The fenced code block is an appropriate way to embed this code snippet.

Tools
Markdownlint

578-578: Expected: indented; Actual: fenced
Code block style

(MD046, code-block-style)


585-586: LGTM!

It's helpful to clarify that the Push plugin follows the same semantic versioning rules as the Ably client library. The examples of locking into specific versions using the CDN URL are clear and consistent with the earlier examples for the main library.

Tools
Markdownlint

585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Bare URL used

(MD034, no-bare-urls)


585-585: null
Spaces inside emphasis markers

(MD037, no-space-in-emphasis)


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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.

@github-actions github-actions bot temporarily deployed to staging/pull/1861/bundle-report September 11, 2024 14:18 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1861/features September 11, 2024 14:18 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1861/typedoc September 11, 2024 14:18 Inactive
Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

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

Looks good so far, couple of suggestions. Also, worth updating the README as part of this PR?

grunt/esbuild/build.js Outdated Show resolved Hide resolved
grunt/esbuild/build.js Show resolved Hide resolved
@VeskeR
Copy link
Contributor Author

VeskeR commented Sep 11, 2024

Also, worth updating the README as part of this PR?

Yeah, good idea. Will add the section to Push plugin about using it from CDN

@VeskeR
Copy link
Contributor Author

VeskeR commented Sep 11, 2024

Added readme in a80ff5f

@github-actions github-actions bot temporarily deployed to staging/pull/1861/bundle-report September 11, 2024 15:04 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1861/typedoc September 11, 2024 15:05 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1861/features September 11, 2024 15:05 Inactive
Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@VeskeR VeskeR merged commit 7d6d512 into main Sep 11, 2024
13 of 14 checks passed
@VeskeR VeskeR deleted the push-plugin-cdn branch September 11, 2024 15:31
@coderabbitai coderabbitai bot mentioned this pull request Sep 11, 2024
VeskeR added a commit that referenced this pull request Oct 1, 2024
Base code, tests and build setup for new LiveObjects plugin. Adds a new
`.liveObjects` property for RealtimeChannel.

Plugin setup is based on Web Push plugin PR [1], and CDN setup for Push
plugin PR [2].

Resolves DTP-947

[1] #1775
[2] #1861
VeskeR added a commit that referenced this pull request Oct 1, 2024
Base code, tests and build setup for new LiveObjects plugin. Adds a new
`.liveObjects` property for RealtimeChannel.

Plugin setup is based on Web Push plugin PR [1], and CDN setup for Push
plugin PR [2].

Resolves DTP-947

[1] #1775
[2] #1861
VeskeR added a commit that referenced this pull request Oct 1, 2024
Base code, tests and build setup for new LiveObjects plugin. Adds a new
`.liveObjects` property for RealtimeChannel.

Plugin setup is based on Web Push plugin PR [1], and CDN setup for Push
plugin PR [2].

Resolves DTP-947

[1] #1775
[2] #1861
VeskeR added a commit that referenced this pull request Oct 1, 2024
Base code, tests and build setup for new LiveObjects plugin. Adds a new
`.liveObjects` property for RealtimeChannel.

Plugin setup is based on Web Push plugin PR [1], and CDN setup for Push
plugin PR [2].

Resolves DTP-947

[1] #1775
[2] #1861
VeskeR added a commit that referenced this pull request Oct 2, 2024
Base code, tests and build setup for new LiveObjects plugin. Adds a new
`.liveObjects` property for RealtimeChannel.

Plugin setup is based on Web Push plugin PR [1], and CDN setup for Push
plugin PR [2].

Resolves DTP-947

[1] #1775
[2] #1861
VeskeR added a commit that referenced this pull request Oct 2, 2024
Base code, tests and build setup for new LiveObjects plugin. Adds a new
`.liveObjects` property for RealtimeChannel.

Plugin setup is based on Web Push plugin PR [1], and CDN setup for Push
plugin PR [2].

Resolves DTP-947

[1] #1775
[2] #1861
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.

None yet

2 participants