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

Unbundle Social JS code from Jetpack and Social #38330

Closed
wants to merge 61 commits into from

Conversation

manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented Jul 15, 2024

Currently, the JS code of social that gets bundled in Jetpack takes precedence over Social even if Social is the latest version. This makes it difficult to fix a bug in Jetpack given the monthly release cycle. Thus we should explore ways to ensure that the JS code is not dependent upon what has been bundled with the plugin. The latest version of the JS code should be used if it's present in any of the plugins.

P2 post: pdWQjU-Mc-p2

This PR is a proof of concept to test unbundling of publicize and the related JS code/logic from both Jetpack and Social plugin. This moves the JS bundling from Jetpack/Social to the publicize package to ensure that the latest version of the code is always loaded regardless of which plugin is active.

Proposed changes:

  • Create webpack utils for dependency extraction. These utilities can be used by other plugins if they need to.
  • Prepare publicize package for bundling by adding a webpack config
  • Update a few components in Jetpack and Social for testing the PoC.
  • To ensure that the separate bundling works correctly, we need to ensure that the initial state is rendered before the publicize handle and thus this PR changes the handles for initial state.

Approach/idea

The basic idea is to make Jetpack independent of js-packages/publicize-components package and rather depend upon publicize package. So, if Jetpack or Social needs to render something common from publicize-components, it must be exported via publicize package. The Social specific code like the admin page may remain in Social plugin itself, i.e. it may consume publicize-components.

The publicize package will export the shared components via its own bundle on runtime just like WP core components and other packages.

This will ensure that we will always have the latest version of publicize UI both in Jetpack and Social.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Ensure that there is no jetpack watch ... command running for any plugin
  • Install the dependencies - pnpm install
  • Run jepack build plugins/social and jetpack build plugins/jetpack
  • Now run jetpack build packages/publicize
  • Now goto connections management on both Jetpack and Social settings pages
  • Confirm that everything is as before
  • Now make a change to to a file used in connections management, e.g. change the button label from 'Connect an account' to something else in publicize-components/src/components/connection-management/index.tsx, e.g. 'Connect a social account'
  • Now build only publicize package - jetpack build packages/publicize
  • Goto connections management again on both Jetpack and Social settings pages
  • Confirm that the button label is what you updated to.
  • Now change that button label again to something different.
  • Now build the plugins not the package - jepack build plugins/social and jetpack build plugins/jetpack
  • Confirm that the label is not changes because publicize wasn't built yet.
  • For simple sites, apply D155515-code and this PR to your sandbox and point your site and public API to your sandbox.
  • Goto post editor on that simple site
  • Confirm that Jetpack sidebar loads correctly and everything there works as before.

@manzoorwanijk manzoorwanijk self-assigned this Jul 15, 2024
@github-actions github-actions bot added [Extension] Publicize Block editor plugin [JS Package] Webpack Config [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin Admin Page React-powered dashboard under the Jetpack menu RNA labels Jul 15, 2024
Copy link
Contributor

github-actions bot commented Jul 15, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for September 10, 2024 (scheduled code freeze on undefined).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Search plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Social plugin:

  • Next scheduled release: none scheduled.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

github-actions bot commented Jul 15, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the update/unbundle-publicize-from-jetpack branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/unbundle-publicize-from-jetpack
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/unbundle-publicize-from-jetpack
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@manzoorwanijk manzoorwanijk requested a review from a team July 15, 2024 10:31
@manzoorwanijk manzoorwanijk force-pushed the update/unbundle-publicize-from-jetpack branch from 0070129 to 8126aae Compare July 15, 2024 11:29
projects/js-packages/webpack-config/src/dependencies.js Outdated Show resolved Hide resolved
projects/js-packages/webpack-config/src/dependencies.js Outdated Show resolved Hide resolved
projects/js-packages/webpack-config/src/dependencies.js Outdated Show resolved Hide resolved
projects/packages/publicize/postcss.config.js Outdated Show resolved Hide resolved
projects/packages/publicize/webpack.config.js Outdated Show resolved Hide resolved
projects/plugins/jetpack/class.jetpack-gutenberg.php Outdated Show resolved Hide resolved
projects/packages/publicize/package.json Outdated Show resolved Hide resolved
projects/plugins/social/src/class-jetpack-social.php Outdated Show resolved Hide resolved
@anomiex
Copy link
Contributor

anomiex commented Sep 6, 2024

This is looking reasonable to me now. 👍 I'll leave final review for the Reach team.

@manzoorwanijk
Copy link
Member Author

This is looking reasonable to me now. 👍 I'll leave final review for the Reach team.

Yeah, this is blocked by publicize initial state refactor. We will come back to this once that is done.

@manzoorwanijk manzoorwanijk changed the title POC: Unbundle Social JS code from Jetpack and Social Unbundle Social JS code from Jetpack and Social Sep 7, 2024
@manzoorwanijk
Copy link
Member Author

We at @Automattic/jetpack-reach have decided to deprioritize this for now and come back later.

@manzoorwanijk manzoorwanijk deleted the update/unbundle-publicize-from-jetpack branch September 18, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu DO NOT MERGE don't merge it! E2E Tests [Extension] Publicize Block editor plugin [JS Package] Publicize Components [JS Package] Webpack Config [Package] Connection [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin RNA [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants